From claude-stack
Generate structured codebase documentation - file tree, dependency graph, module responsibilities, entry points
How this skill is triggered — by the user, by Claude, or both
Slash command
/claude-stack:s-mapThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Scan the project and generate a structured architectural overview. Produces a living document that helps orient anyone (human or AI) in the codebase.
Scan the project and generate a structured architectural overview. Produces a living document that helps orient anyone (human or AI) in the codebase.
Read the project's file tree, respecting .gitignore rules:
node_modules/, .git/, dist/, build/, .next/, __pycache__/, venv/)package.json, Cargo.toml, pyproject.toml, go.mod, pom.xml, etc.packages/, apps/, services/, workspace configsDisplay progress:
[MAP] Scanning project structure...
[MAP] Found {N} files across {M} directories
[MAP] Primary languages: {list}
[MAP] Project type: {monorepo|single-package|library|app}
Identify all technologies in use:
| Category | Detection Method |
|---|---|
| Language | File extensions (.ts, .py, .rs, .go) |
| Framework | Config files (next.config., vite.config., django settings) |
| Database | Migration files, ORM configs, schema files |
| Testing | Test runner configs (jest, vitest, pytest, cargo test) |
| CI/CD | .github/workflows/, Dockerfile, docker-compose.yml |
| Linting | .eslintrc, .prettierrc, ruff.toml, .rubocop.yml |
| Package mgr | package-lock.json, yarn.lock, pnpm-lock.yaml, Pipfile.lock |
Output a tech stack summary table.
Create an annotated file tree. For each key directory and file, add a brief description:
project/
src/
api/ # API route handlers
routes/ # Express/Next.js route definitions
middleware/ # Auth, validation, error handling
components/ # React UI components
ui/ # Shared/primitive components
features/ # Feature-specific components
lib/ # Shared utilities and helpers
db/ # Database access layer
migrations/ # Schema migrations
models/ # ORM models / type definitions
__tests__/ # Test files
public/ # Static assets
scripts/ # Build and dev scripts
Rules for annotation:
Analyze import/require statements to build a module dependency graph:
Output format - adjacency list:
Module Dependencies:
src/api/routes → src/db/models, src/lib/auth, src/lib/validation
src/components/features → src/components/ui, src/lib/api-client
src/db/models → src/lib/types
CIRCULAR: src/lib/auth → src/db/models → src/lib/auth
For large projects, show only top-level module relationships, not file-by-file.
For each top-level module/directory, identify its single responsibility:
| Module | Responsibility | Key Files | Depends On |
|---|---|---|---|
src/api/ | HTTP request handling and routing | routes/*.ts, middleware/*.ts | db, lib |
src/db/ | Data persistence and queries | models/*.ts, migrations/*.sql | lib/types |
src/components/ | UI rendering and interaction | *.tsx | lib/api-client |
src/lib/ | Shared utilities and types | auth.ts, validation.ts | (none) |
Flag modules that seem to have multiple responsibilities (possible refactoring target).
Find all entry points into the application:
| Type | File | Purpose |
|---|---|---|
| App entry | src/index.ts | Main application start |
| API routes | src/api/routes/*.ts | HTTP endpoints |
| CLI commands | src/cli/*.ts | Command-line interface |
| Background jobs | src/jobs/*.ts | Scheduled/queued tasks |
| Tests | src/__tests__/*.test.ts | Test entry points |
| Config | next.config.js | Framework configuration |
| Scripts | scripts/*.sh | Build/deploy scripts |
Identify which modules have tests and which don't:
Test Coverage Map:
[TESTED] src/api/routes/ → src/__tests__/api/
[TESTED] src/lib/auth.ts → src/__tests__/lib/auth.test.ts
[TESTED] src/db/models/ → src/__tests__/db/
[UNTESTED] src/components/ui/ → no test files found
[UNTESTED] src/lib/validation → no test files found
[PARTIAL] src/api/middleware/ → 2/5 files have tests
Calculate overall coverage estimate:
Estimated coverage: {N}% of modules have corresponding test files
Tested modules: {X}/{Y}
Untested modules: {list}
Identify potential architectural issues:
List any circular import chains found in Step 4.
Files that are never imported by any other file (and are not entry points).
Files exceeding 300 lines that might need splitting.
Modules with no corresponding test files (from Step 7).
Directories containing files with very different purposes.
Files not modified in 6+ months (check git log) that might be dead code.
Format:
Concerns:
[CIRCULAR] auth ↔ models circular dependency
[ORPHAN] src/lib/old-utils.ts - never imported
[LARGE] src/api/routes/users.ts - 450 lines
[UNTESTED] src/components/ui/ - 8 components, 0 tests
[MIXED] src/lib/ - contains both utils AND types AND config
Save the complete analysis to docs/ARCHITECTURE.md:
Structure:
# Architecture Overview
Generated: {YYYY-MM-DD}
## Tech Stack
{table from Step 2}
## File Structure
{annotated tree from Step 3}
## Module Map
{responsibility table from Step 5}
## Entry Points
{table from Step 6}
## Dependencies
{graph from Step 4}
## Test Coverage
{map from Step 7}
## Concerns
{flags from Step 8}
If docs/ARCHITECTURE.md already exists, UPDATE it rather than overwriting. Preserve any manually-added sections.
Display a concise summary to the user:
[MAP] Codebase analysis complete.
[MAP] Saved to: docs/ARCHITECTURE.md
[MAP]
[MAP] Quick stats:
[MAP] Files: {N} | Directories: {M} | Languages: {list}
[MAP] Modules: {N} | Entry points: {M}
[MAP] Test coverage: ~{N}% of modules
[MAP] Concerns: {N} issues found
[MAP]
[MAP] Top concerns:
[MAP] 1. {most important concern}
[MAP] 2. {second concern}
[MAP] 3. {third concern}
/s:brainstorm (understand before you design) and /s:review (architecture checks)npx claudepluginhub bdarbaz/claude-stack-pluginOrchestrates parallel subagents to map any codebase, creating docs/CODEBASE_MAP.md with architecture, file roles, dependencies, and navigation. Updates incrementally via git or scans.