/mthines-agent-skills:optimize-claude-md [audit|trim|extract] [<path>]from mthines-agent-skills
Audits CLAUDE.md and .claude/rules/ for context bloat, then emits ranked fixes to trim inventory entries, extract sections, and flag rarely-used skills for slash-only invocation.
Ships in mthines-agent-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description, though model invocation is off: only you can start it.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Reduces the recurring token cost of CLAUDE.md (and its nested + linked
siblings) by identifying paragraph-length entries, redundant content, and
hot-path bloat — then trimming or extracting them while preserving the
canonical source.
This
SKILL.mdis a thin index. Detailed rules live inrules/*.mdand load on demand. Worked examples live inreferences/*.md. Reading them all up-front would burn tokens you do not need yet.
Run when any of these hold:
Large CLAUDE.md will impact performance (Xk chars > 40.0k) at session start.description frontmatter, which is preloaded automatically).CLAUDE.md repeats content from the root.Refuse if the target file is < 10k chars — see rules/hard-rules.md.
Parse $ARGUMENTS and detect the mode. First positional is mode; second is
optional path (default ./CLAUDE.md).
| Mode | Default | Trigger |
|---|---|---|
audit | yes | Default. Or audit, "review", "report", no mode argument. |
trim | trim, "shorten", "condense", "make entries one-liners". | |
extract | extract, "move to file", "split out", "externalize inventory". |
State the detected mode and target file in one line before continuing:
Mode: audit
Target: /abs/path/to/CLAUDE.md (43,012 chars / ~10,750 tokens)
| Phase | Name | Rule file | Gate |
|---|---|---|---|
| 0 | Preflight | rules/hard-rules.md | File exists, ≥ 10k chars, readable, in a project root or .claude/. |
| 1 | Measure | rules/measurement.md | Chars, approx tokens, line counts per section captured. |
| 2 | Classify content | rules/classification.md | Every section labelled hot-path / cold-path / borderline. |
| 2.5 | Invocation review | rules/invocation-review.md | Slash-conversion candidates (if any) listed with baseline-savings estimate. Skipped if the repo doesn't own skills/. |
| 3 | Mode-specific run | audit-mode.md, trim-mode.md, extract-mode.md | Report emitted or diff applied with user approval. |
| 4 | Verify | rules/hard-rules.md | Before/after metrics shown; no content lost in trim or extract. |
Load on demand — do not preload.
| Phase | Files |
|---|---|
| 0 | rules/hard-rules.md |
| 1 | rules/measurement.md |
| 2 | rules/classification.md, references/bloat-patterns.md (optional, for pattern matching) |
| 2.5 | rules/invocation-review.md, and the canonical create-skill/rules/invocation-control.md for the matrix. |
| 3 | One of rules/audit-mode.md, rules/trim-mode.md, rules/extract-mode.md — by mode. |
| 4 | rules/hard-rules.md (preservation invariant check) |
CLAUDE.md is a
recurring token cost once loaded, and survives compaction at a per-session
slice. Optimize for the smallest hot-path footprint that still preserves
the rules an agent must follow.description frontmatter is preloaded by Claude Code automatically. An
inventory paragraph in CLAUDE.md that restates it pays the token cost
twice. Replace with a one-line hook + link.trim / extract.
(b) Convert rarely-used agent-invokable skills to slash-only via Phase
2.5 — removes their description from the always-on available-skills
list. Both reduce per-session context cost.CLAUDE.md. Design rationale,
feature history, verbose descriptions → move to linked files.trim and extract always preserve content
somewhere reachable. If you cannot find a destination, abort and ask.SKILL.md frontmatter is
the authority for that skill. Never edit it from this skill — hand
invocation-flag changes to the user as a frontmatter edit to apply.rules/classification.md)description frontmatter verbatim.CLAUDE.md — belongs in the skill's own CLAUDE.md or a rule file.CLAUDE.md that repeats root content.CLAUDE.md itself — examples belong in skill files.docs skill's Placement
Resolver via Skill("docs", "pattern <glob>") when an extraction
needs cross-cutting placement (e.g. a rule applies to multiple subtrees).A run is complete when:
skills/ exists in the repo; candidates listed with baseline-savings estimates.audit: ranked report emitted with top-N concrete suggestions (lever 1 + lever 2), each tagged hot-path / cold-path or slash-conversion.trim and extract: every applied change shows before/after chars + estimated tokens saved.SKILL.md frontmatter edited (hand invocation-flag changes to the user as an edit).references/bloat-patterns.md (opens in a new tab)rules/audit-mode.md (opens in a new tab)rules/classification.md (opens in a new tab)rules/extract-mode.md (opens in a new tab)rules/hard-rules.md (opens in a new tab)rules/invocation-review.md (opens in a new tab)rules/measurement.md (opens in a new tab)rules/trim-mode.md (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
claude-md, context-bloat, optimization, audit, slash-command
Generated from the plugin's indexed repository (mthines/agent-skills) — no native marketplace selected
npx claudepluginhub p/mthines-mthines-agent-skills54 skills in this plugin
/ai-engineeringReviews and guides LLM/AI application engineering — prompts, caching, RAG, agent loops and tools, resilience, model migration, evals, prompt-injection defence, and observability. Invoke with /ai-engineering for "review my prompt", "set up RAG", or "write evals".
/animationsAuthors performant CSS-first web animations and picks the right feedback for an interaction — transitions, View Transitions, scroll-driven motion, Motion for React, reduced motion, and perceived performance. Triggers on "animate this", "hover effect", "feel faster", "skeleton loader", "/animations".
/animations-nativeAuthors performant React Native / Expo animations and gestures with Reanimated and react-native-gesture-handler on the UI thread; web animations go to `animations`. Triggers on "reanimated", "react native animation", "gesture handler", "swipe gesture", "/animations-native".
/atelierTakes one change from request to merged PR by sequencing existing skills — aw builds the draft PR, prepare gets it green, a deterministic gate allows the squash-merge only when a user-visible diff that needs a rollout ships behind a deployment-verify flag contract, or a small one carries a classed no-flag marker (and, in a repo with a hosted service, every diff carries a contract or an opt-out) — then reads the default-branch pipeline, fixes a red one once, verifies a no-flag change on the deploy with deployment-verify, and says what a human does next. Resumable from a sticky PR comment; invoke with /atelier.
/attach-mediaUploads local screenshots and recordings to GitHub and embeds them in a PR or issue body or comment as inline-rendering user-attachments URLs, via `gh --attach` with a curl fallback; never writes placeholders. Triggers on "attach screenshots to the PR", "upload this recording to the PR", "/attach-media".
/autonomous-workflowThe phase machinery (0–7) behind the `aw` dispatcher: task intake through a tested draft PR in an isolated worktree, gated by the plan.md brief and the run-checks.mjs sentinel, with companions that never block. Not the entry point — natural-language requests for autonomous work go to the `aw` skill; invoke /autonomous-workflow only to run the phases directly.
Other plugins' skills for the same job