context-budget-discipline
Use when sessions run long, adding subagents, fetching large files, or planning context-heavy work. SELECT/WRITE/COMPRESS/ISOLATE discipline.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Use when sessions run long, adding subagents, fetching large files, or planning context-heavy work. SELECT/WRITE/COMPRESS/ISOLATE discipline.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Use before claiming done/fixed/passing — or before asserting something is absent: not installed, not available, no such function, couldn't find it. Default-FAIL runs both ways — every claim needs an evidence path. A negative claim must carry its search scope and observation date; state calibrated uncertainty when evidence is missing.
Use at start of work, after env changes (deps/branch/OS), or when something stops working. Runs init.sh health check; treats failures as blocking.
Use whenever working in a project. Establishes state/scope/verification discipline. Auto-loaded at session start. Complements superpowers.
Use in C/C++ projects for clang-format. Changed-lines-only; never reformat unchanged code mid-feature. .clang-format from root or LLVM baseline.
Use in C/C++ projects when reviewing changes or hunting bugs. Runs clang-tidy/cppcheck/IWYU. Needs compile_commands.json. Changed lines only.
Use in C/C++ projects for build configure/errors, compile_commands.json generation, or selecting CMake/Meson/Make/Bazel commands.
| name | context-budget-discipline |
| description | Use when sessions run long, adding subagents, fetching large files, or planning context-heavy work. SELECT/WRITE/COMPRESS/ISOLATE discipline. |
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 watermark fires (T1 "Context is filling" = flush now; T2 "Context is heavily filled" = wrap up via /session-end + fresh session) — 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 index