Codebase Viewer
Produces a structured codebase map — not a file listing but an annotated architecture view with entry points, dependency flow, test coverage, and danger zones.
Philosophy
Jumping into a new or unfamiliar codebase without a map is how hours disappear. File listings tell you what exists; this skill tells you what matters — where execution starts, where complexity accumulates, which corners have been skipped in testing, and which files will burn you. The output is a decision-ready orientation document, not a directory dump.
When to Use
- Onboarding to a codebase you haven't touched before
- Resuming work after a long gap on a project
- Before dispatching build agents so you scout first-hand (not off a spec)
- Code review or audit where you need structural context, not just diff hungers
- Identifying where to focus refactoring or test investment
- Any time someone asks "how does this repo fit together?"
Do NOT use for repos you know intimately and just need to read a single file — this skill is oriented toward whole-codebase orientation, not targeted lookup.
Workflow
1. TREE
Generate directory structure (2-3 levels deep) with role annotations:
- Each directory gets a one-line role description
- Mark directories as: source, test, config, docs, build, generated, vendored
- Flag empty directories and their likely purpose
- Respect .gitignore — skip node_modules, vendor, build outputs
2. ENTRY
Identify entry points — where execution begins:
main functions (Go, Rust, Python)
- CLI command handlers
- HTTP route registrations
- Event listeners and subscribers
- Scheduled task definitions
- Test suites (as secondary entry points)
3. DEPS
Map the dependency graph:
- External dependencies from go.mod / package.json / Cargo.toml / requirements.txt
- Internal package import relationships
- Circular dependency detection
- Heavyweight dependencies (large transitive dep trees)
4. TESTS
Scan for test coverage:
- Which packages/directories have test files
- Test-to-source ratio per directory
- Packages with zero tests (flag as risk)
- Test patterns in use (unit, integration, e2e, benchmark)
5. PATTERNS
Identify architectural patterns:
- Clean architecture / hexagonal / onion (ports-and-adapters)
- MVC / MVVM
- Microservice boundaries
- Monolith with internal module separation
- Event-driven / message-passing
- Repository pattern / service layer
6. DRAGONS
Flag areas of concern — severity-labeled:
- CRITICAL: Files >1000 lines, circular dependencies, hardcoded secrets
- WARNING: Files >500 lines, deeply nested code (>4 levels), TODO/FIXME density >5 per file
- INFO: No tests for package, outdated dependencies, unused imports
7. CONTRACTS
Identify interfaces and API boundaries:
- Go interfaces and their implementors
- HTTP API surface (routes, methods, request/response types)
- gRPC / protobuf definitions
- Event schemas
- Configuration contracts (env vars, config files)
8. REPORT
Produce structured codebase map as markdown:
- Header with repo name, language, size metrics
- Each section from above as a headed section
- Summary statistics table (files, lines, packages, test coverage %)
9. SUGGEST (optional, only if requested)
Based on findings, suggest 3 high-value improvements:
- Highest-risk dragon to address first
- Biggest test coverage gap
- Most impactful architectural improvement
Reading Rules
- For files >50KB: use Grep to find relevant sections, then read with offset/limit
- Never read files >200KB in one shot
- Check file size with wc -c before reading large files
- Prefer targeted reads over full-file reads for analysis
Common Pitfalls
- File listing ≠ architecture map. Don't just emit
ls -R output. Every section should add annotation, not just enumeration.
- Skipping the DRAGONS step. It's tempting to stop at the pretty tree. The danger-zone audit is often the most actionable output.
- Reading large files whole. A 3000-line file read entirely to find one entry point wastes context. Grep for
func main or the framework's router registration instead.
- Marking everything CRITICAL. Severity labels lose value if everything is red. Reserve CRITICAL for genuine hazards (hardcoded secrets, circular deps); use INFO liberally.
- Inventing test coverage numbers. If the tool can't count test files precisely, say "no test files found" rather than estimating a percentage.
Example
A Go microservice repo. The skill produces:
- TREE:
cmd/server/ (entry), internal/handler/ (HTTP layer), internal/store/ (DB), pkg/models/ (shared types), docs/ (OpenAPI specs)
- ENTRY:
cmd/server/main.go → registers HTTP router, loads config, starts listener
- DEPS: external —
chi, pgx, zap; no circular internal imports detected
- TESTS:
internal/handler/ has tests; internal/store/ has zero test files (flagged INFO)
- PATTERNS: Clean architecture — handler → service → store, no cross-layer imports
- DRAGONS:
internal/store/queries.go at 1,100 lines (CRITICAL); 3 TODO comments in internal/handler/auth.go (INFO)
The output is a single markdown document a new contributor can read in five minutes to understand the system.
Quality Checklist
Related Skills
convergence-checker — checks memory health and index freshness; useful after a codebase-viewer run reveals the local memory is stale
adr-writer — once the architecture is mapped, write ADRs for the key structural decisions found
scout-writer — produces targeted scouts into specific subsystems after the top-level map is done
1---2name: codebase-viewer3description: Structured codebase intelligence: directory tree with roles, entry points, dependency graph, test coverage map, and annotated 'here be dragons' warnings. Lean single-file variant — full version (adds a defined reading-order output): `continuous-learning:codebase-cartography`.4---56# Codebase Viewer78Produces a structured codebase map — not a file listing but an annotated architecture view with entry points, dependency flow, test coverage, and danger zones.910## Philosophy1112Jumping into a new or unfamiliar codebase without a map is how hours disappear. File listings tell you what exists; this skill tells you what matters — where execution starts, where complexity accumulates, which corners have been skipped in testing, and which files will burn you. The output is a decision-ready orientation document, not a directory dump.1314## When to Use1516- Onboarding to a codebase you haven't touched before17- Resuming work after a long gap on a project18- Before dispatching build agents so you scout first-hand (not off a spec)19- Code review or audit where you need structural context, not just diff hungers20- Identifying where to focus refactoring or test investment21- Any time someone asks "how does this repo fit together?"2223Do NOT use for repos you know intimately and just need to read a single file — this skill is oriented toward whole-codebase orientation, not targeted lookup.2425## Workflow2627### 1. TREE28Generate directory structure (2-3 levels deep) with role annotations:29- Each directory gets a one-line role description30- Mark directories as: source, test, config, docs, build, generated, vendored31- Flag empty directories and their likely purpose32- Respect .gitignore — skip node_modules, vendor, build outputs3334### 2. ENTRY35Identify entry points — where execution begins:36- `main` functions (Go, Rust, Python)37- CLI command handlers38- HTTP route registrations39- Event listeners and subscribers40- Scheduled task definitions41- Test suites (as secondary entry points)4243### 3. DEPS44Map the dependency graph:45- External dependencies from go.mod / package.json / Cargo.toml / requirements.txt46- Internal package import relationships47- Circular dependency detection48- Heavyweight dependencies (large transitive dep trees)4950### 4. TESTS51Scan for test coverage:52- Which packages/directories have test files53- Test-to-source ratio per directory54- Packages with zero tests (flag as risk)55- Test patterns in use (unit, integration, e2e, benchmark)5657### 5. PATTERNS58Identify architectural patterns:59- Clean architecture / hexagonal / onion (ports-and-adapters)60- MVC / MVVM61- Microservice boundaries62- Monolith with internal module separation63- Event-driven / message-passing64- Repository pattern / service layer6566### 6. DRAGONS67Flag areas of concern — severity-labeled:68- **CRITICAL**: Files >1000 lines, circular dependencies, hardcoded secrets69- **WARNING**: Files >500 lines, deeply nested code (>4 levels), TODO/FIXME density >5 per file70- **INFO**: No tests for package, outdated dependencies, unused imports7172### 7. CONTRACTS73Identify interfaces and API boundaries:74- Go interfaces and their implementors75- HTTP API surface (routes, methods, request/response types)76- gRPC / protobuf definitions77- Event schemas78- Configuration contracts (env vars, config files)7980### 8. REPORT81Produce structured codebase map as markdown:82- Header with repo name, language, size metrics83- Each section from above as a headed section84- Summary statistics table (files, lines, packages, test coverage %)8586### 9. SUGGEST (optional, only if requested)87Based on findings, suggest 3 high-value improvements:88- Highest-risk dragon to address first89- Biggest test coverage gap90- Most impactful architectural improvement9192## Reading Rules93- For files >50KB: use Grep to find relevant sections, then read with offset/limit94- Never read files >200KB in one shot95- Check file size with wc -c before reading large files96- Prefer targeted reads over full-file reads for analysis9798## Common Pitfalls99100- **File listing ≠ architecture map.** Don't just emit `ls -R` output. Every section should add annotation, not just enumeration.101- **Skipping the DRAGONS step.** It's tempting to stop at the pretty tree. The danger-zone audit is often the most actionable output.102- **Reading large files whole.** A 3000-line file read entirely to find one entry point wastes context. Grep for `func main` or the framework's router registration instead.103- **Marking everything CRITICAL.** Severity labels lose value if everything is red. Reserve CRITICAL for genuine hazards (hardcoded secrets, circular deps); use INFO liberally.104- **Inventing test coverage numbers.** If the tool can't count test files precisely, say "no test files found" rather than estimating a percentage.105106## Example107108A Go microservice repo. The skill produces:109- TREE: `cmd/server/` (entry), `internal/handler/` (HTTP layer), `internal/store/` (DB), `pkg/models/` (shared types), `docs/` (OpenAPI specs)110- ENTRY: `cmd/server/main.go` → registers HTTP router, loads config, starts listener111- DEPS: external — `chi`, `pgx`, `zap`; no circular internal imports detected112- TESTS: `internal/handler/` has tests; `internal/store/` has zero test files (flagged INFO)113- PATTERNS: Clean architecture — handler → service → store, no cross-layer imports114- DRAGONS: `internal/store/queries.go` at 1,100 lines (CRITICAL); 3 TODO comments in `internal/handler/auth.go` (INFO)115116The output is a single markdown document a new contributor can read in five minutes to understand the system.117118## Quality Checklist119120- [ ] Tree is annotated (each directory has a role label), not a bare listing121- [ ] Entry points section names specific files and symbols, not just "main files"122- [ ] Dependency section distinguishes external vs internal imports123- [ ] Test coverage section identifies packages with zero tests124- [ ] DRAGONS section uses severity labels (CRITICAL / WARNING / INFO) and is non-empty even if all items are INFO125- [ ] Architectural pattern named explicitly (even "no clear pattern detected" is valid)126- [ ] Report section includes at least: file count, directory count, identified entry points count127- [ ] No invented metrics — if a number can't be derived from actual file reads/greps, it is omitted128129## Related Skills130131- `convergence-checker` — checks memory health and index freshness; useful after a codebase-viewer run reveals the local memory is stale132- `adr-writer` — once the architecture is mapped, write ADRs for the key structural decisions found133- `scout-writer` — produces targeted scouts into specific subsystems after the top-level map is done