optimize-claude-md

optimize-claude-md is a skill for Claude Code from mthines/agent-skills. It costs 82 tokens per session (1,982 once invoked), scanned A, original, MIT.

A tool for checking CLAUDE.md instruction files and related rule files for unnecessary length, repetition, and outdated content. CLAUDE.md files provide guidance to coding agents working in a project.

In plain words
What is it for?
Use it to audit or trim large instruction files, find repeated guidance, and identify rarely used skills that should not appear in the always-available list.
Why use it?
It identifies instructions that consume attention and tokens every session, including long entries, duplicates, and stale nested documentation.

Skill for Claude Code

Written for Claude Code: disable-model-invocation in frontmatter. Also seen: mentions CLAUDE.md; mentions Claude Code.

Part of the mthines-agent-skills plugin — 54 skills, 3 agents, 2 hooks shipped together

Good fit Use it to audit or trim large instruction files, find repeated guidance, and identify rarely used skills that should not appear in the always-available list.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/mthines/agent-skills/optimize-claude-md
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add mthines/agent-skills --skill optimize-claude-md
Clone the repo
git clone --depth 1 https://github.com/mthines/agent-skills

Made for: Claude Code.

Or install mthines-agent-skills, the plugin that ships this one along with the rest of its 54 skills, 3 agents, 2 hooks.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for optimize-claude-md

README.md
[![agentmods](https://agentmods.dev/badge/skills/mthines/agent-skills/optimize-claude-md/github.svg)](https://agentmods.dev/skills/mthines/agent-skills/optimize-claude-md)
Your own site
<a href="https://agentmods.dev/skills/mthines/agent-skills/optimize-claude-md"><img src="https://agentmods.dev/badge/skills/mthines/agent-skills/optimize-claude-md/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for optimize-claude-md

Your own site · 80×15
<a href="https://agentmods.dev/skills/mthines/agent-skills/optimize-claude-md"><img src="https://agentmods.dev/badge/skills/mthines/agent-skills/optimize-claude-md.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 82 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,982 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe. Third-party audits
  • NVIDIA SkillSpector warn 7 Sept 2026
SkillSpector: 4 findings, up to medium

These are SkillSpector’s own severities. On a checked sample its high-severity flags on skills were ~96% false positives — a documented command, a public API, a “never do X” rule — so we show them as a caution to read, not a verdict. Why →

  • medium Prompt Injection · line 102
    Large whitespace padding was detected (a block of blank lines or a long run of spaces). This can push injected instructions below or to the right of the visible area so a human reviewer never sees them while the agent still reads them. Manual review of the hidden content is recommended.
    Fix: Remove the large whitespace padding (blank-line blocks or long space runs) and review any content hidden below or to the right of it. Keep skill files compact and reviewable so no instructions can be
  • medium Prompt Injection · line 104
    Large whitespace padding was detected (a block of blank lines or a long run of spaces). This can push injected instructions below or to the right of the visible area so a human reviewer never sees them while the agent still reads them. Manual review of the hidden content is recommended.
    Fix: Remove the large whitespace padding (blank-line blocks or long space runs) and review any content hidden below or to the right of it. Keep skill files compact and reviewable so no instructions can be
  • medium Prompt Injection · line 105
    Large whitespace padding was detected (a block of blank lines or a long run of spaces). This can push injected instructions below or to the right of the visible area so a human reviewer never sees them while the agent still reads them. Manual review of the hidden content is recommended.
    Fix: Remove the large whitespace padding (blank-line blocks or long space runs) and review any content hidden below or to the right of it. Keep skill files compact and reviewable so no instructions can be
  • medium Prompt Injection · line 109
    Large whitespace padding was detected (a block of blank lines or a long run of spaces). This can push injected instructions below or to the right of the visible area so a human reviewer never sees them while the agent still reads them. Manual review of the hidden content is recommended.
    Fix: Remove the large whitespace padding (blank-line blocks or long space runs) and review any content hidden below or to the right of it. Keep skill files compact and reviewable so no instructions can be
How audits are shown
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00082 $0.01982
Opus 5.5 $0.00033 $0.00793
Sonnet 5.5 $0.00016 $0.00396
Haiku 4.5 $0.00008 $0.00198

Measured 1mo ago against content hash 1bb32469cb3c, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

optimize-claude-md scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 1mo ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/authoring/optimize-claude-md/SKILL.md · 160 lines

How it starts

The opening of the file, as written. The whole thing — 160 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Optimize CLAUDE.md

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.md is a thin index. Detailed rules live in rules/*.md and load on demand. Worked examples live in references/*.md. Reading them all up-front would burn tokens you do not need yet.


When to run

Run when any of these hold:

  • Claude Code prints Large CLAUDE.md will impact performance (Xk chars > 40.0k) at session start.
  • The user asks "shrink", "optimize", "reduce", or "trim" CLAUDE.md.
  • A paragraph in CLAUDE.md exceeds 6 lines and is not a code block.
  • An inventory section duplicates content already loaded by the harness (e.g. skill description frontmatter, which is preloaded automatically).
  • A nested package CLAUDE.md repeats content from the root.

Refuse if the target file is < 10k chars — see rules/hard-rules.md.


Mode Detection

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)

Workflow

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.

Read the full file on GitHub · 160 lines

Files

What ships with it

8 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 1mo ago Changed · -15 lines · -157 tokens per session 1bb32469cb3c
  2. 3mo ago First seen · 175 lines · 239 tokens per session scan A 4af9ae5eecae

Subscribe to this mod's changes

optimize-claude-md is a skill published in the GitHub repository mthines/agent-skills (22 stars, last pushed yesterday), licensed MIT. It adds 82 tokens to every session and 1,982 once invoked, about $0.0003 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

optimize-claude-md compared with skills from other repositories

optimize-claude-md next to 6 skills from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
optimize-claude-mdmthines/agent-skillsSkill22yesterdayMITA82Claude Code
skill-bodycitrolabs/ego-liteSkill26kyesterdayMITA0Claude Code, Codex
ego-browsercitrolabs/ego-liteSkill26kyesterdayMITA125Claude Code, Codex
temporal-developertemporalio/skill-temporal-developerSkill2439d agoMITA216Claude Code, Codex
creating-explainersanalyticalmonk/explain-thisSkill241mo agoMITA98Claude Code, Codex
fact-checking-explainersanalyticalmonk/explain-thisSkill241mo agoMITA84Claude Code, Codex
explaining-codebasesanalyticalmonk/explain-thisSkill241mo agoMITA84Claude Code, Codex