Chapter 3 · Give context#

The big idea#

The model has read a huge amount of text but knows nothing about you: your company, your project, your reader or what you tried last time. Context is the background that makes an answer fit your situation instead of the average situation. Give the goal, the audience, the facts to use and what has already happened.

Everyday example: Asking a taxi driver to “take me to the station” works only if there is one station in town. In a city with three, you must say which one, or you may be driven to the wrong place very efficiently.

In plain words

Put the facts you want used in the prompt. If a fact is not written there, the model will either guess or ignore it.

A picture#

Give context The model cannot see your situation unless you describe it. Give context Before Write a cover letter After Write a cover letter for a junior data analyst role at a bank; I have 1 year of SQL internship experience Who you are + what it's for + facts to use Same model, same question. Only the prompt changed.
The model cannot see your situation unless you describe it.

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 cover letter#

Before

Write a cover letter.

Typical reply

Dear Hiring Manager,

I am writing to express my interest in the position advertised. I am a hard-working team player with excellent communication skills... (could be about any job and any person)

After

Write a cover letter for a junior data analyst role at a retail bank. About me: final-year statistics student, a 6-month SQL internship where I built a weekly sales dashboard used by 12 people, and basic Python. Tone: warm and confident. Max 180 words.

Typical reply

Dear Hiring Manager,

I am a final-year statistics student applying for the junior data analyst role. During my six-month SQL internship I built a weekly sales dashboard that 12 colleagues used to plan their week, which taught me how to turn raw numbers into decisions. I also use Python for analysis and am keen to apply these skills in banking...

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. The facts (6 months, 12 people, the dashboard) are the only reason the second letter sounds like a real person. The model cannot make those up truthfully.

Example 2 · Debugging#

Before

My code doesn't work, fix it.

Typical reply

Could you please share the code and describe the error you are seeing? (the model has nothing to work with)

After

This Python function should return the average of a list, but `average([])` crashes with ZeroDivisionError. I use Python 3.11. Fix it so an empty list returns 0, and explain the change in one sentence.

```python
def average(nums):
    return sum(nums) / len(nums)
```

Typical reply

Fixed:

```python
def average(nums):
    if not nums:
        return 0
    return sum(nums) / len(nums)
```

An empty list has length 0, so the division failed; the early return handles that case.

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    4/7  [. Y . Y Y . Y]  missing: task, audience, example

Why it works. The goal, the symptom, the version and the code arrive together. This is the context a colleague would ask for if you were sitting next to them.

What to include#

  • Goal: what the result will be used for.

  • Audience: who reads or uses it.

  • Facts: names, numbers, dates, the exact error message.

  • History: what you already tried or what the last version got wrong.

  • Constraints of the environment: language version, tools, budget, deadline.

Rules of thumb#

  • Paste the real thing: the actual error, the actual paragraph, the actual numbers.

  • State the goal as well as the task. “Rewrite this” is less useful than “rewrite this so a customer stops asking the same question”.

  • Keep context relevant. Ten unrelated paragraphs hide the one that matters.

Common mistakes#

  • Describing the problem instead of pasting it (“my function is broken”).

  • Leaving out the goal, so the model solves a different problem.

  • Including private data you should not share, such as passwords, keys or customer details. Remove or mask them first.

Try it yourself#

  1. Add context to: “Plan a trip.”

  2. What four facts would you add to “Why is my website slow?”

  3. Name one piece of information you should never put in a prompt.

Answers
  1. “Plan a 3-day trip to Jaipur for two adults in November. Budget: 25,000 rupees total. We like food and forts, dislike long drives. Give a day-by-day list with rough costs.”

  2. The framework or stack, how slow (seconds), which page, and what changed recently. Possibly a sample of the network timing.

  3. Secrets such as passwords, API keys and other people’s personal data. Mask them, for example API_KEY=<hidden>.

Next

Context tells the model about the world. A role tells it how to behave in it. Next: assign a role.