skills/optimize-cc-md/SKILL.md
Interactively helps users optimize their CLAUDE.md files. Use when user asks to "optimize my CLAUDE.md", "my CLAUDE.md is too long", "improve organization", or "split my CLAUDE.md". Runs validation, explains issues conversationally, and helps create @import files to reduce size and improve structure.
npx skillsauth add pdugan20/claudelint optimize-cc-mdInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
An interactive skill that helps you optimize your CLAUDE.md file through a 3-phase workflow: validate, assess quality, then make guided improvements. Each phase builds on the previous one so the user understands what's wrong, why it matters, and what to do about it.
Invoke with /optimize-cc-md or say "optimize my CLAUDE.md". Optionally pass a path: /optimize-cc-md CLAUDE.md. The skill guides you through three phases: validation, quality assessment, and guided improvement.
If a specific path is provided, optimize that file: $ARGUMENTS
Phase A: Validate Phase B: Assess Quality Phase C: Guided Improvement
───────────────── ─────────────────────── ───────────────────────────
Run claudelint → Explain issues plainly → Ask user what to fix
Read CLAUDE.md → Check quality criteria → Make surgical changes
Collect violations → Identify opportunities → Create @import files
→ Verify results
Run automated validation and read the file to understand its current state.
Use the Bash tool to run claudelint validation with verbose output:
npx claude-code-lint validate-claude-md --verbose
This identifies all CLAUDE.md issues including:
Use the Read tool to examine the user's CLAUDE.md:
Read(file_path: "CLAUDE.md")
Understand the current structure, content, and patterns. Note:
Go beyond automated checks. Explain issues conversationally and evaluate quality using criteria that linting can't catch.
Translate validation errors into plain language:
Focus on the "why" not just the "what". Help users understand the impact.
Walk through the key quality dimensions from quality criteria:
Present a brief assessment to the user:
"Your CLAUDE.md has 3 validation errors and some quality gaps:
- 45KB (over 30KB threshold) - needs splitting
- 12 generic statements that should be removed
- Testing section is thorough but git workflow is missing
- Good: all commands are current and paths are valid"
For each issue, determine the root cause and link to reference files:
Let the user choose what to fix, then make the changes and verify results.
Use the AskUserQuestion tool to present prioritized options:
What would you like me to fix first?
1. Reduce file size (45KB → under 30KB)
2. Fix circular import in git-workflow.md
3. Split content into organized @imports
4. Remove generic/obvious content
Let the user prioritize. Don't assume.
Use the Edit tool for surgical changes to CLAUDE.md:
Edit(
file_path: "CLAUDE.md",
old_string: "existing content to replace",
new_string: "new content"
)
For removing content:
Use the Write tool to create new files in .claude/rules/:
Write(
file_path: ".claude/rules/git-workflow.md",
content: "---\nglob: \"**/*.{ts,js}\"\n---\n\n# Git Workflow\n\n..."
)
Then update CLAUDE.md to import the file:
Edit(
file_path: "CLAUDE.md",
old_string: "# Git Workflow\n\nLong content here...",
new_string: "@import .claude/rules/git-workflow.md"
)
Best practices for @imports:
Run validation again to confirm fixes:
npx claude-code-lint validate-claude-md --verbose
Show before/after comparison:
For detailed fix strategies, see common fixes reference.
Quick reference:
User says: "My CLAUDE.md is 45KB and I'm getting warnings. How do I reduce it?"
Phase A - Run validation and read the file:
npx claude-code-lint validate-claude-md --verbose
Output shows: "Warning: CLAUDE.md is 45KB (threshold: 30KB)". Read the file and note the largest sections: git workflow (12KB), testing standards (8KB), generic advice (~5KB scattered).
Phase B - Assess quality and explain:
"Your file is 45KB - 15KB over the warning threshold. I found:
Phase C - Fix with user guidance:
Ask user what to fix. User chooses: "Split git workflow and remove generic advice."
Write(.claude/rules/git-workflow.md, content: git workflow section)
Edit(CLAUDE.md, old: git workflow section, new: @import .claude/rules/git-workflow.md)
Edit(CLAUDE.md, old: generic advice blocks, new: [removed])
Re-run validation: "CLAUDE.md is now 28KB (under 30KB threshold)."
Result: File reduced from 45KB to 28KB by splitting largest section and removing bloat.
User says: "My CLAUDE.md has everything in one file. Help me organize it better."
Phase A - Validate and read. Find 5 distinct topics totaling 1,650 lines.
Phase B - Assess: "I see 5 distinct topics that can each become focused @import files. This will make your config more maintainable. All content is project-specific (good), but nothing is scoped by file type."
Phase C - Suggest structure, create files with glob frontmatter, update CLAUDE.md:
.claude/rules/
├── git-workflow.md (glob: "**/*")
├── testing.md (glob: "**/*.test.ts")
├── typescript.md (glob: "**/*.{ts,tsx}")
├── api-conventions.md (glob: "src/api/**/*.ts")
└── style-guide.md (glob: "src/**/*.ts")
Re-run validation to confirm no circular imports or depth issues.
Result: Well-organized config with 5 focused @import files, each scoped to relevant file types.
User says: "Is my CLAUDE.md too generic? It feels bloated."
Phase A - Validate and read. Use Grep to find generic patterns ("always", "best practice", "should", "never"). Find 47 instances.
Phase B - Assess: "I found 47 generic statements that Claude already knows. These add ~5KB without project-specific value. Example - Generic: 'Always write clean code' vs Project-specific: 'Use PascalCase for React components, camelCase for hooks'"
Phase C - Show the user what will be removed, ask for confirmation, then edit. Re-run validation.
Result: Focused config with only project-specific guidance. File size reduced by 5KB.
For solutions to common problems, see troubleshooting guide.
Common issues: CLI not found (install claude-code-lint), broken @import paths, size violations persisting after splits, circular imports.
/init command instead/validate-cc-md for just checkingThis skill requires the claudelint npm package:
npm install --save-dev claude-code-lint
The skill checks for this dependency and will show installation instructions if missing.
For detailed strategies, see:
These files are read on-demand when you need specific guidance.
testing
A valid test skill for testing purposes. Use this when you want to test skill validation.
testing
This skill is missing the version field for testing purposes.
testing
This skill contains dangerous commands for testing security validation.
tools
Validates Claude Code skills for schema, naming, documentation, and security. Use when user asks to "check my skill", "validate skill syntax", "why isn't my skill loading", "skill errors", or "dangerous command detected". Validates SKILL.md frontmatter, allowed-tools, file references, directory organization, and shell script security.