Prompt construction for production
Where each kind of content belongs, and why placement is a caching decision too.
4 min read · Lesson 5 of 12 in this domain
Where you put text in a prompt is not only a comprehension decision, it is a caching decision, and the two point the same way. Stable material — role, conventions, output expectations, few-shot examples — belongs early, because it forms a reusable cache prefix and because the model reads it as framing. Volatile material — the document, the user's question, an id — belongs after the last cache breakpoint, because anything before it that changes invalidates everything downstream. There is also a behavioural shift worth knowing: prompts written to bully older models into using a tool now overtrigger, and the fix is to soften the wording rather than pile on guardrails.
- The system prompt should hold stable material: role, conventions, output expectations. It then forms a reusable cache prefix.
- Put volatile per-request content — the document, the user question, identifiers — after the last cache breakpoint. Never interpolate a per-user id into the system prompt.
- Few-shot examples earn their tokens on genuinely ambiguous edge cases, unusual formats, and conveying the desired level of detail. More is not better — volume biases the model toward the shown cases.
- Examples are stable content and belong early, before the volatile question.
- Current models follow the system prompt closely. Wording written to overcome older models' reluctance (
CRITICAL: You MUST…,If in doubt, use X) now overtriggers. The fix is to soften the language, not to add guardrails.
Adding exceptions to an over-forceful instruction instead of dialling the instruction back.
Where does volatile per-request content belong?
Anything volatile early in the prefix invalidates everything after it.
'CRITICAL: You MUST use this tool' now overtriggers. Best fix?
Current models follow the system prompt closely; wording written for older models overtriggers.
Practise this domain with 20%%-weighted questions in the study app.
Open in study appSource: Claude Docs — Prompt caching · Independent study aid, not affiliated with or endorsed by Anthropic.