xiaohongshu
xiaohongshu
editing-claude
Validate and optimize CLAUDE.md files using Anthropic's best practices for focused sessions. Detects contradictions, redundancy, excessive length (200+ lines), emphasis overuse (2%+ density), broken links, and orphaned sections. Scores health 0-50 points. Suggests safe automated fixes and extract...
Full skill instructions
Validate and optimize CLAUDE.md files to maintain focus and effectiveness.
This skill validates CLAUDE.md files against Anthropic's best practices, detects quality issues (contradictions, redundancy, excessive length, emphasis overuse), and suggests safe automated fixes or extraction strategies. Based on comprehensive research into context engineering best practices.
Analyze current CLAUDE.md:
Skill(command: "editing-claude")
Expected output: Health report (0-50 score), issues found (critical/warning/info), extraction opportunities, automated fixes available.
Explicit Triggers:
Implicit Triggers:
File Types:
8-Step Workflow:
Health Score Components (50 points):
Find all CLAUDE.md files in hierarchy:
# Global CLAUDE.md
test -f ~/.claude/CLAUDE.md && echo "Global: ~/.claude/CLAUDE.md" || echo "No global"
# Project CLAUDE.md
test -f ./CLAUDE.md && echo "Project: ./CLAUDE.md" || echo "No project"
# Get line counts
wc -l ~/.claude/CLAUDE.md ./CLAUDE.md 2>/dev/null
Read the target CLAUDE.md file (usually project).
Extract headings and calculate section lengths:
# Extract all headings with line numbers
grep -n "^#" ./CLAUDE.md
# Count sections
grep -c "^## " ./CLAUDE.md # H2 sections
grep -c "^### " ./CLAUDE.md # H3 subsections
Use Python script for detailed analysis:
python .claude/skills/editing-claude/scripts/analyze_structure.py ./CLAUDE.md
Detect issues:
Extract emphasis markers:
# Find all CRITICAL/MANDATORY/MUST/NEVER/ALWAYS instances
grep -n "\(CRITICAL\|MANDATORY\|MUST\|NEVER\|ALWAYS\)" ./CLAUDE.md
Calculate emphasis density:
python .claude/skills/editing-claude/scripts/analyze_emphasis.py ./CLAUDE.md
Thresholds:
5%: ❌ Error (nothing is critical)
Intra-file redundancy (same file):
Run semantic similarity analysis:
python .claude/skills/editing-claude/scripts/detect_redundancy.py ./CLAUDE.md
Distinguish redundancy from reinforcement:
Cross-file redundancy (global vs project):
python .claude/skills/editing-claude/scripts/detect_redundancy.py ~/.claude/CLAUDE.md ./CLAUDE.md
Common redundant rules:
Fix: Replace project duplication with reference to global.
Run semantic contradiction analysis:
python .claude/skills/editing-claude/scripts/detect_contradictions.py ./CLAUDE.md
Contradiction patterns:
Validation: Check if apparent contradictions are actually conditional fallbacks (not true contradictions).
Analyze each section:
python .claude/skills/editing-claude/scripts/identify_extractions.py ./CLAUDE.md
Extraction criteria:
Common extraction targets:
Keep in CLAUDE.md:
Extract and validate all links:
python .claude/skills/editing-claude/scripts/validate_links.py ./CLAUDE.md
Check:
Fix broken links automatically (safe operation).
Compile all analyses into comprehensive report:
python .claude/skills/editing-claude/scripts/generate_report.py ./CLAUDE.md
Report format:
# CLAUDE.md Health Report
**Overall Score: X/50** 🟢 EXCELLENT | 🟡 GOOD | 🟠 NEEDS WORK | 🔴 CRITICAL
## Issues Found
### 🔴 Critical (Fix Immediately)
- [Issue with line numbers and fix]
### 🟠 High Priority (Fix Soon)
- [Issue with line numbers and fix]
### 🟡 Medium Priority (Improve)
- [Issue with line numbers and suggestion]
### 🟢 Low Priority (Optional)
- [Issue with line numbers and suggestion]
## Extraction Opportunities
- [Section] (X lines) → [target-file.md]
## Automated Fixes Available
- [ ] Fix 1 (safe, low-risk)
- [ ] Fix 2 (requires review)
## Recommendations
1. [Priority action]
2. [Next action]
3. [Future improvement]
Write report to .claude/artifacts/YYYY-MM-DD/reports/claude-md-health-report.md.
reports/ subfolder for health reportsreports/claude-md-optimization/)The following fixes can be applied automatically (with --apply flag):
When: Same rule in global and project CLAUDE.md
Action: Replace project duplication with reference to global
# Before (project CLAUDE.md)
### Token Optimization (MultiEdit Required)
[13 lines of MultiEdit explanation]
# After
### Token Optimization
**Global Rule:** See [~/.claude/CLAUDE.md](~/.claude/CLAUDE.md) for MultiEdit requirement
Validation: Ensure global CLAUDE.md exists and contains the rule.
When: Internal link points to non-existent file
Action: Update link to correct path OR remove if file truly missing
Validation: File exists at new path AND content matches expected.
When: H3 section without H2 parent
Action: Promote to H2 OR nest under appropriate existing H2
Validation: Requires semantic understanding - ASK USER for confirmation.
When: Too many CRITICAL/MANDATORY markers
Action: Remove redundant emphasis (e.g., heading + body both have emphasis)
Validation: Meaning preserved, emphasis still clear.
See examples/examples.md for:
Verify skill execution:
.claude/artifacts/YYYY-MM-DD/reports/Expected outcomes:
With Quality Gates:
With Git Workflow:
With Documentation Reviews:
With Skill Creator:
Common mistakes when using this skill:
Issue: Script not found
ls .claude/skills/editing-claude/scripts/Issue: False positive contradictions
Issue: Health score seems wrong
Issue: Extraction suggestions break document
Issue: Links break after fixes
git checkout CLAUDE.md if neededPython 3.8+ with standard library:
re (regex)os (file operations)sys (arguments)pathlib (path handling)Bash tools:
grep (pattern matching)wc (line counting)test (file existence)Claude Code tools:
Optional:
git (for rollback, history analysis)markdownlint (markdown validation)xiaohongshu
technical spec
product ux expert
database patterns
Conduct multi-agent task orchestration and workflow coordination.
Initialize project with Conductor artifacts (product definition,
Expert in web animations, transitions, and motion design using Framer Motion and CSS
Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...
PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.
Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...
Display project status, active tracks, and next actions
Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.
Generate, edit, and beat-sync AI video with leading models in one workspace.
The world's fastest calendar for remote work
Transform Your Design with AI Designer by ImgCreator.ai
Revolutionizing Video Production with AI-Powered Creativity
Extend an image past the frame and let AI fill the new aspect ratio.
Discover your celebrity doppelgänger with StarByFace!
ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.
Opus.ai: Revolutionize Your Web Experience