From claude-md-optimizer
Use when the user asks to audit, optimize, review, clean up, or improve a CLAUDE.md file. Also use when Claude is ignoring instructions, behaving inconsistently, or the CLAUDE.md appears bloated or overloaded. Does not cover SKILL.md files, plugin commands, or other markdown files.
npx claudepluginhub shawn-sandy/agentics --plugin claude-md-optimizerThis skill uses the workspace's default tool permissions.
Audit and optimize a CLAUDE.md file against Claude Code best practices.
Guides Next.js Cache Components and Partial Prerendering (PPR) with cacheComponents enabled. Implements 'use cache', cacheLife(), cacheTag(), revalidateTag(), static/dynamic optimization, and cache debugging.
Migrates code, prompts, and API calls from Claude Sonnet 4.0/4.5 or Opus 4.1 to Opus 4.5, updating model strings on Anthropic, AWS, GCP, Azure platforms.
Analyzes BMad project state from catalog CSV, configs, artifacts, and query to recommend next skills or answer questions. Useful for help requests, 'what next', or starting BMad.
Audit and optimize a CLAUDE.md file against Claude Code best practices.
Freedom level: Rigid — Execute all six steps in the order listed. Do not skip, combine, or reorder them.
Determine which CLAUDE.md to audit using this priority order:
CLAUDE.md in the current working directory (primary project location).claude/CLAUDE.md in the current working directory (alternate, checked if primary absent)~/.claude/CLAUDE.md (global user-level)Tell the user which file will be audited before continuing. If none of the four locations has a file and no argument was given, stop and ask the user to provide a path.
If a path was given but the file does not exist, stop and report the error clearly.
Read the target file in full, then collect these metrics:
**Always**, **Never**). Acknowledge a ±30–50 variance in your estimate.## heading presentsk-, ghp_, AKIA, xoxb-, -----BEGIN, or a label followed by a long alphanumeric string (e.g., TOKEN=abc123...). Report matches verbatim so the user can verify.@path/to/file references in the file. List each one found. Note that imported content counts toward effective instruction load but is not visible in the raw line count.Report all five metrics before proceeding to Step 3.
Score each dimension 0, 1, or 2. Maximum score: 12.
Full dimension definitions, scoring tables, and example audit output are in
references/audit-steps.md. Load that file before scoring.
Output a structured report in this format:
## CLAUDE.md Audit Report
**File:** [path audited]
**Lines:** [n] | **Estimated instructions:** [n ± 30–50]
### Scores
| Dimension | Score | Max |
|------------------------|-------|-----|
| Instruction Budget | [n] | 2 |
| Section Quality | [n] | 2 |
| 80% Rule Compliance | [n] | 2 |
| Progressive Disclosure | [n] | 2 |
| Safety & Hygiene | [n] | 2 |
| Structure | [n] | 2 |
| **Total** | **[n]** | **12** |
**Grade:** [see scale below]
Grade scale:
| Total | Grade |
|---|---|
| 10–12 | Optimized |
| 7–9 | Functional |
| 4–6 | Needs work |
| 0–3 | Rewrite |
After the table:
When Progressive Disclosure scores 0 or 1, include as a Top 3 item: "Use Step 5's rule-file generation to break path-specific content into
.claude/rules/files."
Ask the user: "Would you like me to generate an optimized version of this file in the chat?"
If the user says yes, generate the optimized content in a code block in the chat (do not write to disk yet). Apply these transformations:
[REDACTED - move to .env]).claude/rules/ files below, not embedded in the CLAUDE.md outputOffer to generate .claude/rules/ files:
For each section removed as an 80%-rule violation or path-specific content:
paths: frontmatter:---
paths:
- "<glob>"
---
# <Descriptive Title>
- Rule bullet 1
- Rule bullet 2
- Rule bullet 3
.claude/rules/ exists. If not, ask: "The .claude/rules/ directory does not exist. Should I create it?".claude/rules/<name>.md?" Wait for explicit confirmation before writing each file.After the CLAUDE.md code block, show a separate callout:
To make this optimizer always available in your project, add the following to your CLAUDE.md
(replace <plugin-dir> with the path passed to --plugin-dir when loading this plugin):
@<plugin-dir>/skills/claude-md-optimizer/SKILL.md
If the user says no, stop here.
After showing the optimized version, ask: "Should I write this to disk? Commit or back up your current CLAUDE.md first — this will overwrite it."
Wait for an explicit second confirmation before writing. Write only the file that was audited in Step 1.