Analyze codebase architecture with mode support
Analyzes codebase architecture patterns, dependencies, and structure with multiple analysis modes.
/plugin marketplace add Data-Wise/craft/plugin install data-wise-craft@Data-Wise/craftarch/Analyze codebase architecture patterns, dependencies, and structure.
| Mode | Time | Focus |
|---|---|---|
| default | < 15s | Quick overview |
| debug | < 120s | Deep dive, all patterns |
| optimize | < 180s | Performance hotspots |
| release | < 300s | Full architectural audit |
/craft:arch:analyze # Quick overview (default)
/craft:arch:analyze debug # Deep pattern analysis
/craft:arch:analyze optimize # Performance architecture
/craft:arch:analyze release # Full audit
/craft:arch:analyze debug src/ # Analyze specific directory
| Area | What's Analyzed |
|---|---|
| Structure | Directory layout, module organization |
| Dependencies | Import graphs, coupling metrics |
| Patterns | MVC, microservices, layers, etc. |
| Data Flow | How data moves through the system |
| Complexity | Cyclomatic complexity, nesting depth |
Output:
╭─ Architecture Overview ─────────────────────────────╮
│ Project: aiterm | Type: Python CLI │
│ Structure: src/aiterm/ (6 modules) │
├─────────────────────────────────────────────────────┤
│ cli/ terminal/ context/ claude/ opencode/ utils/ │
├─────────────────────────────────────────────────────┤
│ Health: Good | Dependencies: 4 external, 6 internal│
╰─────────────────────────────────────────────────────╯
Output:
╭─ Architecture Analysis (Debug Mode) ────────────────╮
│ STRUCTURE │
│ src/aiterm/ │
│ ├── cli/ (entry point, commands) │
│ ├── terminal/ (backends, detection) │
│ ├── context/ (project detection) │
│ └── claude/ (Claude Code integration) │
│ │
│ PATTERNS DETECTED │
│ ✓ Strategy Pattern - terminal backends │
│ ✓ Factory Pattern - detector creation │
│ ⚠ God Class - main.py (consider splitting) │
│ │
│ DEPENDENCIES │
│ cli/ ──→ terminal/ ──→ context/ │
│ └──→ claude/ │
╰─────────────────────────────────────────────────────╯
Output:
╭─ Architecture Analysis (Optimize Mode) ─────────────╮
│ IMPORT PERFORMANCE │
│ rich 234ms ████████████████ │
│ typer 156ms ██████████ │
│ yaml 89ms ██████ │
│ │
│ HOT PATHS │
│ 1. detector.py:detect_context() - 45ms avg │
│ 2. settings.py:load_settings() - File I/O │
│ │
│ SUGGESTIONS │
│ • Cache context detection result │
│ • Lazy load heavy modules │
│ • Estimated startup improvement: 40% │
╰─────────────────────────────────────────────────────╯
Output:
╭─ Architecture Audit (Release Mode) ─────────────────╮
│ Status: ⚠ MINOR ISSUES (3) │
├─────────────────────────────────────────────────────┤
│ METRICS │
│ Cyclomatic Avg 4.2 < 10 ✓ │
│ Max Func Size 45 < 50 ✓ │
│ Test Coverage 83% > 80% ✓ │
│ Circular Deps 0 = 0 ✓ │
├─────────────────────────────────────────────────────┤
│ ISSUES │
│ ⚠ cli/main.py has 15 functions (split?) │
│ ⚠ Missing docstrings in utils/ (5 funcs) │
├─────────────────────────────────────────────────────┤
│ QUALITY SCORE: 91/100 │
╰─────────────────────────────────────────────────────╯
--depth <N> - Analysis depth (1=shallow, 3=deep)--focus <area> - Focus on specific area--report - Generate detailed report--json - Output as JSONWorks with:
/craft:arch:plan - Design planning/craft:arch:review - Architecture review/craft:arch:diagram - Generate diagrams/craft:code:refactor - Implement changes