Analyze and optimize CLAUDE.md files for quality improvements and token reduction. Supports analysis-only, simplification-only, or full optimization modes. Use when asked to "review", "optimize", "simplify", "improve", "check", or "reduce tokens" in CLAUDE.md.
This Skill analyzes CLAUDE.md files for quality, suggests improvements based on Claude Code best practices, and simplifies content to reduce token usage.
/optimize-claude-md [mode] [level] [target]
Modes:
analyze: Quality analysis and improvement recommendations onlysimplify: Token reduction through simplificationfull: Both analysis and simplification (default)Levels (for simplify/full mode):
conservative: Careful simplification (50-70% reduction)aggressive: Bold simplification (70-85% reduction, recommended)extreme: Maximum reduction (85-95% reduction)Targets:
project: Project CLAUDE.md onlyall: Both project and global CLAUDE.md (global is read-only for reference)Global CLAUDE.md policy: Global ~/.claude/CLAUDE.md is always read-only. It may be read for cross-reference during analysis, but NEVER modified. Simplification proposals apply only to project-level files. If the user wants to change global CLAUDE.md, inform them to edit the chezmoi source instead.
Examples:
/optimize-claude-md # Full optimization, aggressive, project only
/optimize-claude-md analyze # Analysis only, project
/optimize-claude-md simplify conservative # Conservative simplification, project
/optimize-claude-md full aggressive all # Full optimization, global read for reference
Trigger this Skill when the user asks to:
Based on the mode parameter, follow the appropriate workflow:
Execute both analyze and simplify workflows in sequence.
Follow these steps to analyze and improve CLAUDE.md files:
Check all memory locations in this order:
./CLAUDE.md or ./.claude/CLAUDE.md — editable~/.claude/CLAUDE.md — read-only (reference only, never modify)./.claude/rules/*.md — editable./CLAUDE.local.md — editableRead each file found and note its location in the hierarchy. Global files (~/.claude/) are read for cross-reference context only — all modification proposals must target project-level files.
Evaluate each file against these criteria:
Organization:
Specificity:
Modularity:
.claude/rules/?See BEST-PRACTICES.md for detailed evaluation criteria.
Create a structured report with these sections:
Report Template:
# CLAUDE.md Analysis Report
## Executive Summary
[Overall assessment in 2-3 sentences]
## Strengths
- [What's working well]
## Issues Found
### Issue: [Name]
**Severity:** High/Medium/Low
**Location:** [File path and section]
**Problem:** [Specific issue]
**Example:**
[Quote from file]
**Why it matters:** [Impact on Claude's behavior]
## Recommendations
### Priority 1: [High-impact improvements]
[Specific action with code example]
### Priority 2: [Medium-impact improvements]
[Specific action with code example]
### Priority 3: [Low-impact improvements]
[Specific action with code example]
## Next Steps
1. [Immediate action]
2. [Short-term action]
3. [Long-term action]
For each recommendation, show:
When proposing simplifications, follow these critical rules:
For each proposed change, provide:
Example format:
**Section**: Worktree Management
**Why**: Implementation details inferable from command name
**Preserved**: Protection behavior (uncommitted/unpushed)
**Removed**: Auto-creates, uses existing (automatic behavior)
**Evidence**: "Auto-creates branch from current" ← user doesn't decide this
NEVER simplify content that serves as:
Explicit lists: Commit types, allowed values, prohibited patterns
Constraint definitions: "Only use X", "Never do Y"
Annotated examples: Annotations like "← why" clarify intent
Decision matrices: Tables showing when to use what
Preservation examples:
feat2, bugfix, etc.If CLAUDE.md or rules files are large or cover multiple concerns, suggest:
Splitting into .claude/rules/:
.claude/rules/
├── code-style.md # Style guidelines
├── testing.md # Test conventions
├── git-workflow.md # Commit and PR standards
└── debugging.md # Debugging procedures
Adding path-specific rules:
---
paths:
- "src/**/*.ts"
---
# TypeScript-specific guidelines
Using imports for modularity:
See @docs/architecture.md for system design
See @~/.claude/my-preferences.md for personal settings
❌ Bad: "Write good code" ✅ Good: "Use 2-space indentation for JavaScript"
❌ Bad: "Git is a version control system that..." ✅ Good: "Use conventional commits: feat/fix/refactor"
❌ Bad: All instructions in one long list ✅ Good: Grouped by topic with clear headings
❌ Bad: "Follow project conventions" ✅ Good: "Match existing pattern: async function fetchData()"
❌ Bad: "Use React 18 features" (will become outdated) ✅ Good: "Prefer hooks over class components"
❌ Bad: 2000-line CLAUDE.md with everything ✅ Good: Core in CLAUDE.md, specifics in .claude/rules/
❌ Bad: Inferring missing details and adding them as recommendations ✅ Good: Only reorganize, clarify, or simplify existing information
Critical Rule: Optimization means improving how existing information is presented, NOT adding new rules or information that wasn't there before. If something is unclear or seems incomplete, ask the user rather than assuming their intent.
Example of violation:
${projectRoot}/.tmp for temporary files"~/.tmp for system-wide temporary files"${projectRoot}/.tmp"For comprehensive best practices, see BEST-PRACTICES.md.
Key principles:
Always provide:
Make all recommendations actionable with specific text to add, remove, or modify.
Before proposing simplifications:
Approval format:
Proposal X: [Category name] (N lines reduced)
- Why: [Reason]
- Preserved: [Critical info]
- Removed: [Non-critical content]
Apply? (User must approve)
Search for places (restaurants, cafes, etc.) via Google Places API proxy on localhost.
Interact with GitHub using the `gh` CLI. Use `gh issue`, `gh pr`, `gh run`, and `gh api` for issues, PRs, CI runs, and advanced queries.
Create or update AgentSkills. Use when designing, structuring, or packaging skills with scripts, references, and assets.
Start voice calls via the OpenClaw voice-call plugin.
Notion API for creating and managing pages, databases, and blocks.
Gemini CLI for one-shot Q&A, summaries, and generation.
Category:developer