Pebellslearn by building
0%
RoadmapsMatrixCoursesSandboxSign in
Prompting and Context  ›  Lesson

Give the Right Context

Context 12 minAn assistant works only from what is in its context, so give it the relevant files, exact evidence, your rules and what you tried, and leave out noise and secrets.

Give the Right Context

Last week you and the assistant agreed that Kitty stores money as whole paise. Today, in a new conversation, it writes a function that uses floats. It is not being stubborn. That decision simply is not in front of it. An assistant works only from what is in its context: your prompt, the files it has been shown or has read, and the earlier messages in the current session.

The rule

Give the assistant what this task needs, and nothing it doesn't.

The assistant does not know your flatmates, your decisions from last week or the error on your screen unless they reach its context. Useful context usually comes in four kinds:

  • The relevant files. The function in question, its tests, and the table layout it reads. Not the whole project.
  • Exact evidence. The full error message or the exact wrong output, copied, not "it's broken".
  • Rules and decisions. "Money is whole paise." "No JavaScript framework." "Do not change the tests."
  • What you have tried. So it does not suggest the same thing again.

More is not always better. Unrelated files can distract the assistant and bury what matters. Old versions of a file, still sitting earlier in a long conversation, can mislead it. And some things must never go into context at all: real passwords, API keys and personal data. Share the error, not the secret.

The shortcut

Before you send, imagine a skilled stranger who has never seen Kitty. Ask: what would they need to see to do this task? List the files, evidence, rules and attempts, then cross off anything they would not need.

Kitty's balances show every expense twiceStep 1 of 4
  1. Files

    balances.py, which builds the balances, plus the table layouts for expenses and payments. Not the page templates or the stylesheet.

That last line narrows the search from "anywhere" to "the query", which is exactly what a skilled stranger would want to know.

Drills

Answer fast — trust the rule.

quick drill

In a new conversation, the assistant stores amounts as floats, although you chose whole paise last week. What is the most likely reason?

quick drill

Which is the most useful context when asking about a crash?

quick drill

Why can pasting the whole project into the context hurt?

quick drill

Which of these should never go into a prompt?

Remember

  • Rule: give the assistant what this task needs, and nothing it doesn't.
  • Shortcut: picture a skilled stranger. Files, evidence, rules, attempts, then cross off the rest.
  • Trap: assuming the assistant remembers decisions that are no longer in its context.

Practice — level up

0/1 solved

Write your answer, then compare it with a rubric and a model answer.

ExplainPack the context

Kitty's settle-up form accepts a payment larger than what the flatmate owes. Write out the context you would give the assistant to fix this, and explain why you would leave out the rest of the project.