| name | update-claude-md |
| description | Analyse codebase and generate a hierarchical CLAUDE.md system optimized for Claude Code. Use when the user wants to update, regenerate, or create CLAUDE.md files, set up project documentation for Claude Code, or optimize the CLAUDE.md hierarchy. Triggers on "/update-claude-md", "update CLAUDE.md", "regenerate CLAUDE.md", or "set up Claude Code docs". |
Update CLAUDE.md
Analyze the codebase and generate a hierarchical CLAUDE.md system optimized for Claude Code.
Key Principles
- CLAUDE.md is authoritative — treated as system rules, not suggestions
- Use modular sections with clear markdown headers
- Front-load critical context — large CLAUDE.md files improve instruction adherence
- Hierarchical strategy: Root = universal rules; Subdirs = specific context
- Keep root CLAUDE.md under 400 lines
Workflow
Phase 1: Repository Analysis
Analyze and present:
- Architecture — monorepo/standard, tech stack, testing, CI/CD
- Claude Code opportunities — hooks, MCP servers, commands, subagents
- Directory map — where CLAUDE.md files should exist
- Dangerous patterns — commands to block, files to protect
- Tool permissions — defaults vs explicit permission required
Present analysis as a structured map before generating files.
Phase 2: Generate Root CLAUDE.md
Include these sections (see references/claude-md-guide.md for detailed templates):
- Project Identity (5-10 lines) — type, stack, architecture
- Universal Rules (10-20 lines) — MUST/SHOULD/MUST NOT with RFC-2119 language
- Core Commands (10-20 lines) — development, quality, testing
- Project Structure Map (15-30 lines) — with links to subdirectory CLAUDE.md
- Quick Find Commands (10-15 lines) — JIT search patterns
- Security & Secrets (5-10 lines)
- Git Workflow (5-10 lines)
- Testing Strategy (5-10 lines)
- Tool Permissions (5-10 lines)
- Subdirectory Context (5-10 lines) — links to specialized CLAUDE.md
Phase 3: Generate Subdirectory CLAUDE.md Files
For each major package/directory (100-200 lines each):
- Package identity and parent context link
- Setup and commands
- Architecture and patterns (most important)
- Key files and touch points
- JIT search hints
- Common gotchas
- Package-specific testing
- Pre-PR validation
Phase 4: Claude Code Configuration
- Hooks configuration (
.claude/settings.json)
- Custom slash commands (
.claude/commands/)
- MCP server recommendations
- Subagent recommendations (if applicable)
Quality Checklist