AI Prompting Basics

In the last lesson, you learned AI Large Language Models. Now let us understand prompting, because most AI apps start with instructions.

A prompt is the text we send to the model.

Here is how a prompt guides the model:

Task

Prompt

Context

Style

Format

Model answer

🧠 What Is a Prompt?

A prompt is the input we give to an AI model.

It can include:

  • A question: β€œWhat is an API?”
  • An instruction: β€œExplain this in simple English.”
  • Context: β€œUse this refund policy to answer.”
  • Output format: β€œAnswer in 3 bullet points.”
  • Role or style: β€œAct like a helpful coding teacher.”

So in simple words:

  • The prompt tells the model what we want.
  • The model reads the prompt.
  • Then it generates an answer based on that prompt.

πŸ€” Why Prompting Matters

When we ask a vague question, the model has to guess what we mean.

For example:

Explain JavaScript.

This is too wide.

  • Should the answer explain variables?
  • Should it explain browser JavaScript?
  • Should it explain Node.js?
  • Should it be short or detailed?

A better prompt gives direction:

Explain JavaScript promises in simple English.
Use one real-life example and one small code example.
Keep it beginner-friendly.

Now the model knows the target better.

Clear task

Tell the model exactly what you want it to do.

Useful context

Give the model the background it needs, like the audience, goal, pasted text, or rules.

Output shape

Tell the model if you want bullets, JSON, steps, or a short paragraph.

✍️ A Simple Prompt Shape

A useful prompt often has this shape:

Task:
Explain what a REST API is.
Audience:
Beginner developer.
Style:
Simple English, point-wise.
Format:
Give 5 bullet points and one small example.

Let us understand this slowly.

  • Task tells the model what to do.
  • Audience tells the model who the answer is for.
  • Style tells the model how the answer should sound.
  • Format tells the model how to arrange the answer.

This does not guarantee a perfect answer, but it gives the model more direction, so the answer is less likely to go off-topic.

🌍 Prompts in Real Chat Apps

ChatGPT prompt

If you type "Explain APIs with one example" in ChatGPT, that full sentence is the prompt.

Claude prompt

If you paste a document and ask Claude to summarize it, the document plus instruction becomes the prompt.

Gemini prompt

If you ask Gemini to compare two ideas in a table, your wording guides the answer shape.

πŸ§ͺ Weak Prompt vs Better Prompt

Weak prompt:

Write about databases.

The problem:

  • It is too broad.
  • It does not say the level.
  • It does not say the format.
  • It does not say what the reader wants to learn.

Better prompt:

Explain what a database is for a beginner.
Use an online shopping app example.
Explain why the app needs to store users, products, and orders.
Keep the answer point-wise.

Why this is better:

  • It gives a clear topic.
  • It gives the reader level.
  • It gives a practical example.
  • It asks for point-wise explanation.

🧰 More Prompt Examples

Here are more examples you can copy and change.

The goal is not to memorize prompts. The goal is to see how clear instructions change the answer.

Explain a topic

Weak prompt:

Explain APIs.

Better prompt:

Explain what an API is for someone building a simple website.
Use a restaurant menu example.
Then show one tiny frontend-to-backend example.
Keep it point-wise.

Why this works:

  • It says the topic: API.
  • It says the audience: someone building a simple website.
  • It asks for an example.
  • It asks for point-wise output.

Summarize text

Weak prompt:

Summarize this.

Better prompt:

Summarize the text below in 5 bullet points.
Keep only the important ideas.
Do not add information that is not present in the text.
Text:
<paste the text here>

Why this works:

  • It says how many points you want.
  • It tells the model not to add extra facts.
  • It gives a clear place for the text.

Rewrite for a beginner

Weak prompt:

Make this easy.

Better prompt:

Rewrite the paragraph below in simple English.
Keep the meaning same.
Use short sentences.
Avoid difficult words.
Paragraph:
<paste the paragraph here>

Why this works:

  • It says the exact task: rewrite.
  • It protects the meaning.
  • It gives writing rules.

Compare two things

Weak prompt:

React vs Vue.

Better prompt:

Compare React and Vue for a beginner frontend developer.
Explain in a table with these columns:
- Topic
- React
- Vue
- Simple meaning
Keep the comparison practical.

Why this works:

  • It says what to compare.
  • It says who the comparison is for.
  • It gives the output structure.

Get JSON output

Weak prompt:

Give product data.

Better prompt:

Create 3 sample products for an online store.
Return only valid JSON.
Each product should have:
- id
- name
- price
- category
Do not add explanation outside the JSON.

Why this works:

  • It asks for a machine-readable format.
  • It lists required fields.
  • It says not to add extra text.

Debug code

Weak prompt:

Fix this code.

Better prompt:

Find the bug in this JavaScript code.
Explain the problem in simple words.
Then show the corrected code.
Do not rewrite unrelated parts.
Code:
<paste code here>

Why this works:

  • It tells the model to find the bug first.
  • It asks for explanation plus corrected code.
  • It prevents unnecessary rewriting.

🧩 Prompting in AI Apps

In a real app, the user prompt is not always sent alone.

The app may add extra instructions like:

  • System instruction: β€œAnswer safely and politely.”
  • Developer instruction: β€œAnswer only from provided documents.”
  • User message: β€œWhat is the refund rule?”
  • Retrieved context: A small part of the refund policy.
  • Output rule: β€œReturn the answer and source title.”

So the final prompt may be built by the app, not only typed by the user.

This is why prompting matters for developers too.

🧩 What You’ve Learned

  • βœ… A prompt is the input sent to the model.
  • βœ… Better prompts give clearer task, context, style, and format.
  • βœ… Prompting helps, but it does not guarantee truth.

Check Your Knowledge

4 questions Show quiz Hide quiz

Test what you learned. Pick an answer for each question, then click Check.

  1. 1

    What is a prompt?

    Why: A prompt is the question, instruction, or context sent to the model.

  2. 2

    Why is 'Explain JavaScript' a weak prompt?

    Why: The model does not know the level, format, or exact part of JavaScript you want.

  3. 3

    What can improve a prompt?

    Why: A clear task, context, and output format usually make the answer more useful.

  4. 4

    Can a good prompt guarantee a true answer?

    Why: Prompting helps, but the model can still make mistakes.

πŸš€ What’s Next?

When we ask an AI model something, the first answer may be too long, too vague, or in the wrong format. A useful skill is improving the prompt in small loops until the answer becomes better. Next, let us learn the prompt improvement loop.