/claude-code-expert:cc-context-budgetingfrom claude-code-expert
Manages Claude Code's context window with token arithmetic, /compact strategy, anchor preservation, progressive loading, and session analytics. Useful for long sessions approaching context limits.
Ships in claude-code-expert. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Every token in context is a cost you pay every turn. This skill is the discipline that keeps long sessions cheap and coherent.
Rough budget on a 200K-context model:
| Consumer | Typical | Budget |
|---|---|---|
| System prompt + CLAUDE.md | 3–8 K | ≤ 10 K |
| Skills frontmatter (all active) | 2–6 K | ≤ 8 K |
| MCP tool schemas (passive) | 5–25 K | ≤ 15 K |
| Hook definitions | <1 K | <1 K |
| Conversation history | variable | ~120 K |
| Working headroom | — | ≥ 20 K |
If passive context (everything before conversation history) exceeds 30 K, optimize.
| Tier | What | Size | Loaded |
|---|---|---|---|
| 1 — Frontmatter | name + description | ~50 tokens | always |
| 2 — Body | SKILL.md after frontmatter | ≤ 500 lines | on activation |
| 3 — References | references/*.md, MCP KB artifacts | unlimited | on demand |
Rule: if content doesn't change Claude's behavior every session, it belongs in tier 3.
/compact condenses conversation history when it's filling up. It does NOT touch system prompt, CLAUDE.md, or skills.
When to /compact:
When NOT to /compact:
/clear (nothing to compact).Anchor preservation: before /compact, save anything you'd lose to engram via mem_save. After compact, the post-compact-context-restoration hook re-loads memory rules and recent context.
| Command | What it does |
|---|---|
/compact | Summarize history, keep system prompt + CLAUDE.md |
/clear | Wipe everything including CLAUDE.md — fresh session |
Use /clear between unrelated tasks. Use /compact mid-task.
When a single subtask would consume too much context (e.g. scanning a huge codebase), delegate to a subagent. The agent gets a fresh window; you only see its report.
Agent({
description: "Inventory all API endpoints",
prompt: "Scan src/api/ recursively, list every route with method, auth requirement, and response schema. Report under 500 words."
})
Net: the scan consumes agent tokens; your session only pays for the 500-word summary.
Track cost patterns:
| Metric | Target |
|---|---|
| Passive context (pre-conversation) | ≤ 30 K |
| Cost per turn | ≤ $0.05 (Sonnet), ≤ $0.15 (Opus) |
| Tools loaded but never called per session | 0 (prune unused MCPs) |
| /compact frequency | every 20–30 exchanges on long sessions |
| Subagent delegation rate | ~1 per 5 substantive turns |
Session analytics isn't automatic — periodically review what's consuming tokens and trim.
| Need | Tool |
|---|---|
| Settings schema for compact config | cc_docs_settings_schema |
| Compact/budget troubleshooting | cc_docs_troubleshoot("context") |
| Model cost for budgeting | cc_docs_model_recommend(task, budget) |
What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub thelobbi/claude --plugin claude-code-expert21 skills in this plugin
/cc-agentic-patternsSelect and wire an agentic design pattern (reflection, prompt chaining, routing, parallelization, orchestrator-workers, evaluator-optimizer, ReAct, blackboard) into the 5-layer Claude Code stack. Use this skill whenever deciding how to structure a multi-step task, whether to spawn subagents, how to run parallel review, or when to use which pattern. Triggers on: "which pattern", "orchestrate", "parallel review", "self-review", "chain of thought", "eval-optimizer loop", "blackboard", "ReAct", "how to decompose this task"./cc-agent-teamsSelect and coordinate multi-agent teams (topology kits, role-based squads, lifecycle, worktree isolation). Use this skill whenever launching parallel agents, designing a review board, running a debug council, scheduling an orchestrator-workers team, configuring agent tool restrictions, or deciding between solo and team execution. Triggers on: "launch a team", "parallel agents", "review board", "debug council", "architect-implementer-reviewer", "swarm", "multi-agent", "subagents for X", "team topology", "agent lifecycle"./cc-auto-modeAuto mode permission handling — classifier-based approvals, PermissionDenied hook, defer permissionDecision, and autonomy profiles for hands-off Claude Code usageOther plugins' skills for the same job