CLAUDE.md Architect Skill
Generate and optimize CLAUDE.md files for software projects by analyzing codebase context and applying Anthropic engineering best practices. Creates concise, maintainable project instructions that maximize Claude Code effectiveness while minimizing token consumption.
Core Principles
- Conciseness over Completeness: Treat CLAUDE.md like frequently-used prompts, not exhaustive documentation
- Evidence-Based Context: Analyze actual codebase before making recommendations
- Incremental Refinement: Start minimal, iterate based on effectiveness
- Token Efficiency: Every line should earn its presence in the context window
- Human-Readable Structure: Use clear organization with XML tags for parsing
When to Use This Skill
Activate when user requests:
- "init CLAUDE.md" or "create project instructions"
- "optimize" or "improve" existing CLAUDE.md
- "setup Claude for my project"
- Project-specific instructions for Claude Code
- Starting work on a new project that needs documentation
- Existing CLAUDE.md is outdated or ineffective
Quick Decision Tree
User Request
│
├─→ "init" or "create" → Initialize New CLAUDE.md
│ └─→ Follow: @refs/initialization-workflow.md
│
├─→ "optimize" or "improve" → Optimize Existing CLAUDE.md
│ └─→ Follow: @refs/optimization-patterns.md
│
└─→ "integrate" or "setup MCP/slash commands" → Integration
└─→ Follow: @refs/integration-strategies.md
Workflow Overview
Initialize New CLAUDE.md
Quick Steps:
- Discover - Analyze codebase (language, framework, structure, tests)
- Extract - Identify code style, commands, patterns
- Generate - Select template, customize for project
- Validate - Verify commands, check token count
- Present - Show output with explanation
Detailed Instructions: @refs/initialization-workflow.md
Optimize Existing CLAUDE.md
Quick Steps:
- Analyze - Evaluate token efficiency, accuracy, relevance
- Identify - Find redundancy, outdated info, generic fluff
- Refactor - Apply token reduction, restructure, improve clarity
- Test - Verify 40%+ token reduction, retain critical info
- Present - Show before/after with metrics
Detailed Instructions: @refs/optimization-patterns.md
Token Reduction Quick Reference
Before (Verbose)
When you are implementing new features in this codebase, it's very important that you always make sure to write comprehensive tests for all the functionality you add. We use Jest as our testing framework, and we expect all new code to have at least 80% code coverage.
After (Concise)
### Testing Requirements
- New features require tests (Jest, >80% coverage)
- Unit tests: Individual functions in `src/lib/`
- Integration tests: API endpoints with Supertest
Result: 70% token reduction, same information
Template Selection Guide
| Project Type |
Key Indicators |
Template Focus |
| Web App |
React/Vue/Angular, frontend build |
UI components, responsive design, routing |
| Backend API |
Express/FastAPI, database, auth |
RESTful conventions, validation, security |
| CLI Tool |
Commander/Click, stdio |
Commands, user experience, file operations |
| Library |
Package exports, no app logic |
API design, versioning, backward compatibility |
| Monorepo |
Workspaces, multiple packages |
Cross-package changes, workspace commands |
Quality Checklist
Before presenting CLAUDE.md:
- ✓ File is <400 lines (prefer <250)
- ✓ Commands verified against package.json/Makefile
- ✓ Patterns match actual codebase conventions
- ✓ No redundant info already in README
- ✓ Context loading is selective, not exhaustive
- ✓ Structure uses clear sections with headers
- ✓ Examples are concrete, not generic
- ✓ Security/testing requirements reflect actual needs
Token Budget Guidelines
| Project Complexity |
Target Token Count |
| Simple (single-purpose tool) |
100-200 tokens |
| Medium (standard web app) |
200-400 tokens |
| Complex (multi-service platform) |
400-800 tokens |
| Maximum (exception only) |
1000 tokens |
If approaching max, split into:
.claude/CLAUDE.md (essentials)
.claude/ARCHITECTURE.md (reference, not auto-loaded)
.claude/commands/*.md (workflows as slash commands)
Content Priority
Keep (High Value)
- Project-specific commands and scripts
- Code style conventions unique to this project
- File organization patterns
- Testing requirements and strategies
- Security constraints
- Performance considerations
Remove (Low Value)
- Generic software engineering advice
- Information already in README
- Obvious best practices (DRY, SOLID, etc.)
- Detailed framework explanations (use context7)
- Step-by-step tutorials (link to docs)
Context Loading Strategy
Use @-syntax ONLY for:
- Small, universally relevant files (<100 lines)
- Configuration affecting all changes (tsconfig, .eslintrc)
- Core type definitions used everywhere
Use On-Demand Loading:
When working on authentication:
@src/lib/auth.ts
@src/middleware/authenticate.ts
Avoid:
- Loading entire directories with @src/**
- Adding large files that aren't always needed
- Injecting documentation that duplicates official sources
Integration with Global CLAUDE.md
User has ~/.claude/CLAUDE.md (global):
- Universal principles (SOLID, DRY, YAGNI)
- MCP tool documentation
- Preferred communication style
Project CLAUDE.md should:
- Focus exclusively on project-specific guidance
- Avoid duplicating MCP tool usage (already global)
- Add project-specific MCP tool applications only
Example header:
# MyProject - Development Guide
> Note: General software engineering principles are in your global CLAUDE.md.
> This guide focuses on project-specific patterns and requirements.
MCP Tool Configuration
Detect opportunities:
- React/Vue/Angular imports → Suggest context7 for official docs
- UI component requests → Suggest magic MCP for patterns
- E2E test files → Suggest Playwright MCP for browser automation
Add to CLAUDE.md:
## MCP Tools Configuration
### context7 (Official Documentation)
Use for React hooks, Next.js routing, Prisma schema
### magic (UI Component Generation)
Use for new components, accessibility improvements
### Playwright (E2E Testing)
Use for user flows, visual regression, accessibility audits
Detailed Integration Guide: @refs/integration-strategies.md
Output Format
When Generating New CLAUDE.md
- Display generated content in code block
- Explain customizations based on analysis
- Highlight key decisions
- Suggest optional additions
- Provide save location and next steps
When Optimizing Existing CLAUDE.md
- Summarize issues found
- Show before/after comparison for key sections
- Present optimized full version
- Quantify improvements (token savings %)
- Suggest iteration approach
Detailed Templates: @refs/output-templates.md
Common Mistakes to Avoid
| Problem |
Solution |
| Over-Documentation |
Document project-specific decisions only |
| Stale Information |
Verify against current package.json, files |
| Redundant Context |
Link to README, add only unique patterns |
| Token Waste |
On-demand context by functional area |
| Generic Fluff |
Specific patterns: "Use Zod validation, Prisma transactions" |
Success Metrics
Effective CLAUDE.md
- Claude requires fewer clarifying questions
- Code matches project conventions on first try
- Commands work without errors
- User rarely provides missing context manually
Ineffective CLAUDE.md
- Claude frequently asks "what framework?"
- Generated code doesn't match existing style
- User repeatedly provides same context files
- CLAUDE.md contains info never referenced
Philosophy
Remember:
- CLAUDE.md is a living document, not permanent documentation
- Start minimal, add based on actual friction points
- Remove guidance that doesn't improve Claude's output
- Measure effectiveness: fewer questions = better CLAUDE.md
When in doubt:
- Prefer concise over comprehensive
- Prefer specific over generic
- Prefer examples over explanations
- Prefer on-demand over auto-loading
Reference Files
- @refs/initialization-workflow.md - Complete guide for creating new CLAUDE.md files from scratch
- @refs/optimization-patterns.md - Techniques for reducing tokens and improving effectiveness
- @refs/integration-strategies.md - Integration with global config, MCP tools, slash commands
- @refs/output-templates.md - Standard formats for presenting results to users
Quick Start: When user requests CLAUDE.md creation/optimization, follow the decision tree above and consult relevant reference files for detailed instructions.
1---2name: claude-md-architect3description: CLAUDE.md file generation and optimization for Claude Code projects. Capabilities: initialize project instructions, analyze codebase context, optimize existing CLAUDE.md, apply Anthropic best practices, reduce token usage, improve effectiveness. Actions: init, create, optimize, enhance CLAUDE.md files. Keywords: CLAUDE.md, project instructions, Claude Code setup, project context, codebase analysis, Anthropic best practices, token optimization, project configuration, AI instructions, coding guidelines, project rules, workspace setup. Use when: initializing CLAUDE.md for new projects, optimizing existing project instructions, setting up Claude Code for a codebase, improving AI coding guidelines.4---56# CLAUDE.md Architect Skill78Generate and optimize CLAUDE.md files for software projects by analyzing codebase context and applying Anthropic engineering best practices. Creates concise, maintainable project instructions that maximize Claude Code effectiveness while minimizing token consumption.910## Core Principles11121. **Conciseness over Completeness**: Treat CLAUDE.md like frequently-used prompts, not exhaustive documentation132. **Evidence-Based Context**: Analyze actual codebase before making recommendations143. **Incremental Refinement**: Start minimal, iterate based on effectiveness154. **Token Efficiency**: Every line should earn its presence in the context window165. **Human-Readable Structure**: Use clear organization with XML tags for parsing1718## When to Use This Skill1920Activate when user requests:21- "init CLAUDE.md" or "create project instructions"22- "optimize" or "improve" existing CLAUDE.md23- "setup Claude for my project"24- Project-specific instructions for Claude Code25- Starting work on a new project that needs documentation26- Existing CLAUDE.md is outdated or ineffective2728## Quick Decision Tree2930```31User Request32 │33 ├─→ "init" or "create" → Initialize New CLAUDE.md34 │ └─→ Follow: @refs/initialization-workflow.md35 │36 ├─→ "optimize" or "improve" → Optimize Existing CLAUDE.md37 │ └─→ Follow: @refs/optimization-patterns.md38 │39 └─→ "integrate" or "setup MCP/slash commands" → Integration40 └─→ Follow: @refs/integration-strategies.md41```4243## Workflow Overview4445### Initialize New CLAUDE.md4647**Quick Steps:**481. **Discover** - Analyze codebase (language, framework, structure, tests)492. **Extract** - Identify code style, commands, patterns503. **Generate** - Select template, customize for project514. **Validate** - Verify commands, check token count525. **Present** - Show output with explanation5354**Detailed Instructions:** @refs/initialization-workflow.md5556### Optimize Existing CLAUDE.md5758**Quick Steps:**591. **Analyze** - Evaluate token efficiency, accuracy, relevance602. **Identify** - Find redundancy, outdated info, generic fluff613. **Refactor** - Apply token reduction, restructure, improve clarity624. **Test** - Verify 40%+ token reduction, retain critical info635. **Present** - Show before/after with metrics6465**Detailed Instructions:** @refs/optimization-patterns.md6667## Token Reduction Quick Reference6869### Before (Verbose)70```markdown71When you are implementing new features in this codebase, it's very important that you always make sure to write comprehensive tests for all the functionality you add. We use Jest as our testing framework, and we expect all new code to have at least 80% code coverage.72```7374### After (Concise)75```markdown76### Testing Requirements77- New features require tests (Jest, >80% coverage)78- Unit tests: Individual functions in `src/lib/`79- Integration tests: API endpoints with Supertest80```8182**Result:** 70% token reduction, same information8384## Template Selection Guide8586| Project Type | Key Indicators | Template Focus |87|--------------|----------------|----------------|88| **Web App** | React/Vue/Angular, frontend build | UI components, responsive design, routing |89| **Backend API** | Express/FastAPI, database, auth | RESTful conventions, validation, security |90| **CLI Tool** | Commander/Click, stdio | Commands, user experience, file operations |91| **Library** | Package exports, no app logic | API design, versioning, backward compatibility |92| **Monorepo** | Workspaces, multiple packages | Cross-package changes, workspace commands |9394## Quality Checklist9596Before presenting CLAUDE.md:97- ✓ File is <400 lines (prefer <250)98- ✓ Commands verified against package.json/Makefile99- ✓ Patterns match actual codebase conventions100- ✓ No redundant info already in README101- ✓ Context loading is selective, not exhaustive102- ✓ Structure uses clear sections with headers103- ✓ Examples are concrete, not generic104- ✓ Security/testing requirements reflect actual needs105106## Token Budget Guidelines107108| Project Complexity | Target Token Count |109|-------------------|-------------------|110| **Simple** (single-purpose tool) | 100-200 tokens |111| **Medium** (standard web app) | 200-400 tokens |112| **Complex** (multi-service platform) | 400-800 tokens |113| **Maximum** (exception only) | 1000 tokens |114115If approaching max, split into:116- `.claude/CLAUDE.md` (essentials)117- `.claude/ARCHITECTURE.md` (reference, not auto-loaded)118- `.claude/commands/*.md` (workflows as slash commands)119120## Content Priority121122### Keep (High Value)123- Project-specific commands and scripts124- Code style conventions unique to this project125- File organization patterns126- Testing requirements and strategies127- Security constraints128- Performance considerations129130### Remove (Low Value)131- Generic software engineering advice132- Information already in README133- Obvious best practices (DRY, SOLID, etc.)134- Detailed framework explanations (use context7)135- Step-by-step tutorials (link to docs)136137## Context Loading Strategy138139### Use @-syntax ONLY for:140- Small, universally relevant files (<100 lines)141- Configuration affecting all changes (tsconfig, .eslintrc)142- Core type definitions used everywhere143144### Use On-Demand Loading:145```markdown146When working on authentication:147 @src/lib/auth.ts148 @src/middleware/authenticate.ts149```150151### Avoid:152- Loading entire directories with @src/**153- Adding large files that aren't always needed154- Injecting documentation that duplicates official sources155156## Integration with Global CLAUDE.md157158**User has ~/.claude/CLAUDE.md (global):**159- Universal principles (SOLID, DRY, YAGNI)160- MCP tool documentation161- Preferred communication style162163**Project CLAUDE.md should:**164- Focus exclusively on project-specific guidance165- Avoid duplicating MCP tool usage (already global)166- Add project-specific MCP tool applications only167168**Example header:**169```markdown170# MyProject - Development Guide171172> Note: General software engineering principles are in your global CLAUDE.md.173> This guide focuses on project-specific patterns and requirements.174```175176## MCP Tool Configuration177178### Detect opportunities:179- React/Vue/Angular imports → Suggest **context7** for official docs180- UI component requests → Suggest **magic** MCP for patterns181- E2E test files → Suggest **Playwright** MCP for browser automation182183### Add to CLAUDE.md:184```markdown185## MCP Tools Configuration186187### context7 (Official Documentation)188Use for React hooks, Next.js routing, Prisma schema189190### magic (UI Component Generation)191Use for new components, accessibility improvements192193### Playwright (E2E Testing)194Use for user flows, visual regression, accessibility audits195```196197**Detailed Integration Guide:** @refs/integration-strategies.md198199## Output Format200201### When Generating New CLAUDE.md2022031. Display generated content in code block2042. Explain customizations based on analysis2053. Highlight key decisions2064. Suggest optional additions2075. Provide save location and next steps208209### When Optimizing Existing CLAUDE.md2102111. Summarize issues found2122. Show before/after comparison for key sections2133. Present optimized full version2144. Quantify improvements (token savings %)2155. Suggest iteration approach216217**Detailed Templates:** @refs/output-templates.md218219## Common Mistakes to Avoid220221| Problem | Solution |222|---------|----------|223| **Over-Documentation** | Document project-specific decisions only |224| **Stale Information** | Verify against current package.json, files |225| **Redundant Context** | Link to README, add only unique patterns |226| **Token Waste** | On-demand context by functional area |227| **Generic Fluff** | Specific patterns: "Use Zod validation, Prisma transactions" |228229## Success Metrics230231### Effective CLAUDE.md232- Claude requires fewer clarifying questions233- Code matches project conventions on first try234- Commands work without errors235- User rarely provides missing context manually236237### Ineffective CLAUDE.md238- Claude frequently asks "what framework?"239- Generated code doesn't match existing style240- User repeatedly provides same context files241- CLAUDE.md contains info never referenced242243## Philosophy244245**Remember:**246- CLAUDE.md is a living document, not permanent documentation247- Start minimal, add based on actual friction points248- Remove guidance that doesn't improve Claude's output249- Measure effectiveness: fewer questions = better CLAUDE.md250251**When in doubt:**252- Prefer concise over comprehensive253- Prefer specific over generic254- Prefer examples over explanations255- Prefer on-demand over auto-loading256257## Reference Files258259- **@refs/initialization-workflow.md** - Complete guide for creating new CLAUDE.md files from scratch260- **@refs/optimization-patterns.md** - Techniques for reducing tokens and improving effectiveness261- **@refs/integration-strategies.md** - Integration with global config, MCP tools, slash commands262- **@refs/output-templates.md** - Standard formats for presenting results to users263264---265266**Quick Start:** When user requests CLAUDE.md creation/optimization, follow the decision tree above and consult relevant reference files for detailed instructions.