optimize-claude-md

optimize-claude-md is a skill for Claude Code from mthines/agent-skills. It costs 239 tokens per session (2,229 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 — 55 skills, 4 agents 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 55 skills, 4 agents.

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.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.svg" alt="Measured on agentmods" height="20"></a>
Per session 239 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,229 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.00239 $0.02229
Opus 5 $0.00120 $0.01115
Sonnet 5 $0.00048 $0.00446
Haiku 4.5 $0.00024 $0.00223

Measured 8d ago against content hash 4af9ae5eecae, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-08, 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 8d 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 · 175 lines

How it starts

The opening of the file, as written. The whole thing — 175 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 · 175 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. 8d 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 (13 stars, last pushed yesterday), licensed MIT. It adds 239 tokens to every session and 2,229 once invoked, about $0.0012 per session on Opus 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

Other skills, from other repositories

ego-browser

Skill "ego-browser" from citrolabs/ego-lite, covering ego-browser, quick start, common helpers, task spaces and control handoff.

citrolabs/ego-lite · 210 tokens

temporal-developer

Develop, debug, and manage Temporal applications across Python, TypeScript, Go, Java, .NET, Ruby, and Rust. Use when the user is building workflows, activities, or workers with a Temporal SDK, debugging issues like non-determinism errors, stuck workflows, or activity retries, using Temporal CLI, Temporal Server, or…

temporalio/skill-temporal-developer · 161 tokens

geekx-gate

A review framework for deciding whether an engineering idea or technical commitment is necessary, too broad, or premature. It examines the real problem, complexity, evidence, non-goals, and ease of reversal.

geekjourneyx/geekx-skills · 155 tokens

geekx-engineering

A set of engineering instructions for making substantial changes in an existing codebase. It emphasizes understanding the affected system, keeping a persistent plan, and recording decisions and evidence.

geekjourneyx/geekx-skills · 59 tokens

x-algorithm

Write X (Twitter) posts that the For You algorithm actually rewards. Grounded in the open-sourced X recommendation system — the Grok-based transformer ranker, Phoenix retrieval, Thunder in-network store, and Grox content-understanding pipeline. Use when the user wants to write a post, thread, reply, or quote; plan a…

carson2222/skills · 152 tokens

opencode-memory

Browse local OpenCode history: sessions, messages, plans, prompt history, and prior decisions. Use when the user says history, previous session, last time, remember, recall, plans, prior work, or when resuming/debugging repeated work where earlier OpenCode context may help. Do not use for fresh tasks or when current…

carson2222/skills · 77 tokens