Production systems

Context engineering for Claude: budget the window like memory

Context engineering is choosing what Claude sees, in what order, and what is cached. It is the discipline behind quality and spend.

Context engineering is the work of assembling what Claude sees on each turn: instructions, tools, retrieval, history, and the user. Prompt wording is a subset. Most production failures we inherit are context failures: too much, in the wrong order, uncached, uncited.

Treat the window like a memory budget, not a junk drawer.

A working budget

  • Policy and tools first, stable, cached. See prompt caching.
  • Then the resolved entity and a few chunks. See retrieval.
  • Then the current user turn.
  • History last, summarised or truncated, never infinite.

If a token cannot change the decision, it should not be in the prompt.

Order is a product decision

Putting untrusted retrieval above the policy is how injection wins. Putting a 40-page dump above the user question is how the model answers a different question. Read prompt injection defense if writes are on the table.

Test context like code

Ablate chunks. If removing a section does not change eval scores, delete it. If adding a section drops scores, it is noise. Context is not "more documents." Context is the minimum that makes the next action correct.

This is one of the six disciplines on our expertise page because it shows up in every live system, not because it is a trend word.

Related notes