Prompts, rules, and context
Curate the context
Give the model the smallest complete set of files, examples, requirements, and documentation needed for the task.
8 minute lesson
Too little context forces the model to guess. Too much unrelated context can hide the important details and consume the context window.
The goal is the smallest complete context: enough evidence to do the task, without a dump of everything you have.
Start from the decision the model must make
If the task is to fix a form validation bug, the model probably needs:
- the failing input and expected behavior
- the form component and validation function
- relevant tests
- the interface the code must preserve
- current documentation for any external API involved
It probably does not need the entire image folder, deployment history, or fifty unrelated components.
Let the agent inspect nearby code before you manually attach half the repository. Search and file-reading tools can discover imports, callers, tests, and conventions as the task develops.
Prefer primary and current context
The implementation is usually better evidence than a remembered description of it. Current official documentation is better than an old blog post when an API may have changed. A real error log is better than it does not work.
Include one representative example of the pattern you want to preserve. If five similar components exist, point to the best one instead of asking the model to infer a convention from all five.
Keep data separate from instructions
Files, web pages, issue descriptions, and tool results may contain text that looks like an instruction. Treat retrieved content as untrusted data unless it comes from an instruction source you control.
For example, a dependency’s README could contain malicious text telling an agent to read environment variables. Reading that file must not grant the file authority or new permissions.
Context can become stale
During a long task, files change and earlier observations become outdated. An agent should reread a file before editing if another process may have changed it. It should also use the latest test result rather than reasoning from an old failure.
Long conversations may compress or lose earlier detail. When starting a new phase, restate the current goal, decisions, and critical constraints. Do not assume the model remembers every turn equally.
A useful context checklist
Before acting, ask:
- What evidence defines the current behavior?
- Which contract must remain stable?
- What example shows the local convention?
- Which source is authoritative and current?
- What is missing that would force a guess?
- Which supplied content is untrusted?
Lesson completed