Code Analyzer
Analyze codebase to build comprehensive mental model for downstream operations.
Workflow Overview
- Scan — Collect facts via bash script (deterministic)
- Understand — Interpret structure and stack
- Build — Construct dependency graph and mental model
- Confirm — Ready for operations
Step 1: Scan Project
Run codebase scanner to collect facts:
.claude/skills/code-analyzer/scripts/scan-codebase.sh
Scanner auto-detects project root (git root or pwd) and collects:
- Structure: file count, extensions, configs, directories, src modules
- Markers: AICODE-NOTE, AICODE-TODO, AICODE-FIX with locations
- Git: branch, modified/added/deleted files
Outputs JSON. No external dependencies required.
Exclusions (automatic)
- node_modules, .git, dist, build
- pycache, .venv, venv
- ai-docs, .next, .nuxt, coverage, .cache
Step 2: Understand Structure
Interpret scan results to determine:
- Stack: Language(s) from extensions, framework from configs
- Entry points: Main/index/app files in directories
- Modules: Domain boundaries from src_modules or directories
- Conventions: Naming patterns, structure style
Step 3: Build Mental Model
Extract and internalize from scan results:
From structure:
- Stack:
[language] | [framework] | [build-tool]
- Entry points with types
- Module list with inferred domains
- Directory organization
From markers:
- AICODE-NOTE → Implementation context (why decisions were made)
- AICODE-TODO → Planned work (incomplete areas)
- AICODE-FIX → Known issues (from previous reviews)
From git:
- Current branch → feature context
- Changed files → review/focus scope
From reading key files:
- Import patterns → dependency relationships
- Shared modules → components with 3+ incoming connections
- Circular dependencies → architectural issues
Step 4: Confirm Readiness
Output minimal confirmation:
✅ Code context loaded: [project-name]
Stack: [language] | [framework]
Modules: [count] ([list])
Markers: [N] NOTE, [N] TODO, [N] FIX
Ready for: review | documentation | agent-generation
Error Handling
- Empty project: Report "No source files found"
- No git repo: Continue without git section (is_repo: false)
- Permission denied: Report file, continue with available
Usage Notes
This skill prepares context for:
- Code review (scope, markers, dependencies)
- Documentation generation (structure, stack)
- Agent creation (domains, boundaries)
- Architecture queries
Context remains in memory for entire conversation.
1---2name: code-analyzer-33description: Comprehensive codebase analysis for building mental model of project structure, dependencies, and implementation context. Use when needing to: (1) Understand project architecture before review or documentation, (2) Find dependencies and shared modules, (3) Locate implementation markers (AICODE-*), (4) Prepare context for review, memory generation, or agent creation. Triggers on: analyze code, load code context, scan codebase, understand project structure.4---5
6# Code Analyzer
7
8Analyze codebase to build comprehensive mental model for downstream operations.
9
10## Workflow Overview
11
121. **Scan** — Collect facts via bash script (deterministic)
132. **Understand** — Interpret structure and stack
143. **Build** — Construct dependency graph and mental model
154. **Confirm** — Ready for operations
16
17## Step 1: Scan Project
18
19Run codebase scanner to collect facts:
20
21```bash
22.claude/skills/code-analyzer/scripts/scan-codebase.sh
23```
24
25Scanner auto-detects project root (git root or pwd) and collects:
26- Structure: file count, extensions, configs, directories, src modules
27- Markers: AICODE-NOTE, AICODE-TODO, AICODE-FIX with locations
28- Git: branch, modified/added/deleted files
29
30Outputs JSON. No external dependencies required.
31
32### Exclusions (automatic)
33- node_modules, .git, dist, build
34- __pycache__, .venv, venv
35- ai-docs, .next, .nuxt, coverage, .cache
36
37## Step 2: Understand Structure
38
39Interpret scan results to determine:
40- **Stack**: Language(s) from extensions, framework from configs
41- **Entry points**: Main/index/app files in directories
42- **Modules**: Domain boundaries from src_modules or directories
43- **Conventions**: Naming patterns, structure style
44
45## Step 3: Build Mental Model
46
47Extract and internalize from scan results:
48
49**From structure:**
50- Stack: `[language] | [framework] | [build-tool]`
51- Entry points with types
52- Module list with inferred domains
53- Directory organization
54
55**From markers:**
56- AICODE-NOTE → Implementation context (why decisions were made)
57- AICODE-TODO → Planned work (incomplete areas)
58- AICODE-FIX → Known issues (from previous reviews)
59
60**From git:**
61- Current branch → feature context
62- Changed files → review/focus scope
63
64**From reading key files:**
65- Import patterns → dependency relationships
66- Shared modules → components with 3+ incoming connections
67- Circular dependencies → architectural issues
68
69## Step 4: Confirm Readiness
70
71Output minimal confirmation:
72```
73✅ Code context loaded: [project-name]
74 Stack: [language] | [framework]
75 Modules: [count] ([list])
76 Markers: [N] NOTE, [N] TODO, [N] FIX
77 Ready for: review | documentation | agent-generation
78```
79
80## Error Handling
81
82- **Empty project**: Report "No source files found"
83- **No git repo**: Continue without git section (is_repo: false)
84- **Permission denied**: Report file, continue with available
85
86## Usage Notes
87
88This skill prepares context for:
89- Code review (scope, markers, dependencies)
90- Documentation generation (structure, stack)
91- Agent creation (domains, boundaries)
92- Architecture queries
93
94Context remains in memory for entire conversation.