From harness-anchor
Manages Claude Code's context budget by selecting just-in-time, writing to disk, compressing old turns, and isolating subagents. Use for long sessions or heavy context work.
How this skill is triggered — by the user, by Claude, or both
Slash command
/harness-anchor:context-budget-disciplineThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Context is a finite resource. Every token competes for the model's attention. The "lost-in-the-middle" phenomenon is real — content buried in 50% of the window position is least attended.
Context is a finite resource. Every token competes for the model's attention. The "lost-in-the-middle" phenomenon is real — content buried in 50% of the window position is least attended.
This skill applies four operations to keep the budget sane.
SELECT load context just-in-time, not all-at-once
WRITE persist to disk; let the filesystem remember, not chat
COMPRESS summarize older turns when window fills
ISOLATE delegate so child work doesn't pollute parent context
Default behaviour: don't preemptively load files. Wait until they're needed.
Anything reusable across turns should live on disk:
feature_list.jsonprogress.md or docs/decisions/session-handoff.mdAnti-pattern: re-explaining the same plan/decision in every reply.
When context usage > 70% of model window, mid-session compaction can help. But per Anthropic Nov 2025:
"Compaction preserves continuity, but doesn't give the agent a clean slate. Context anxiety can still persist."
Flush before you compress. Before compaction/reset — or when the PostToolUse context-fill
sentinel fires — write chat-only durable memory to disk first: golden-rule stubs
(capturing-golden-rules), feature status, a milestone progress.md entry. After a compaction,
do NOT backfill memory from the summary: reconstruct from on-disk evidence (git diff, test
output, progress.md) and state uncertainty where evidence is missing.
If compaction isn't enough → use /session-end to write a rich handoff, then suggest the user start a fresh context (context reset > compaction for long runs).
Subagents (/verify, cpp-build-doctor, etc.) run in fresh context. They:
If you delegate a noisy task, ask for a SUMMARY back, not a transcript.
| Tier | Budget | Source |
|---|---|---|
| Tier 1 (always loaded) | ~3000 tokens cap; measured at v0.10.0: generic ≈1160 t, C/C++ ≈1580 t | SessionStart hook injection (hard-capped 12000 chars, meta-skill injected slimmed; ${CLAUDE_PLUGIN_ROOT}/scripts/measure-context.sh re-measures both baselines) |
| System prompt + tools | Model-defined | Outside your control |
| Working context | Most of remaining window | Your edits + reads accumulate here |
Hot state files carry fixed budgets. The SessionStart banner warns (warn-only) when one is
exceeded; /session-end offers deterministic archival via state-archive.mjs.
| File | Hot window | Sentinel |
|---|---|---|
progress.md | newest 20 sections | 64KB |
feature_list.json | live features + 10 newest pass | 32KB |
golden-rules.md | prune — never archived | 8KB |
AGENTS.md | keep it a map (~80 lines) | 8KB |
session-handoff.md | overwritten each session | 4KB |
Archives (progress-archive.md, feature_archive.json) are grep-only — never load whole.
When budget pressure rises:
/session-end if features are in flight.head -50, grep -A 5, line range in Read tool — over reading whole files.You can roughly estimate context use by:
When the user asks "how much room do we have?", be honest about the estimate.
For specific patterns (e.g., compaction algorithms, attention windowing, RAG indexing strategies) — invoke the docs-lookup skill. Pattern names evolve fast in this area; don't rely on memory.
Typical entry query: context engineering 2026 or <specific technique> llm.
using-harness-anchor — Tier 1 injection budget referencefeature-state-keeper — what to write to diskproject-indexing — TOC as compressed file indexnpx claudepluginhub redtropig/harness-anchor --plugin harness-anchorManages AI context via four operations: Write (persist info), Select (retrieve relevant info), Compress (reduce tokens), Isolate (partition context). Keeps sessions sharp and efficient.
Manages Claude Code context windows with token arithmetic, anchor budget math, compact strategies, progressive loading, and large codebase partitioning.
Manages agent context size to prevent accuracy collapse during long sessions or large file loads. Use when the agent forgets earlier steps or hallucinates.