Measure and cut Claude Code's starting context without breaking which skills fire. Scripts, A/B harness and a plugin.
context-diet
以下摘录自该仓库的 README(片段) · 在 GitHub 读完整 README →
Measure and cut what Claude Code loads before your first prompt (built-in tool schemas, the skills listing, CLAUDE.md, MCP), then prove with an A/B that your skills still get picked.
S-T: every session pays a fixed "entry fee" of tokens before you type anything. This repo tells you what's in that fee, helps you shrink it, and checks you didn't break anything doing it. Example: hiding 20 rarely used skill descriptions saves ~2k tokens on every call; the A/B tells you if Claude still finds those skills when you need them.
What's here
| Folder | What it does |
|---|---|
| measure/ | start_tokens.py (real start per session from your logs, split by block), probe-interactive.sh (cost of one built-in tool in a real interactive session), ablate.sh (headless component ablation) |
| audit/ | skill-usage.py (how often each skill really fired), audit.py (suggested skillOverrides), skill-lint.py (600-char description cap), mcp-usage.py (calls per MCP server, suggests deniedMcpServers), size-ratchet.py (fails when CLAUDE.md, agents or a skill listing grow past a pinned baseline), memory-lint.py (lint CLAUDE.md and its @ imports for dangling pointers, import cycles and duplicated rules) |
| ab/ | Skill-trigger A/B: mine prompts from logs, build arms, synthesize missing positives, run, report recall / wrong pick / false fires / McNemar. Rename arms included |
| tools/ | publish-artifact.sh: publish an Artifact page from a throwaway side session so the Artifact tool can stay off |
| agents/lean.md | A low-context subagent (shell + file tools only) for fan-out work |
| skills/ | Plugin skills that point Claude at the above |
| docs/ | RUNBOOK.md (the full method) and CONTEXT-DIET.md |
Install as a plugin
Or just clone and run the scripts. Python 3.9+, no dependencies; tmux for the interactive probes.
Quick start
Scope and config: scripts read $CLAUDE_CONFIG_DIR if set, else ~/.claude. Session readers (start_tokens.py, skill-usage.py, mcp-usage.py, ab/mine.py) default to the current directory's project; use --project PATH for another one or --all-projects for all. If the project has no sessions they exit 2 rather than reading everything. Anything that calls a model (ablate.sh, ab/filter.py, ab/synth.py, ab/run.py, ab/quick_ab.py) requires --model with an explicit model id.
Then follow docs/RUNBOOK.md: change one lever, A/B it (ab/README.md), keep it only if recall holds.
Findings that shaped it
- claude -p starts ~21k lower than an interactive session. Measure real starts (entrypoint: cli).