context-management
Skill4 starsChanged 7 months agoMITView on GitHub
Context budget awareness, when to compact, when to clear, subagent offloading
14 other projects use a version of this, 1 of them edited.
Adopted by
Most recently taken up by
- REPOZY/superpowers-optimizedtheir own version, first seen Nov 8, 2026
- AnthonyPoschen/agent-skillstheir own version, first seen Oct 26, 2026
- timfewi/unix-agent-skillstheir own version, first seen Oct 17, 2026
- opensite-ai/opensite-skillstheir own version, first seen Oct 13, 2026
- krema/agent-skillstheir own version, first seen Oct 13, 2026
- ttttmr/pi-contexttheir own version, first seen Oct 9, 2026
Other versions14 projects use a version of this.
Word for word · 0
None found.
Edited · 1
- sefaertunc/anthropic-watch★ 1100% same
Wrote their own version · 13
- ttttmr/pi-context★ 304same name
- kangarooking/system-prompt-skills★ 178same name
- REPOZY/superpowers-optimized★ 146same name
- opensite-ai/opensite-skills★ 15same name
- AnthonyPoschen/agent-skills★ 2same name
- bjornjee/skills★ 2same name
- stateofthehart/claude-code-config★ 2same name
- timfewi/unix-agent-skills★ 2same name
- Bridev04/clauderail★ 0same name
- darrenCWJ/agent-skills-scaffold★ 0same name
3 more not listed
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository18 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- agent-routingSkill
- backend-conventionsSkill
- claude-md-maintenanceSkill
- coding-principlesSkill
- coordinator-modeSkill
- frontend-design-systemSkill
- git-conventionsSkill
- memory-architectureSkill
- planning-with-filesSkill
- project-patternsSkill
- prompt-engineeringSkill
- review-and-handoffSkill
- security-checklistSkill
- subagent-usageSkill
- testingSkill
- verificationSkill
The file
We split this skill into the rules it gives an agent
10 rules. 0 are common, 10 are distinctive, and 0 are very specific to this project.
0
Common
Most of the 13 edited versions we read keep these.
10
Distinctive
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 29
Use when: you're mid-task and need more room but want to keep working.
- Distinctive: line 33
After compaction, always re-orient:
- Distinctive: line 39
Use when: you're starting a genuinely new task with no relationship to the current one.
- Distinctive: line 44
Use when: a side task would pollute your main context (research, testing, file generation).
- Distinctive: line 76
When a new Claude Code session opens, a hook automatically injects:
- Distinctive: line 82
Use /start for additional context (handoff files, agent routing).
- Distinctive: line 98
If the session summary is missing or stale, /start still reads PROGRESS.md and handoff files as fallback.
- Distinctive: line 144
After compaction, only 5 files are restored at 5k tokens each.
- Distinctive: line 171
Don't compact right before a complex merge or refactor.
- Distinctive: line 173
After /compact, always verify your understanding before making changes.
“Common” is measured: kept by at least 6 in 10 of the 13 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Context Management
Note: The bash examples below are reference snippets. If you enable
disableSkillShellExecutionin Claude Code settings (v2.1.101+), any inline shell execution from skills is blocked. These fenced examples are safe to read; copy-paste them into your terminal to run.
The 70% Rule
Context windows are finite. When you estimate you've used roughly 70% of available context, it's time to act. Don't wait until you're out of room — you lose the ability to reason well before you hit the hard limit.
Signs you're running low:
- You've read many large files in this session
- You've had a long back-and-forth conversation
- You're working on a second or third major task
- Responses are getting slower or less coherent
Three Tools, Different Jobs
/compact — Compress and continue
Use when: you're mid-task and need more room but want to keep working. What it does: summarizes conversation history, freeing context. Pair with: PostCompact hook that re-reads CLAUDE.md and PROGRESS.md automatically.
After compaction, always re-orient:
- What task am I working on?
- What branch am I on?
- What did I just do?
/clear — Fresh start
Use when: you're starting a genuinely new task with no relationship to the current one. What it does: wipes conversation entirely. Caution: you lose ALL context. Make sure PROGRESS.md is updated first.
Subagents — Offload without losing context
Use when: a side task would pollute your main context (research, testing, file generation). What it does: spawns a separate context that does work and returns results. Your main context stays clean.
Decision Matrix
| Situation | Action |
| ~70% context, mid-task | /compact |
| Task complete, starting unrelated work | /clear |
| Need to research something tangential | Subagent |
| Need to run tests while continuing design | Subagent |
| Context feels sluggish, responses degrading | /compact |
| Long debugging session, found the fix | /compact, then implement |
PostCompact Hook
The workflow installs a PostCompact hook that runs:
cat CLAUDE.md && cat docs/spec/PROGRESS.md 2>/dev/null || trueOn Windows, this command runs in Git Bash (installed with Git for Windows).
This ensures you never lose your bearings after compaction. The hook fires automatically — you don't need to re-read these files manually.
Session Persistence
The workflow automatically maintains session continuity:
SessionStart Hook (automatic)
When a new Claude Code session opens, a hook automatically injects:
- CLAUDE.md — project conventions and rules
- PROGRESS.md — current project state
- The most recent session summary from
.claude/sessions/
You don't need to manually re-read these. The hook handles it. Use /start for additional context (handoff files, agent routing).
Session Summaries
Session summaries are written to .claude/sessions/ by:
/commit-push-pr— writes a summary before committing (completed work)/end— writes a summary before the handoff commit (in-progress work)
These are local files (gitignored) that bridge the gap between sessions. They're automatically picked up by the next session's SessionStart hook.
The Continuity Chain
Session 1: work → /commit-push-pr → writes session summary → push
Session 2: SessionStart hook → reads summary → knows what happened → /start for extrasIf the session summary is missing or stale, /start still reads PROGRESS.md and handoff files as fallback. The system degrades gracefully.
Hook Profiles
Control which hooks fire via the WORCLAUDE_HOOK_PROFILE environment variable:
| Profile | Hooks Active | Use When |
minimal | SessionStart, PostCompact only | Exploring, learning, minimal overhead |
standard | All hooks (default) | Normal development |
strict | All hooks + TypeScript checking | Pre-release, team CI, maximum safety |
Set in your shell:
export WORCLAUDE_HOOK_PROFILE=minimal # lightweight
export WORCLAUDE_HOOK_PROFILE=standard # default (same as unset)
export WORCLAUDE_HOOK_PROFILE=strict # maximum enforcementOr per-session:
WORCLAUDE_HOOK_PROFILE=strict claudeThe default is standard if the variable is not set. You don't need to do
anything for normal development — the default just works.
Token Budgets (Reference)
Approximate values from Claude Code v2.1.88 source (March 2026). These may change between releases.
| Resource | Budget |
| Context window (default) | 200,000 tokens |
| Context window (Opus 4.6 / Sonnet 4.6 with 1M) | 1,000,000 tokens |
| Max output tokens (Sonnet 4.6) | 32,000 default, 128,000 upper limit |
| Max output tokens (Opus 4.6) | 64,000 default, 128,000 upper limit |
| Tool presence overhead | ~500 tokens (added when any tools are enabled) |
| Post-compact file restore | 5 files max, 50,000 token budget, 5,000 per file |
| Post-compact skills restore | 25,000 token budget, 5,000 per skill |
| Compact summary output | 20,000 tokens max |
| CLAUDE.md total budget | ~40,000 characters across all loaded instruction files |
| MEMORY.md (native, ~/.claude/) | 200 lines / 25,000 bytes |
Practical takeaways:
- After compaction, only 5 files are restored at 5k tokens each. Structure your work so the most important files are recently read.
- Skills over 5k tokens get truncated after compaction. Keep skills focused.
- The 70% rule still applies — these numbers help you estimate when you'll hit it.
Context Budget Tiers
Monitor your context usage and adjust behavior accordingly:
| Tier | Context Free | Behavior |
| PEAK | >75% | Normal operation — read files freely, keep full context |
| GOOD | 50-75% | Be selective about file reads — summarize large files |
| DEGRADING | 25-50% | Summarize before reading new files, consider /compact |
| CRITICAL | <25% | Save state immediately, /compact, reload only essentials |
Heuristics (you cannot measure exact tokens):
- Many large file reads in this session = likely DEGRADING
- Long conversation with multiple tasks = likely DEGRADING
- Just started or just compacted = likely PEAK
Gotchas
- Compacting doesn't free as much context as you think. If you've read 20 large files, compaction helps but won't get you back to fresh. Consider /clear if the task is done.
- Subagents don't share your conversation context. They start fresh. Give them explicit instructions and file paths — don't assume they know what you know.
- Don't compact right before a complex merge or refactor. You'll lose the nuanced understanding of the changes you've been building up.
- After /compact, always verify your understanding before making changes. The summary may have lost important details.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

