Prompting
Concepts · topic concepts/prompting
Prompting is the craft of writing the text a model responds to. Good prompts state the instruction clearly, supply examples when the format matters, set a role or system prompt that frames the whole conversation, ask for output in a usable shape, and improve through deliberate iteration rather than repeated retries.
Concepts
- Instruction
- The part of a prompt that says what to do. A clear instruction names the task, the input it applies to, the constraints to respect and what a good result looks like. Vague instructions are filled in by the model with plausible defaults, so most prompt failures trace back to something the instruction left unsaid rather than to the model misunderstanding. glossary
- Example (few-shot)
- One or more worked input-output pairs placed in the prompt so the model can copy the pattern. Few-shot examples are the most reliable way to fix a format, tone or edge-case behavior that is hard to describe in words. Two or three well-chosen examples usually beat a long paragraph of rules, and a bad example teaches the mistake just as well. glossary
- Role and system prompt
- Text set before the conversation starts that frames every later turn. A system prompt typically assigns a role, sets tone, states standing rules and lists what the model must never do. In chat products the vendor writes one you cannot see; in agents and custom applications the developer writes it, and it is where recurring behavior is fixed. glossary
- Iteration
- Improving a result by changing the prompt after reading the output, rather than resending the same prompt hoping for a better draw. Each round adds a missing constraint, an example of the failure, or a sharper definition of done. Iteration is the normal way to reach a reliable prompt; a first attempt that works is the exception. glossary
- Structured output
- Asking the model to answer in a fixed shape, such as a table, a numbered list with named fields, or a machine-readable format like JSON, so the next step can use the result without a human reformatting it. Naming the fields and giving one example of the shape makes the output far more consistent and makes missing information visible. glossary
Links
- Builds on: How language models work
- Leads to: What an agent is, Working with an assistant
- Competencies drawing on it: Writes prompts that get reliable results
Lessons
- Change the prompt before you retry (tutorial)
- Show one example (tutorial)
- Instruction, context and format (tutorial)
- Output the next step can use (tutorial)
- The prompt before the conversation (explanation)
Your reference
Each lesson above adds its takeaways and its example here once you finish it. Your reference lists every lesson you have finished.
Change the prompt before you retry
Unlocks when you finish Change the prompt before you retry.
Takeaways
- A retry draws another sample from the same distribution. The wording changes, and the gap the prompt left stays, because the prompt is what makes one answer more likely than another.
- Name what is wrong with the output in one sentence, as a fact about the text. That sentence points at the line the prompt is missing.
- Change one thing per round and compare with the round before. The difference then has one cause, and you know which line to keep.
- A correction you made twice goes into the prompt you keep. A saved template grows by one tested line at a time and never by a rewrite.
Example
Summarize the meeting notes between the triple quotes for a colleague who missed the meeting. List every decision as its own bullet, starting with "Decided:", and end each decision with the name of the person who acts on it. Write five bullets, each under 20 words, as plain text.
""" [the notes, pasted in full] """
- Pilot sign-ups are 30 percent above plan, but support tickets have doubled, most about the invoice page.
- Decided: improve the invoice help text first, review tickets again on 20 October. Tom.
- Decided: no second pilot region until invoice tickets come down. Anna tells the regional lead.
- Decided: weekly status mail moves from Friday to Thursday. Ben.
- Chloe showed new logo drafts. The team reviews them next week.
Show one example
Unlocks when you finish Show one example.
Takeaways
- A paragraph of rules is one sentence per requirement, and the model has to turn each sentence into a pattern before it can follow it. The default from its training text often pulls harder.
- One worked input and output pair shows the pattern directly, and the model continues it, layout and edge cases included. The pair is a few-shot example, a term the paper on the effect made common.
- Show an example for a format with layout in it, a tone, or an edge case. Describe in words when the requirement is a number or a word.
- The biggest gain is from no example to one. One example is often enough for a format, and this course's advice is two or three chosen to show variety before a page of rules. Each one costs tokens.
- The model often copies the example more closely than it follows a rule, so it copies a mistake in the example too. Read every example as a spec, and fix the example rather than writing a rule against it.
Example
Rewrite the rough meeting notes between the triple quotes in our house style. The first line has the weekday and the date, a short subject, and the attendees' initials in brackets. Lines after the first start with a tag in capitals: DECIDED, OPEN or NOTED. The tags are padded so the items start in the same column. Each item is a short fragment. At the end of a DECIDED or OPEN line, an arrow and the owner's initials, with a deadline if there is one. NOTED lines have no arrow. Use no heading, bullets or blank lines.
"""[the rough notes, pasted in full]"""**Meeting notes, 18 September: Varrowmere delivery**Attendees: MK, JV, SR
- DECIDED: Accept the new delivery date of Friday 17 October (morning). -> MK to confirm with Varrowmere before Thursday.- DECIDED: Cancel the Tuesday unloading shift. -> SR- OPEN: Who will receive the two replacement chairs on arrival? -> JV to ask Facilities.- NOTED: The delay is caused by a port strike. No action required for us.Instruction, context and format
Unlocks when you finish Instruction, context and format.
Takeaways
- A one-line request gets the average answer, because the model fills every gap with the most common default from its training text.
- The instruction says what to do and under which constraints. Most prompt failures trace back to something it left unsaid.
- The context is the material the model works on. Fence it with a delimiter, name that delimiter in the instruction, and keep the instruction outside the fence. Material and instruction that run together let a line of the material become the order.
- Name the audience and the purpose. They decide what the summary keeps and what it leads with.
- State the format and the length in numbers. "Short" is a guess and "three bullets under 15 words" is a check.
Example
Summarize this.
[the email, pasted in full]
This email from Varrowmere Freight informs the customer that their order 4471 has been delayed by three days due to a port strike. The delivery has been rescheduled from Tuesday 14 October to Friday 17 October between 8:00 and 12:00, and includes the two replacement chairs. The customer is asked to confirm by Thursday whether the new time works, or to propose two alternative dates.
Output the next step can use
Unlocks when you finish Output the next step can use.
Takeaways
- Prose is for a person to read. When the next step is a program, ask for the format that program reads, and the retyping and the decisions made while retyping disappear.
- A usable format request names the output type, the fields of each item, and the allowed values of every field that has a fixed set of them, including how dates and numbers are written.
- "Return JSON" fixes the packaging and leaves the keys and values to the model, which may choose differently on each run. Named keys make runs comparable and make a missing value visible.
- Check the first result against its consumer, the import or the script that reads the file, before you produce the rest. Fixing the prompt after item 1 costs one change.
Example
List every action item from the notes between the triple quotes. Return a JSON array with one object per item. Each object has exactly these four keys, and no others:
- "owner": the first name as written in the notes
- "task": what they do, under 12 words
- "due": the date as "YYYY-MM-DD", in the year 2026
- "priority": one of "high", "medium", or "low", taken from what the notes say about urgency
Return only the JSON, with no text before or after it.
""" [the notes, pasted in full] """
[ {"owner": "Jonas", "task": "fix the password reset email address", "due": "2026-10-03", "priority": "high"}, {"owner": "Sam", "task": "get two quotes for a new search box", "due": "2026-10-17", "priority": "low"}, {"owner": "Maria", "task": "replace the old system name in the help texts", "due": "2026-10-10", "priority": "low"}, {"owner": "Dana", "task": "book the accessibility check with the agency", "due": "2026-10-08", "priority": "medium"}]The prompt before the conversation
Unlocks when you finish The prompt before the conversation.
Takeaways
- The system prompt is text the model reads before the conversation. It sets a role, a tone, the standing rules and a never-do list, and it frames every later turn.
- Two assistants on the same model with different system prompts give different answers to the same message, in length and in what they refuse.
- In a chat product the vendor writes it, and you can add standing instructions of your own. In an agent or a custom application the developer writes it, and that is where recurring behavior gets fixed.
- A rule typed into the chat lasts one conversation. A rule that should hold every time goes where the conversation starts.
- The instruction files that coding agents read at the start of a session,
AGENTS.mdorCLAUDE.md, do the same job for a project: standing rules, loaded before your first message. The lesson on project instructions shows how to write one.
Example
System prompt: You are the assistant for the internal help desk of a small company. Answer in plain English, in at most three sentences. Do not give steps the user has not asked for. If a question is about pay, contracts or leave, do not answer it. Say that the human resources (HR) team handles it and give the HR mailbox, hr@example.com.
User: My laptop won't connect to the office Wi-Fi. What do I do?
Turn Wi-Fi off and on again, and pick the network named "Office" rather than "Office-Guest". If it still fails, open a ticket with the help desk and include your laptop's asset tag. They usually respond within an hour.
Sources
DLAI-1ChatGPT Prompt Engineering for Developers, DeepLearning.AI (course)DLAI-3AI Prompting for Everyone, DeepLearning.AI (course)Brown 2020Language Models are Few-Shot Learners, Advances in Neural Information Processing Systems 33 (NeurIPS 2020) (paper)Learn PromptingThe community prompt engineering guide, Learn Prompting (reference)Academy ai-fluency-framework-foundationsAI Fluency: Framework and foundations, Claude Academy (course)Academy building-with-the-claude-apiBuilding with the Claude API, Claude Academy (course)