← Wiki

Context engineering — context as code

2026-04-07 concept contextagentsclaude-mdprogressive-disclosureharness

One of three harness engineering components. The idea: agent context is not chat history — it’s a continuously improved knowledge base in the repository.

Architecture:

CLAUDE.md           ← table of contents (~100 lines, links deeper)
ARCHITECTURE.md     ← domain and layer map
docs/
├── design-docs/    ← design decisions (with verification status)
├── exec-plans/     ← active and completed plans
├── product-specs/
├── references/     ← llms.txt for dependencies
└── QUALITY_SCORE.md

Key OpenAI insight: one big CLAUDE.md is an anti-pattern. Pollutes context, rots instantly, impossible to validate mechanically. Instead: table of contents with links to deeper docs. Progressive disclosure — agent starts with a small stable entry point and knows where to look next.

Dynamic context goes beyond docs: observability (logs, metrics, traces), browser via Chrome DevTools Protocol, screenshots, DOM snapshots. The agent can literally see what the user sees.

Tools for legibility (OpenAI): app per worktree (isolated instance per change), local observability stack (ephemeral per worktree), custom linters with remediation instructions, Ralph Wiggum Loop (agent reviews its own changes).

What others found since (Oct 2026)

What it means for our own injections (Nov 2026)

What the paper covers is a coding agent’s tool outputs; ours are injected blocks. The mechanism carries over, the numbers do not. We have not measured our own cache behaviour, so what follows is the reading, not a result.

What the paper implies for us. The order of the prompt matters more than its size. Put the stable material first and the daily or per-prompt material last; a brief that changes every morning is acceptable only if nothing large sits behind it. Do not “clean up” by deleting old hint blocks or tool outputs mid-session: the paper’s masking result is exactly that, and it lost at a tenth-price cache. Our compaction and the pipeline in claude-code-anatomy are a different mechanism (whole-history rewrite), so the paper does not rate them.

Measure, do not rewrite. Claude Code transcripts record usage per request. Count the three streams per session, split by whether the hook fired:

jq -s '[.[]|select(.type=="assistant" and (.isSidechain|not))|{id:.message.id,u:.message.usage}]
  |unique_by(.id)|map(.u) as $u
  |{req:($u|length),uncached:($u|map(.input_tokens)|add),
    cache_write:($u|map(.cache_creation_input_tokens//0)|add),
    cache_read:($u|map(.cache_read_input_tokens//0)|add),
    out:($u|map(.output_tokens)|add)}' ~/.claude/projects/<project>/<session>.jsonl

Then price it as uncached + 1.25 x cache_write + 0.1 x cache_read + 5 x output (the paper’s ratios for cache read and output; the 1.25 write multiplier is my assumption from API price lists, check it). Use solograph usage to pick the sessions where the hint was followed versus not, and compare cache_write per request. A hint is worth keeping if cache_write per request does not rise on the turn after it and the session’s total does not exceed that of comparable sessions without it. Run the comparison on at least a few dozen sessions per arm and note that sessions differ in length, so compare per request.

Connections

Sources

Related