| name | analyze-codebase |
| description | Generate comprehensive codebase analysis covering architecture, security, performance, and code quality. Use when user says 'analyze codebase', 'code audit', 'architecture review', or 'project health check'. |
| metadata | {"version":"1.0.0","tags":"analysis, architecture, documentation, onboarding"} |
Analyze Codebase
When to Use
- Onboarding new developers
- Architecture documentation
- Project health assessment
- Before major refactoring
- Understanding system complexity
Analysis Process
Step 1: Discovery
tree -L 3 -I 'node_modules|.next|dist|build|coverage'
find . -type f -name "*.ts" | wc -l
find . -type f -name "*.tsx" | wc -l
Step 2: Architecture Analysis
- Identify modules, entry points, API structure
- Map frontend components and routing
- Document service patterns and conventions
Step 3: Patterns and Standards
- Check for established patterns in docs/examples
- Analyze type system organization
- Review security patterns (auth, multi-tenancy, soft delete)
Step 4: Dependencies
- Catalog external services and libraries
- Check version currency
- Identify critical dependencies
Step 5: Generate Report
Write to .agents/memory/codebase-analysis.md with these sections:
- Executive Summary — 3-5 sentence overview
- Project Overview — Tech stack, purpose, architecture style
- Directory Structure — Module layout and organization
- Architecture Patterns — Backend and frontend patterns
- Security Analysis — Auth, data isolation, validation
- Performance Insights — Database, caching, background jobs
- Code Quality — Strengths, improvements, tech debt
- Dependencies — Critical packages and version matrix
- Testing Strategy — Coverage, patterns, gaps
- Recommendations — Immediate, short-term, long-term
Quick Mode
For faster analysis (skip detailed metrics):
tree -L 3 -I 'node_modules|.next|dist'
echo "TypeScript: $(find . -name '*.ts' -o -name '*.tsx' | wc -l)"
echo "Controllers: $(find . -name '*.controller.ts' | wc -l)"
echo "Services: $(find . -name '*.service.ts' | wc -l)"