9thlevelsoftware/legion/codebase-mapper
- community
- ext:[{"type":"config","description":"Configuration overrides"}]
Checking that the SKILL.md file is still in the repository.
Engine for /legion:map. Analyzes an existing codebase, generates CODEBASE.md for backward-compatible architecture context, and writes .planning/codebase/ index artifacts consumed by /legion:start, /plan, /build, /review, /status, and /quick.
Install
npx vskill@latest install 9thlevelsoftware/legion/codebase-mapperSemi-extensibleMentions customization, but needs skill-specific knowledge. Read the extensible skills standard
SKILL.md
Codebase Mapper
Codebase mapping engine for Legion. /legion:map is the canonical entry point. It analyzes existing codebases to produce a structured map of architecture, functionality, ownership, patterns, frameworks, risk areas, dependency graphs, test coverage, API surface, config/environment, and code patterns.
The backward-compatible human artifact remains .planning/CODEBASE.md. The full map dataset also includes machine-readable retrieval artifacts under .planning/codebase/:
.planning/codebase/index.jsonl— chunk-level semantic index for LLM-assisted search..planning/codebase/symbols.json— coarse symbols, entry points, APIs, tests, config, dependencies, and ownership areas..planning/codebase/search.md— consumer protocol for semantic search/readback..planning/config/directory-mappings.yaml— directory placement and validation mappings.
Consumers include /legion:start (pre-start map freshness check), /legion:plan (relevant map chunk retrieval and risk cross-reference), /legion:build (agent prompt enrichment), /legion:review (convention and risk checking), /legion:status (freshness detection), and /legion:quick (routing codebase-analysis requests to /legion:map).
All operations use Read, Bash, Glob, and Grep -- no external dependencies, no custom scripts, no MCP servers. The analysis is the host model reading and reasoning over files using a structured protocol.
References:
- State File Locations from
workflow-common.md(state paths, degradation pattern) - Codebase Map Conventions from
workflow-common.md(lifecycle, paths, integration points) /legion:mapinmap.md(canonical command entry point)/legion:startinstart.md(source detection and user-approved map pre-flight)/legion:planinplan.md(map retrieval and CODEBASE.md context injection during phase decomposition)/legion:buildinbuild.md(agent context injection via wave-executor Step 3.5)/legion:reviewinreview.md(convention checking via review-loop Step 2.5)/legion:plan(critique) inskills/plan-critique/SKILL.md(risk cross-reference)/legion:statusinstatus.md(staleness detection)/legion:quickinquick.md(routes analyze-codebase tasks to/legion:map)
Section 1: Principles & Detection
Core rules governing codebase mapping and the detection heuristic that determines when to run.
Principles
- Opt-in only -- codebase mapping is never automatic outside an explicit
/legion:mapinvocation./legion:startalways asks via AskUserQuestion before generating or refreshing a map. No background scanning, no silent analysis. - Backward-compatible markdown --
.planning/CODEBASE.mdremains the human-readable architecture document consumed by older workflows. - Structured retrieval artifacts --
.planning/codebase/index.jsonl,.planning/codebase/symbols.json, and.planning/codebase/search.mdare generated alongside CODEBASE.md so commands can retrieve relevant chunks instead of injecting the whole map. - No embeddings or external services -- semantic search is LLM-consumable metadata plus
rg/Read over JSONL and source files. Do not require API keys, vector databases, or network services. - Graceful degradation -- every consumer checks for map artifact existence before using it. If absent, the workflow proceeds identically to greenfield mode. Mapping is an enhancement, never a requirement.
- Heuristic-based -- all detection uses file presence, content grep, manifest parsing, and sampled reads, not mandatory AST/LSP analysis.
- Depth-limited -- analysis constrains itself to avoid consuming the context window on large codebases. Work with counts, representative chunks, and summaries instead of full enumeration.
- Calibrated scoring -- risk levels use per-file rates relative to project size, not absolute counts. A 5-file project with 10 TODOs is HIGH; a 500-file project with 10 TODOs is LOW.
When to Run
- Triggered explicitly by
/legion:map - Checked by
/legion:startwhen existing source code is detected in the project directory - Can be re-triggered manually with
/legion:map --refreshif the codebase has changed significantly - NEVER runs as an unannounced background scan --
/legion:startasks via AskUserQuestion before generating or refreshing the map - If a complete map dataset exists, is <=30 days old, and its source fingerprint matches, treat it as fresh
- If CODEBASE.md exists but
.planning/codebase/artifacts are missing, treat the dataset as partial and recommend/legion:map --refresh
Source Code Detection Heuristic
Check for non-Legion files in the current directory. Run these checks in order:
Decision logic:
- If ANY of the above are found: existing codebase detected. Proceed to AskUserQuestion.
- If NONE found: pure greenfield. Skip codebase mapping silently.
- If ONLY .md files found: content project, not a codebase. Skip codebase mapping silently.
Constants
Graceful Degradation
- If CODEBASE.md does not exist: all consumers skip map context silently unless the command is
/legion:map --query - If
.planning/codebase/artifacts are missing but CODEBASE.md exists: fall back to CODEBASE.md only and recommend/legion:map --refresh - If the map is stale (>30 days or fingerprint mismatch): consumers warn but do not block
- Never error, never block, never require mapping for workflow completion outside
/legion:map - All workflows function identically to their pre-map behavior when map artifacts are absent
Section 2: Map Generation (MAP-CORE-01)
Building the structural map of the codebase. This section produces the file tree, language distribution, entry points, and module structure that form the foundation of CODEBASE.md.
2.1: File Tree Summary
Generate a depth-limited directory tree, excluding noise directories and files:
Large codebase handling:
- Count entries at depth 2. If >500 entries: reduce to
maxdepth 1 - For depth-1 results, add per-directory file counts:
``bash # Count files per top-level directory for dir in $(find . -maxdepth 1 -type d -not -name '.git' -not -name 'node_modules' -not -name '.planning' -not -name '.claude'); do echo "$dir: $(find "$dir" -type f | wc -l) files" done ``
- Never enumerate every file in a directory -- summarize by count
2.2: Language Distribution
Count files by extension to understand the language composition:
Output format:
| Extension | File Count | % of Codebase | |
|---|---|---|---|
| .ts | 47 | 38% | |
| .md | 23 | 19% | |
| .js | 15 | 12% |
Extension detection approach:
- Run
find . -type f -not -path './.git/*' -not -path './node_modules/*' -not -path './.planning/*' -not -path './.claude/*' -not -name '*.lock'via Bash - Extract extensions, count occurrences, sort by frequency
- Filter to extensions with >= 2 files
2.3: Entry Points
Identify project entry points by checking for known patterns:
| Ecosystem | Entry Point Indicators | |
|---|---|---|
| Node.js | package.json fields: main, module, bin, scripts.start | |
| Python | __main__.py, manage.py, app.py, main.py, wsgi.py | |
| Ruby | config.ru, bin/rails, Rakefile | |
| Go | main.go in root, cmd/ directory with main.go files | |
| Rust | src/main.rs, src/lib.rs | |
| Java | src/main/java/**/Application.java, pom.xml | |
| Generic | src/index.*, app/main.*, Makefile targets |
Detection protocol:
- Check for each indicator file using Glob
- For
package.json: Read and extractmain,module,binfields - For
Makefile: Read first 20 lines to find target names - Record each found entry point with its path and type
Output format:
| Type | Path | Evidence | |
|---|---|---|---|
| npm main | src/index.ts | package.json "main" field | |
| CLI | bin/cli.js | package.json "bin" field | |
| Makefile | Makefile | build and serve targets |
2.4: Module Structure
Detect how the codebase is organized by examining directory layout:
| Structure Type | Detection Heuristic | |
|---|---|---|
| Monorepo | Multiple package.json or go.mod files in subdirectories; packages/, apps/, or workspaces in root manifest | |
| Flat | All source in root directory or single src/ directory with no subdirectories | |
| Domain-driven | Directories named by business domain (e.g., users/, billing/, orders/) | |
| MVC | controllers/, models/, views/ directories present | |
| Component-based | components/, modules/, features/ directories present | |
| Layered | api/, services/, repositories/ (or data/) directories present | |
| Clean Architecture | domain/, application/, infrastructure/ directories present |
Detection protocol:
- List top-level and second-level directories using Glob
- Match directory names against heuristic patterns above
- If multiple patterns match, report the most specific one
- Use directory name heuristics only -- do not read every file
Output: Single line describing detected structure type with evidence. Example:
2.5: Directory Mapping Extraction (ENV-01, ENV-02)
Automatically identifies standard directory locations based on codebase structure and conventions.
2.5.1: Standard Category Detection
Detect these standard categories by examining directory structure:
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 95 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/codebase-mapper/SKILL.md
Popularity
- Repository stars
- 76
- Repository forks
- 9
- Repository npm downloads, 7 days
- 108
- 7-day trend score
- 33
Stars and forks are for the whole GitHub repository, not this skill alone. Downloads are for the repository's npm package. Refreshed 11 Sep 2026, a month ago.
Extension points
configConfiguration overrides
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/9thlevelsoftware/legion/codebase-mapper)