marinvch/cortex/trim-agent-docs
Claude Code and agent skill by marinvch/cortex
- community
Checking that the SKILL.md file is still in the repository.
Audit and slim agent context files (AGENTS.md, CLAUDE.md, rules, skill bodies) in a repo or ~/.claude, and judge a skill collection by use — never reached, redundant. Triggers — "optimize the context", "our AGENTS.md is bloated", "clean up my global CLAUDE.md", "review my skills", "are any of these redundant".
Install
npx vskill@latest install marinvch/cortex/trim-agent-docsSKILL.md
The same SKILL.md was published earlier as marinvch/cortex/trim-agent-docs.
/trim-agent-docs — make a repo's agent context earn its tokens
Runs inside a target repo (Cortex-installed or not). Measures the files that steer AI agents there, ranks what costs context without earning it, fixes what is mechanically safe, and proposes everything else. The rules it applies are [[context-engineering]] Rules 1–5.
Not for this vault —/audit-notesowns vault structure.
This is the audit half of the job. /write-agent-docs is the other half — the discipline for writing these documents in the first place, and the vocabulary this ritual's findings are named in (context load, disclosure, sprawl, duplication, no-ops, a weakly worded pointer). Rewriting a file this ritual flags means reaching for that skill, not improvising.
The hard rule: never delete prose without a human yes
You cannot mechanically tell redundant from deliberately repeated because it is load-bearing ([[context-engineering]] Rule 5). In the Cortex vault itself, the employer-firewall enforcement repeated across /quick-note, /audit-notes score and /personal-setup scores as textbook duplication — and cutting it would silently remove a safety control.
So: automatic changes are limited to moves that preserve total information. Anything that reduces it is quoted, reasoned, and waits for a yes.
Two scopes — say which one you are in before Pass 1
Repo scope (the default): root and nested AGENTS.md · CLAUDE.md · GEMINI.md · .github/copilot-instructions.md · .github/instructions/*.md · .cursor/rules/*.mdc · .claude/skills/*/SKILL.md. Costs context only in that repo.
Machine scope — ~/.claude/CLAUDE.md, ~/.claude/agents/*.md, ~/.claude/skills/*/SKILL.md, and the settings.json that steers behaviour. Run this when the user says "my global CLAUDE.md", "the rules I have everywhere", "my personal instructions".
The machine scope is where bloat is most expensive and least examined: those files load in every session on every project, so a paragraph nobody needs is paid for on every turn of every task, forever. A repo's AGENTS.md is at least paid for only by people working in that repo.
It also inverts the main trim. A rule can move out of a repo file into a skill and be no worse off, because something will route back to it. A rule removed from a global CLAUDE.md and left only in a skill stops applying in every session where that skill does not trigger — and skills trigger on description match, which is exactly the thing you cannot guarantee. So in machine scope:
- Keep the invariant — the sentence that must hold even when no skill loads. One line.
- Move the method — the ordering, the checklists, the templates — into the skill, and point at
it by name from the line you kept.
- Never move a safety or privacy rule out of a global file at all. Those are exactly the rules whose
failure mode is silent.
The honest result of a machine-scope pass is often a file that is shorter in method and no shorter overall. Report it that way rather than reporting a line count as if it were the goal.
A machine-scope run pairs with the skill collection mode below: the passes judge the always-loaded prose, and that mode judges whether the skills it points at are ever reached.
Pass 1 — Measure
Per file: bytes, estimated tokens (bytes ÷ 4 — do not add a tokenizer), and whether it loads every session or on demand. Always-loaded bytes is the headline number; lead the report with it.
Read the frontmatter before you classify — location is not the answer. A file's own header decides when its host loads it, and classifying by path understates the headline number in the dangerous direction: the repo looks leaner than it is, so the findings that would recover the most context rank lowest or get dropped. On one real repo that error halved the number.
| Signal | Loads | |
|---|---|---|
applyTo: "**" in .github/instructions/*.md | every session — Copilot applies it to every file | |
applyTo: "src/pages/**, src/components/**" | on demand, for those globs only | |
alwaysApply: true in .cursor/rules/*.mdc | every session | |
globs: in .cursor/rules/*.mdc, no alwaysApply | on demand | |
root AGENTS.md, CLAUDE.md, GEMINI.md, shims | every session | |
| no frontmatter, nested leaf or skill body | on demand |
Two files that are both always-loaded are co-loaded, and that is what makes repointing one at the other content-preserving rather than lossy. Without reading the frontmatter a safe [safe] repoint is indistinguishable from an unsafe one, and the hard rule below — never delete prose without a human yes — has no way to be applied correctly.
State the signal you used per file, so the classification can be checked rather than trusted.
Pass 2 — Find waste
- Discoverable from code — cut what [[context-engineering]] Rule 3 covers. Check each claim
against the repo's manifest — package.json, pyproject.toml, go.mod, Cargo.toml, whatever the stack uses — and the actual tree; anything recoverable from the manifest counts as stated by the code, including script names. Test per line, not per section: keep any line carrying a fact the code does not state, and quote what you kept.
- Duplicated across files (Rule 4) — a shim holding its own copy; a convention stated in both
root and a leaf. Keep one canonical copy; point the rest at it — but only when the duplicate's content is fully contained in the canonical file. If it states anything the canonical file does not (drift), it is not a safe repoint — quote the divergent lines and treat it as [propose].
- Inlined bulk (Rule 2) — file templates, long examples, reference tables inside an
always-loaded body. Move to a file; reference it from the step that needs it.
The official lens — every always-loaded line, against Anthropic's own test
Anthropic's best-practices page gives a test for CLAUDE.md that applies to anything loaded every session. Cortex vendors it as rules in ${CLAUDE_PLUGIN_ROOT}/core/claude-code.js, each with its source sentence; cite the rule id in the finding, not a number from memory.
- `claude-md.prune-test` — for each always-loaded line: *could Claude work this out from the
code itself?* A line it could is a [propose] finding, quoted with that reason. This does not loosen the hard rule: the test says what to propose, the human still says yes.
- `claude-md.broad-only` — a line that applies only to one area or one workflow belongs in a
scoped leaf (/write-area-brief) or a skill, which load on demand. Moving it is [propose] unless the destination already states it word for word.
- `claude-md.emphasis-not-the-fix` —
IMPORTANT,MUST,NEVERdo not make a line stick.
Report the count. For a line Claude keeps skipping, propose a hook or deny rule if it cannot bend, or a shorter file if it is getting lost. Never propose adding emphasis.
- `claude-md.max-lines` — a file over this limit is a finding on its own; say by how much.
What the page says belongs in the file, and what does not (code.claude.com/docs/en/best-practices):
| Keep | Cut or move | |
|---|---|---|
| how to confirm work: the exact test, typecheck and lint commands, and how to run one test file | anything Claude can work out from the code itself | |
| places where the code misleads: a pattern new code must not copy, a directory that looks unused but isn't | a rule that can't have exceptions — make it a hook or a deny rule | |
| decisions that aren't in the repo: the error helper the team settled on, how deploys work | personal preferences — those go in CLAUDE.local.md, gitignored | |
| anything you've had to correct twice already | a procedure only some tasks need — make it a skill |
If the repo's /setup-repo report already carries claude-setup/claude-md-* findings, start from those — they are the mechanical half of this lens, and this pass is the judgment half.
Pass 3 — Find missing structure
The only pass that adds. Find directories that are high-churn, security/data sensitive, or hold an invariant an agent could break, and have no scoped AGENTS.md leaf. Read the code to confirm the invariant is real. Do not nominate a directory with no invariant and no gotcha.
Pass 4 — Report, then act
Rank findings by always-loaded bytes recovered. Tag each:
- `[safe]` — content-preserving (extract a template, repoint a shim whose content is fully
contained in the canonical file). Apply it.
- `[propose]` — reduces information. Quote the exact lines, give the reason, wait for a yes.
- `[handoff]` — an approved leaf nomination. Invoke
/write-area-brief <dir>; do not write leaves
here. Leaves are Rule 2 (progressive disclosure for directories); delegating rather than duplicating is Rule 4.
Close with: measured always-loaded bytes before → projected after.
The skill collection
Take this mode when the question is about the skills as a set: "review my skills", "are any of these redundant", "why does Claude never use this skill". The passes above read the files. This mode reads the record of them being used, because a skill's real defect is usually invisible in its own file: well written, correct, wired in, and nobody ever reaches it. On one vault the first run found 28 of 42 skills never reached in 51 sessions, and no amount of re-reading the bodies would have shown that. It reports only.
A skill nothing reaches is more often a routing failure than a quality one, and the fix is usually one line in a neighbouring skill. Deleting is the least interesting outcome.
Measure before reading anything
Read the exposure dates first. A skill added on the last recorded day has had no chance to fire, so its zero is arithmetic, not evidence. Judge only the skills present for most of the window, and say which ones you set aside.
The two counts are separate on purpose, and the gap between them is the diagnosis:
| typed | auto | What it means | |
|---|---|---|---|
| > 0 | 0 | the description does not match how the work actually arrives | |
| 0 | > 0 | it triggers on its own; the slash command is decoration | |
| 0 | 0 | nothing reaches it; the graph says whether that is wiring or a missing front door |
The usage tool reads a transcript directory holding everything the user has ever typed. It extracts skill names and timestamps only. Do not read those transcripts yourself for more context: that is a different act with a different consent question, and this mode does not include it.
Rank each skill, strongest signal first
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewNot runA model review is scheduled for the next rescan.
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/trim-agent-docs/SKILL.md
Popularity
- 7-day trend score
- 0
Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/marinvch/cortex/trim-agent-docs)