Skip to content
Daniel Östling.

Six rules for context engineering

The whiteboard version — six rules for laying out a context window, each with a number measured on this site's chat.

llmcontext-engineeringprompts

Everything I learned building this site’s chat compresses into six rules. Each one has a number behind it, measured on the system running in the corner of this page.

#RuleOne lineMeasured
1Separate reference from rulesReference gets searched when relevant. Rules must be obeyed every time. Sort every token into one of the two buckets before placing it.A 5,600-token corpus and a one-line length rule needed opposite positions
2Position is priorityIdentity at the top, bulk in the middle, must-win behavior at the end. The middle is a black hole.Same rule moved from top to end: 230 words down to 75
3Move before rewritingWhen the model disobeys, relocate the instruction before strengthening its wording.Rewriting got me to ~110 words. Moving got me to 75
4Budget tokens like moneyEvery token dilutes attention on every other token. Not “does it fit” — “does it earn its place”.Instruction drift was measurable behind just 5,600 tokens
5Stable prefix, volatile suffixByte-stable content first and cached. Everything that changes goes after the cache marker.Warm questions cost 0.15 cents against 0.8 cold, and tuning the suffix is free
6Measure behaviors separatelyThey fail one at a time. One assertion each, run on every change.The same prompt scored 10/10 on grounding while running 3× over length

The full system these six rules run on — corpus, citations, caching and the ten-question eval suite — is written up in the chat on this site, explained.

If you keep one sentence: the model gives you a fixed attention budget — lay it out like a designer laying out a page, not like a lawyer adding clauses.

Back to writing