debloat
Skill1 starsChanged 13 days agoMITView on GitHub
Measure and trim your AI agent's always-load context - the instruction, rule, and state files it reads on every session start. Works with Claude Code, Codex, and Cursor. Use when the user says 'debloat', '/debloat', 'context bloat', 'how heavy is my context', 'trim startup context', 'context weight', or 'my startup is bloated'. Environment hygiene, not a gate: it measures and suggests; you choose what to trim.
6 other projects use a version of this.
Adopted by
Most recently taken up by
- ShlomiPorush/agent-skillstheir own version, first seen Nov 29, 2026
- cofin/flowtheir own version, first seen Nov 28, 2026
- changeroa/iyen-skillstheir own version, first seen Nov 22, 2026
- ontology-of-everything/handy-skillstheir own version, first seen Nov 15, 2026
- LilMGenius/paperthintheir own version, first seen Nov 15, 2026
- agentmemoir/skillstheir own version, first seen Nov 1, 2026
Other versions6 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 6
- LilMGenius/paperthin★ 1.5ksame name
- cofin/flow★ 19same name
- changeroa/iyen-skills★ 14same name
- agentmemoir/skills★ 3same name
- ontology-of-everything/handy-skills★ 2same name
- ShlomiPorush/agent-skills★ 2same name
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.
The file
We split this skill into the rules it gives an agent
6 rules. 0 are common, 3 are distinctive, and 3 are very specific to this project.
0
Common
Most of the 6 edited versions we read keep these.
3
Distinctive
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 19
Run them as node <skill-dir>/<script>, where <skill-dir> is the directory this file is in (.claude/skills/debloat, .agents/skills/debloat, …
- Distinctive: line 37
Not measurable from files: the agent's own system prompt, tool definitions, user rules stored in editor settings, and Claude Code auto …
- Very specific: line 91
If a file's real field points somewhere else, plan against that path.
- Very specific: line 120
Never delete data - extract accreted history to a *-history file and leave a pointer.
- Distinctive: line 121
Never trim immutable/append-only records, transaction data, audit trails, or anything whose retention rules are unclear.
- Distinctive: line 123
Never apply a trim the user has not seen as a diff and approved.
“Common” is measured: kept by at least 6 in 10 of the 6 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
/debloat - context hygiene for the always-load surface
Deterministically measures what your agent loads on EVERY session start (its instruction files, rules, and any always-read state files) and, on demand, runs a trim pass you drive. Pure arithmetic, no LLM judgment, so the number cannot be rationalized away. Environment hygiene, not a gate: it never blocks a session and never forces a trim. You choose what (if anything) to move.
Two scripts live in this skill's directory, next to this SKILL.md:
context-hygiene.mjsmeasures. Modes:--fyi(one line),--json(drives the trim picker), default (full report). Read-only, always exits 0.trim-context.mjsmoves line ranges into a history file: preview first, then a verified apply.
Run them as node <skill-dir>/<script>, where <skill-dir> is the directory this file is in
(.claude/skills/debloat, .agents/skills/debloat, or wherever it was installed). Do not assume
one agent's path.
What gets measured
With no config, the surface is discovered for the agent you name with --agent:
| Agent | Files counted |
claude | Managed, user (~/.claude/CLAUDE.md) and project CLAUDE.md, .claude/CLAUDE.md and CLAUDE.local.md in the root and every parent directory; .claude/rules/**/*.md without a paths: key; files pulled in by @path imports. |
codex | AGENTS.override.md or AGENTS.md in ~/.codex (or $CODEX_HOME), then one file per directory from the git root down to the root, including configured fallback names. |
cursor | .cursorrules, .cursor/rules/**/*.mdc with alwaysApply: true, and AGENTS.md / CLAUDE.md in the root. |
Pass --agent for the agent you are running as. Without it, all three are measured and the total
is their union. A file reached through several symlinks is counted once. Rules that load only for
matching paths are left out because they are not always-load.
Not measurable from files: the agent's own system prompt, tool definitions, user rules stored in editor settings, and Claude Code auto memory.
Configure the surface (.debloat.json)
Optional. Put a .debloat.json in the project root:
{
"agents": ["claude"],
"surface": ["docs/always-loaded-state.md"],
"discover": true,
"thresholds": { "watch": 8000, "heavy": 16000 },
"perFileSoft": { "*": 4000, "CLAUDE.md": 6000 }
}surface lists extra always-loaded files (state files a startup hook reads, for example). A
config with surface and no discover measures exactly those files and nothing else. CLI:
--include <path> (repeatable), --root <dir>, --config <path>, --no-discover.
Two modes
1. Startup FYI (one line, ignorable - good for a session-start hook)
node <skill-dir>/context-hygiene.mjs --fyi --agent claudeEmits ONE line, e.g. context: ~9.3k tok always-load (watch) | heavy: CLAUDE.md 5210t - /debloat to trim.
Surface it and move on. It is FYI, not an action item. Weight labels: light (< watch) /
watch (>= watch, or a heavy file present) / heavy (>= heavy).
2. On-demand /debloat (interactive trim pass)
- Measure -
node <skill-dir>/context-hygiene.mjs --json --agent <agent>. Parsetotal_tok,total_chars,total_bytes,weight,files[](per-file weight,aliases,real),targets[](heavy files),missing[]. - Show the weight + the heaviest files + the suggested targets. If
weight === 'light'and no targets, report "light, nothing to trim" and stop. - Ask which target(s) to trim (never trim without an explicit choice).
Plan each chosen target. Read the file and identify the accreted HISTORY (dated log prose, superseded notes, event history) versus the current live state. Write the line ranges that hold history to
.debloat/trim-plan.json(1-based, inclusive):{ "source": "CLAUDE.md", "history": "CLAUDE-history.md", "pointer": "Older notes: see CLAUDE-history.md.", "ranges": [{ "start": 42, "end": 78 }, { "start": 120, "end": 131 }] }If a file's
realfield points somewhere else, plan against that path. A source that resolves outside the project root is refused: trim it from its own project.- Preview -
node <skill-dir>/trim-context.mjs --plan .debloat/trim-plan.json --dry-run. This writes nothing. Show the user the diff it prints and ask for approval. Keep thereview tokenfrom the last line. Apply, only after approval:
node <skill-dir>/trim-context.mjs --plan .debloat/trim-plan.json --apply --review-token <token>The token is bound to the plan and to the exact content that was previewed. If the command refuses because something changed, run the dry run again and show the new diff. Do not work around a refusal by editing the files yourself.
- Re-measure with
--jsonand report the before/aftertotal_tokdrop, the backup directory, and that the apply reportedverified.
What apply does: checks the token, backs up source and history under .debloat/backups/, appends
the ranges to the history file inside marked blocks carrying their SHA-256, replaces them in the
source with the pointer, writes both files atomically, re-reads them and compares hashes, and
restores both if anything does not match.
JSON state files are refused by the trim script (moving lines would break them). Trim those by
hand with the same discipline: move history to a *-history file, leave a pointer, then validate
(node -e "JSON.parse(require('fs').readFileSync('<path>','utf8'))").
Rules
- Environment hygiene, never a gate. Non-blocking. You select; nothing is forced.
- Never delete data - extract accreted history to a
*-historyfile and leave a pointer. - Never trim immutable/append-only records, transaction data, audit trails, or anything whose retention rules are unclear. Surface them, do not trim.
- Never apply a trim the user has not seen as a diff and approved.
- The token count is
chars/4(ESTIMATE~), a deterministic estimate, not an exact tokenizer count. Say "about" when you quote it.
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.

