Re-checked 2026-11-23 (Curator Pass B)
@references, layered CLAUDE.md, resume/continue and plan mode still match the docs. Updated:/focus(a view toggle, not a scope),/compactsyntax, subagent model variable, hook wording. The 70%/85% context thresholds are model-dependent and were not re-verified.
The hands-on playbook for the principle in Context Engineering. The canonical page explains why the model’s attention is a finite, degrading budget (context rot, n² scaling, the long-horizon trio). This page is the how for one specific harness — Claude Code — distilled from @zodchiii’s 6-pattern, 13-step thread (The Context Engineering System the Claude Code Team Runs).
The thesis in one line: context isn’t something Claude manages for you — it’s something you engineer. A long session loses the 5% that matters by hour two; the fix is controlling what enters the session, not a bigger model.
Verify the commands
The thread frames this as a system “the Claude Code team uses internally.” Treat that as a hook. The durable, real pieces are layered CLAUDE.md,
@-file references,/compactwith instructions,--resume/--continue, plan mode (Shift+Tab), hooks, and subagents. A few commands as written (/focus,/stats, aclaude-require-plan-modehelper) may not exist exactly — checkcode.claude.com/docsbefore relying on them. The patterns hold regardless of whether a specific slash command does.
The six patterns
1. Layered CLAUDE.md — three files, stacked
Not one CLAUDE.md but three, each scoped to a different concern, all read on every prompt without re-uploading through your context window:
| Layer | Path | Owns |
|---|---|---|
| Personal | ~/.claude/CLAUDE.md | your cross-project preferences (style, push-back rules, OS/shell) |
| Project | repo-root CLAUDE.md (<100 lines) | stack, conventions, don’t-touch list, defaults |
| Module | src/auth/CLAUDE.md etc. | rules that change per folder; “files to read first” |
2. Surgical file references — @ over prose
@-references load exactly the named files. Prose (“the auth code and the session helper”) forces Claude to search, read 4–5 candidates, and guess wrong half the time. (Note: /focus in current Claude Code is only a view toggle; it does not limit which folders Claude reads. Scope with @ references and module CLAUDE.md files instead.) This is the operational form of just-in-time retrieval: pull the right tokens in, keep the wrong ones out.
3. Compact-and-continue — survive the limit
- Watch usage; past ~70% you’re in the danger zone, past ~85% early messages start dropping silently.
/compact focus on <what must survive>(e.g./compact focus on the failing test and the chosen approach) — summarize the conversation while protecting the task plan, key decisions, and load-bearing outputs (a failing test, a chosen approach).claude --resume [session-id]/claude --continuecarry the compacted state across days.
This is the Claude Code instantiation of the compaction lever in Context Window Management Strategies — but note that page’s warning: auto-compaction launders mistakes into assertions and defeats observability. The preserve: instruction is how you keep compaction honest, telling it what must survive rather than trusting a generic summary.
4. Plan-first reading — read before write
The biggest context leak is editing before understanding. Plan mode (Shift+Tab) makes Claude read-only: it lists every file it would touch and shows proposed changes before anything runs. Saves the “read 8, edit 3 wrong, revert, re-read” thrash. A PreToolUse hook can deny or ask before edits to sensitive paths (an if condition such as Edit(src/auth/**)) (Edit(src/auth/**)|Edit(migrations/**)) so it can’t be bypassed — a mechanical guardrail in the spirit of Golden Principles and Garbage Collection.
5. Subagent context isolation — push noise into a child window
Each subagent runs in its own context, so the parent never sees the noise. Three moves:
- Minimal tool surface — a
code-reviewergetsRead, Grep, Globonly; less surface, less context spent on irrelevant tool descriptions (Agent Tools - Design Principles). - Pass only the file refs it needs — not “review the recent changes” but the exact
@paths. - Cheaper models per agent — Sonnet for review/test, Haiku for docs/lints, Opus only for architecture/security (Model Tier Routing);
CLAUDE_CODE_SUBAGENT_MODELsets the subagent model, but the built-in Explore and Plan agents ignore it unless you also setCLAUDE_CODE_SUBAGENT_MODEL_FORCE=1.
This is the single-machine version of the sub-agent leg of the long-horizon trio and the orchestrator-worker split in Multi-Agent Research System - Production Lessons.
6. The 30-minute starter
10 min root CLAUDE.md → 5 min module CLAUDE.md (2–3 hottest modules) → 5 min personal CLAUDE.md → 5 min one skill in .claude/skills/ → 5 min plan-mode muscle memory. Claimed payoff: 50–70% less context for the same work, reflexive by session 5.
How this fits the vault
- Canonical theory: Context Engineering (Anthropic) — attention budget, context rot, the long-horizon trio. This page operationalizes it.
- The harness lever it lives in: Context Window Management Strategies — compaction is one of six ways a harness handles transcript growth; here it’s
/compact preserve:. - Adjacent Claude Code internals: Claude Code Internals (what claude-trace revealed), Slash Commands (this vault’s own commands).
- Shared machinery: Model Tier Routing (subagent model choice), Agent Tools - Design Principles (minimal tool surface), Self-Extending Agents / Skillify - Meta-Skill Pattern (the skill in step 4).
Practical note for Quang
You already run the personal + (sometimes) project CLAUDE.md layers and lean on plan mode. The two highest-leverage additions from this thread: module-level CLAUDE.md with a “files to read first” list in your most-edited areas, and
/compact preserve:with an explicit keep-list on any session that’s about to cross the danger zone — that’s the move that stops a long ingest or refactor from silently losing its plan.
Related
- Context Engineering — the canonical theory this playbook applies
- Context Window Management Strategies — the six transcript-growth levers; the compaction caveat
- Claude Code Automation Stack — the automation companion (same Claude Code surface, different axis)
- Model Tier Routing — choosing subagent models
- Claude Code Internals — what’s actually inside Claude Code