trim-context
Skill4 starsChanged 5 days agoMITView on GitHub
Audit and reduce always-on token costs in the project's instruction files. Invoke manually after completing any plan.
1 other project uses a version of this.
Adopted by
Most recently taken up by
- daryaKuto/claude-skillstheir own version, first seen Nov 15, 2026
Other versions1 project uses a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 1
- daryaKuto/claude-skills★ 0same 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.
In this repository16 other files it gives its agents.
- benchmarkSkill
- bugfixSkill
- designSkill
- deterministic-pr-gatesSkill
- featureSkill
- gatesSkill
- parallel-reviewSkill
- pipeline-reviewSkill
- planSkill
- pr-followupSkill
- releaseSkill
- reviewSkill
- specSkill
- statusSkill
- sync-workflowSkill
- testSkill
The file
We split this skill into the rules it gives an agent
10 rules. About 0 are common, 7 are distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈7
Distinctive · estimate
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
- Distinctive: line 19
Read AGENTS.md (or CLAUDE.md on the pre-AGENTS.md convention) and flag any content that violates these rules:
- Distinctive: line 29
If AGENTS.md exceeds 50 lines or contains removable content, edit it in place and report what was cut.
- Distinctive: line 32
Read the index and each linked file.
- Distinctive: line 37
Remove stale files and their index entries.
- Very specific: line 40
Read .claude/settings.json.
- Distinctive: line 48
Read each skill file. Flag content that is:
- Very specific: line 55
If headroom is installed (command -v headroom), run:
- Distinctive: line 70
Do not remove content that is genuinely useful and not available elsewhere
- Distinctive: line 71
Do not add new content — this is a reduction pass only
- Very specific: line 72
Commit any changes to AGENTS.md/CLAUDE.md and settings.json with message chore: trim context after <plan-name>
≈ “Common” is an estimate: at least 1 in 5 of the 364,980 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Trim Context Agent
Trigger
Invoked manually after completing any plan: /trim-context.
Process
Audit and reduce always-on token costs.
What to audit
1. AGENTS.md (target: ≤50 lines)
Read AGENTS.md (or CLAUDE.md on the pre-AGENTS.md convention) and flag any content that violates these rules:
| Keep | Remove |
| Build commands + simulator name | Anything already in .claude/skills/ |
| Layer rules (enforced in code decisions) | Model/service tables (readable from source) |
| Non-obvious domain constraints | Navigation structure (visible in source) |
| Test framework (import Testing, not XCTest) | ASCII diagrams |
| File inclusion note (PBXFileSystemSynchronizedRootGroup) | Verbose descriptions of obvious patterns |
If AGENTS.md exceeds 50 lines or contains removable content, edit it in place and report what was cut.
2. Memory index (~/.claude/projects/.../memory/MEMORY.md)
Read the index and each linked file. Flag entries that are:
- Stale (reference things that no longer exist or have changed)
- Redundant with current project state
- No longer actionable
Remove stale files and their index entries. Report what was removed.
3. Settings.json allow list (target: broad patterns only)
Read .claude/settings.json. Flag any Bash(...) entries that are:
- Specific file paths — replace with a broad
Bash(git -C <project path> *)pattern - Pointing to paths that no longer exist
- Duplicated by an existing broad pattern
Edit in place, report changes.
4. Skill files (~/.claude/skills/)
Read each skill file. Flag content that is:
- Outdated (wrong simulator name, wrong paths, obsolete commands)
- Duplicated verbatim in AGENTS.md/CLAUDE.md or a command file
Report findings. Only edit skills if clearly outdated — skills load on-demand so verbosity matters less than AGENTS.md/CLAUDE.md.
5. Runtime read/tool-output waste (diagnostic only, no proxy required)
If headroom is installed (command -v headroom), run:
headroom audit-reads --path ~/.claude/projects/"$(pwd | sed 's/[^A-Za-z0-9]/-/g')" --format json--path scopes it to this project only — its default with no --path is ~/.claude/projects, every tracked project's transcripts combined, not this one. The transcript directory's name is this project's absolute path with every non-alphanumeric character (not just /) replaced by -; compute it with the sed command above rather than by hand — a path containing a ., space, or other punctuation (e.g. jane.doe, a folder name with parens or commas) transforms those characters too, not only slashes. This assumes the session was started from the project root: if your sessions launch from a parent directory, derive the path from that launch directory instead, because that is where the live transcripts land. It streams the scoped transcripts read-only and sizes addressable waste by category (identical repeats, stale reads, line-number scaffolding) as structured fields (dedup_identical_bytes, stale_bytes, linenum_overhead_bytes, etc.) — read those directly rather than parsing text output. This is a diagnostic, not a compression layer: it doesn't touch anything, it just tells you where the waste actually is.
Report the top category by byte share for this run. headroom doesn't persist run history, and this command doesn't save one either, so there's no "last run" to compare against — report the current numbers as a point-in-time reading, not a trend. If a category is a large share of the total, that's a behavioral signal, not a config fix — flag it in prose (e.g. "a file was re-read N times this session where the content hadn't changed — read once and hold it in context instead") rather than editing anything automatically; this section never changes files, unlike sections 1–4.
If headroom isn't installed, or audit-reads exits non-zero or returns malformed output, report that as section 5's outcome ("headroom not installed" / "audit-reads failed, skipped") rather than omitting a line for it — this section is optional to adopt, but still reports like every other section below.
Output
For each section, including section 5: what was found, what was changed (or "no changes needed"). End with the new line count for AGENTS.md/CLAUDE.md.
Rules
- Do not remove content that is genuinely useful and not available elsewhere
- Do not add new content — this is a reduction pass only
- Commit any changes to AGENTS.md/CLAUDE.md and settings.json with message
chore: trim context after <plan-name>
Done when
AGENTS.md/CLAUDE.md is ≤50 lines, stale memory entries removed, settings.json allow list tightened, and changes committed.
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.

