Context placement and retrieval
How position can affect retrieval in long contexts and how to keep important instructions salient.
Position can affect retrieval in a long context window, but there are no universal “smart” and “dumb” regions. The Lost in the Middle research demonstrates primacy and recency effects on retrieval tasks; it does not show that a model's general reasoning ability switches by position. A useful, limited heuristic is:
- The start can anchor the task: system behavior, project rules, and initial instructions shape how the task is framed.
- Middle details can be harder to retrieve: long tool dumps, old turns, or rarely referenced files may receive less attention in retrieval-style tasks.
- Recent context is often salient: the latest message, fresh tool results, and recent decisions appear immediately before the answer.
This is a heuristic, not a law. Model family, fine-tuning, and prompt shape all matter. Treat it as a planning tool: if something must not be forgotten, do not bury it only in the middle of a 50-page paste.
What to put where (practically)
| Priority | Placement strategy |
|---|---|
| Non-negotiable rules | CLAUDE.md / rules (loaded early) plus short reminders in the latest user message when stakes are high |
| Working set | Keep attachments and tool output relevant; do not send stale @ files when you change tasks |
| Reference material | Large specs: prefer a file in the repo and @ the section you need, instead of pasting the whole doc into chat |
| One-off constraints | Repeat critical constraints in the final line of your prompt (“Do not push; read-only this turn”) |
Symptoms of retrieval pressure
- The model ignores a requirement you stated many turns ago but never repeated.
- It contradicts an earlier decision that only lives in middle chat history.
- It re-reads files you already analyzed because the summary never made it to a durable place.
Mitigations: move durable facts to CLAUDE.md, a plan file, or /compact with explicit “retain X”; repeat one-line critical constraints when risk is high.
Example prompt
Constraints for this turn (repeat in your plan before coding): no schema migrations, no new dependencies, backend only.
Now implement the validation change we discussed; if anything conflicts with those three lines, stop and ask.