Keep large tool output from flooding an AI coding agent's context window.
Every file read, test run, log dump, and URL fetch an agent makes gets billed as input tokens on every turn that follows. Most of it is noise the model never reasons over. Context-sizing is a single instruction file that teaches the agent to filter at the tool call — measure before reading, query instead of dumping, and widen only when a narrow view misses.
No binary, no proxy, no server, no network. One markdown file.
Claude Code — drop it in either location:
# user-wide
D=~/.claude/skills/context-sizing && mkdir -p "$D" && for f in SKILL.md REFERENCE.md; do
curl -fsSL "https://raw.githubusercontent.com/rochitr/context-sizing/main/$f" -o "$D/$f"
done
# or, per project:
mkdir -p .claude/skills/context-sizing && cp SKILL.md REFERENCE.md .claude/skills/context-sizing/Any skills-compatible agent (Codex, Cursor, Windsurf, Cline, opencode):
npx skills add rochitr/context-sizingAnything else — it's plain markdown. Append the body of SKILL.md to
AGENTS.md, .cursorrules, a system prompt, or whatever rule file your agent
reads, and keep REFERENCE.md beside it. It has no dependencies on any host
feature.
| File | Loaded | Contents |
|---|---|---|
SKILL.md |
every turn | Six rules, a cheat sheet, thresholds — ~600 tokens |
REFERENCE.md |
on demand | Expanded recipes per payload type, worked example |
The split is deliberate: SKILL.md is re-billed on every turn, so it carries only
what has to be resident. REFERENCE.md costs nothing until the agent reads it,
which it does when it hits a payload shape the cheat sheet doesn't cover. Install
both — the reference is useless if it isn't sitting next to the skill.
Compressing an agent's context can be done two ways: intercept the traffic, or teach the agent to ask for less. Interception (a local proxy or tool-call hook) is automatic and enforced, but needs a running process, per-agent wiring, and a new trust boundary. Instruction is voluntary — the model has to comply — but it installs anywhere in seconds and can't break a request path.
Context-sizing is the second kind, deliberately. The tradeoff it accepts is enforcement; what it buys is that it works in any agent, today, as one file.
- Recovery is free. No handle store, no cache. The file is still on disk and the command still re-runs, so aggressive filtering is always reversible.
- Precision is never traded. The skill governs what gets fetched, never what gets preserved — exact errors, code, paths, and values stay verbatim.
- It stays short. The file loads into context every turn. A long skill about saving tokens would defeat itself, so it's kept near ~1k tokens.
- It knows when to stop. Over-probing (five greps to avoid one small read) costs more than it saves; the skill says so explicitly.
MIT