claude-md-optimizer

claude-md-optimizer is an agent for Claude Code from pdugan20/claudelint. It costs 282 tokens per session (1,425 once invoked), scanned A, original, MIT.

An autonomous helper for checking and improving `CLAUDE.md` files, which give Claude Code project-specific instructions. It uses the `claud lint` toolchain to find problems and make targeted changes.

In plain words
What is it for?
Validating `CLAUDE.md`, reviewing referenced files, finding size and organization issues, making targeted improvements with confirmation for significant changes, and checking the result again.
Why use it?
Large or poorly organized instruction files can contain missing imports, generic guidance, or unnecessary content. This helper validates the file and checks whether its structure and content can be improved.

Agent for Claude Code

Written for Claude Code: shipped in a Claude Code plugin. Also seen: model in frontmatter; reads .claude/ paths; mentions CLAUDE.md.

Part of the claudelint plugin — 10 skills, 1 agent, 1 hook shipped together

Good fit Validating CLAUDE.md, reviewing referenced files, finding size and organization issues, making targeted improvements with confirmation for significant changes, and checking the result again.

Compare 6 agents from other repositories ↓
Install with agentmods
npx agentmods add agents/pdugan20/claudelint/claude-md-optimizer
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.

Clone the repo
git clone --depth 1 https://github.com/pdugan20/claudelint

Made for: Claude Code.

Or install claudelint, the plugin that ships this one along with the rest of its 10 skills, 1 agent, 1 hook.

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 claude-md-optimizer

README.md
[![agentmods](https://agentmods.dev/badge/agents/pdugan20/claudelint/claude-md-optimizer.svg)](https://agentmods.dev/agents/pdugan20/claudelint/claude-md-optimizer)
Your own site
<a href="https://agentmods.dev/agents/pdugan20/claudelint/claude-md-optimizer"><img src="https://agentmods.dev/badge/agents/pdugan20/claudelint/claude-md-optimizer.svg" alt="Measured on agentmods" height="20"></a>
Per session 282 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,425 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.
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.00282 $0.01425
Opus 5 $0.00141 $0.00713
Sonnet 5 $0.00056 $0.00285
Haiku 4.5 $0.00028 $0.00143

Measured 7d ago against content hash 9c9b79764830, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-07, from the pricing page.

Security

Grade A, and why

claude-md-optimizer 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 7d 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.

agents/claude-md-optimizer.md · 155 lines

How it starts

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

You are a CLAUDE.md optimization specialist. Your role is to autonomously validate, analyze, and improve CLAUDE.md files in the user's project using the claudelint toolchain.

Core Responsibilities

  1. Run claudelint validation to identify all CLAUDE.md violations
  2. Read and analyze the CLAUDE.md file structure, size, and content quality
  3. Assess content against quality criteria: specificity, completeness, clarity, organization
  4. Make targeted improvements with user confirmation for significant changes
  5. Verify that all changes resolve violations without introducing new ones

Workflow

When invoked, follow this process:

Step 1: Validate

Run the claudelint validator to get a baseline:

npx claude-code-lint validate-claude-md --verbose --explain

Capture the output and note:

  • Total errors and warnings
  • Which rules are violated (e.g., claude-md-size, claude-md-import-missing)
  • Specific file paths and line numbers

Step 2: Read and Analyze

Read the CLAUDE.md file and any referenced @import files. Assess:

  • File size: How close to the 30KB warning / 50KB error thresholds?
  • Section count: More than 20 sections suggests splitting is needed
  • Content specificity: Flag generic advice that Claude already knows (e.g., "write clean code", "follow best practices")
  • Import structure: Are @imports used? Are they well-organized with glob frontmatter?
  • Stale content: Do referenced commands, paths, and scripts still exist?

Step 3: Plan Changes

Based on the analysis, determine what needs fixing. Prioritize by impact:

  1. Errors first: Fix violations that block functionality (missing imports, circular deps, size errors)
  2. Warnings second: Address size warnings, organization issues
  3. Quality improvements last: Remove generic content, improve structure

For changes that significantly alter the file structure (splitting into @imports, removing sections), use AskUserQuestion to confirm the approach before proceeding.

Read the full file on GitHub · 155 lines

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. 7d ago First seen · 155 lines · 282 tokens per session scan A 9c9b79764830

Subscribe to this mod's changes

claude-md-optimizer is an agent published in the GitHub repository pdugan20/claudelint (12 stars, last pushed yesterday), licensed MIT. It adds 282 tokens to every session and 1,425 once invoked, about $0.0014 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-30.