Chapter 1 · The anatomy of a prompt#

The big idea#

A prompt is the text you give a language model. The model does not know your goal, your audience or your situation. It only sees the words on the page and predicts a useful continuation. So the quality of the answer is limited by the quality of the page you wrote.

Everyday example: You hire a very fast, very well-read assistant on their first day. If you leave a sticky note saying “do the report”, you will get a report, probably not your report. If the note says who it is for, what it must contain, how long it should be and an example of last month’s, you get what you wanted. Prompt engineering is writing a better sticky note.

In plain words

Write the task first. Then add one part at a time, only where the answer was wrong. Longer is not better; clearer is better.

A picture#

The parts of a good prompt Six parts. Only the task is required; each extra part removes one thing the model would otherwise guess. Role who to be Context background Task what to do Examples show, don't tell Format shape of answer Limits length, rules Prompt = Role + Context + Task + Examples + Format + Limits Green is required. Blue sets the scene. Amber shapes the answer. Start with the task, then add parts only where the answer was wrong.
Six parts. Only the task is required; each extra part removes one thing the model would otherwise guess.

Before and after#

Replies below are typical examples to show the difference. Your model will word things differently, so run the prompts yourself.

Example 1 · A vague ask#

Before

Tell me about Python

Typical reply

Python is a high-level, general-purpose programming language created by Guido van Rossum in 1991. It is used in web development, data science, automation, AI and more. It has simple syntax, a large standard library... (continues for several more paragraphs)

After

Explain what a Python list comprehension is to a beginner who knows for-loops. Use one example, at most 120 words, and end with one practice question.

Typical reply

A list comprehension builds a list in one line. Instead of: `squares = []` then a for-loop that appends `n*n`, write `squares = [n*n for n in range(5)]`, which gives `[0, 1, 4, 9, 16]`. Read it as "give me n*n for each n in range(5)".

**Practice:** write a comprehension that keeps only the even numbers from `[1, 2, 3, 4, 5, 6]`.

Prompt checker (code/promptcheck.py, columns T C A F L E D):

before   0/7  [. . . . . . .]  missing: task, context, audience, format, limits, example, delimiters
after    6/7  [Y Y Y Y Y Y .]  missing: delimiters

Why it works. The first prompt has no audience, no length and no goal, so the model picks a safe encyclopedia answer. The second names the reader, the topic, the length and the ending, so there is almost nothing left to guess.

Example 2 · A work task#

Before

Write an email about the delay

Typical reply

Subject: Delay

Dear Customer,

I hope this email finds you well. I am writing to inform you of a delay. We apologise for any inconvenience this may have caused. Please let us know if you have questions. (generic, no names, no dates, no offer)

After

Write a short, polite email to a customer named Priya telling her order #4821 will arrive on Friday instead of Wednesday because of a supplier delay. Apologise once, offer free shipping on her next order, and keep it under 90 words.

Typical reply

Subject: Update on your order #4821

Hi Priya,

Your order will now arrive on Friday instead of Wednesday because of a delay at our supplier. I am sorry for the wait. To make it up to you, your next order ships free.

Thank you for your patience,
The Support Team

Prompt checker (code/promptcheck.py, columns T C A F L E D):

before   1/7  [Y . . . . . .]  missing: context, audience, format, limits, example, delimiters
after    4/7  [Y Y Y . Y . .]  missing: format, example, delimiters

Why it works. Every fact the model had to invent in the first reply (name, order, date, reason, offer) is now supplied. Specific input produces specific output.

The six parts#

Part

Question it answers

Example

Role

Who should the model be?

“You are a patient maths tutor.”

Context

What is the situation?

“The student failed the last test.”

Task

What exactly must it do?

“Explain fractions.”

Examples

What does good look like?

Two sample inputs with answers.

Format

What shape is the answer?

“A table with two columns.”

Limits

What are the boundaries?

“Under 100 words, no jargon.”

Only the task is required. The next eleven chapters take the parts one at a time, each with a before and after.

Rules of thumb#

  • Name the task with a verb: write, summarise, classify, extract, compare, fix.

  • If a human colleague would need to ask you a question, the model needs the answer in the prompt.

  • Change one thing at a time so you know what helped.

Common mistakes#

  • Writing a prompt like a search query (“python list tips”) instead of a request.

  • Assuming the model knows your project, company or audience.

  • Adding ten rules at once and not knowing which one fixed the answer.

  • Treating one good answer as proof the prompt works. Models vary; test more than once.

Try it yourself#

  1. Rewrite “Help with my resume” so a stranger could do the task. Add at least three of the six parts.

  2. Which part of the prompt would you add first if the answers were the right content but too long?

  3. Run python promptcheck.py and change the after prompt until it scores 7/7.

Answers
  1. Example: “You are a recruiter. Review my resume for a junior backend developer role (pasted below). List the 5 weakest lines, worst first, and rewrite each in one line.” Role, task, context, format and limits are all present.

  2. Limits: add a word or sentence count. Length is the cheapest thing to control.

  3. Add a delimiter, for example wrap pasted text in <text> tags. The checker only looks for visible habits, so a high score is a starting point, not a guarantee.

Next

Vague prompts cause most bad answers. Next: be specific.