codebase-mapper
Generate a deterministic architecture map of Python, C#, and TypeScript codebases using AST parsing. Outputs a token-efficient structure section for CLAUDE.md. Use when mapping a codebase, generating architecture documentation, updating claude.md structure, or onboarding to a new project.
Best use case
codebase-mapper is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Generate a deterministic architecture map of Python, C#, and TypeScript codebases using AST parsing. Outputs a token-efficient structure section for CLAUDE.md. Use when mapping a codebase, generating architecture documentation, updating claude.md structure, or onboarding to a new project.
Teams using codebase-mapper should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/codebase-mapper/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How codebase-mapper Compares
| Feature / Agent | codebase-mapper | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Generate a deterministic architecture map of Python, C#, and TypeScript codebases using AST parsing. Outputs a token-efficient structure section for CLAUDE.md. Use when mapping a codebase, generating architecture documentation, updating claude.md structure, or onboarding to a new project.
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
Related Guides
AI Agents for Coding
Browse AI agent skills for coding, debugging, testing, refactoring, code review, and developer workflows across Claude, Cursor, and Codex.
Best AI Skills for Claude
Explore the best AI skills for Claude and Claude Code across coding, research, workflow automation, documentation, and agent operations.
SKILL.md Source
# Codebase Structure Mapper Deterministically parse Python, C#, and TypeScript codebases to extract structural maps (namespaces, classes, methods, inheritance, dependencies) and output a concise, token-efficient architecture section for CLAUDE.md. --- ## Why This Skill? - **Zero AI tokens for parsing** — Pure script execution using AST parsers - **Deterministic & repeatable** — Same code = same output, version-controllable - **Token-efficient output** — Compact format optimized for LLM consumption - **Marker-based updates** — Preserves hand-written CLAUDE.md sections --- ## Workflow | Phase | Name | Description | |-------|------|-------------| | 1 | DETECT | Auto-detect project languages and entry points | | 2 | PARSE | Run appropriate AST-based mapper scripts | | 3 | MERGE | Insert/update map in CLAUDE.md with markers | | 4 | REPORT | Display summary and token count | --- ## Phase 1: DETECT ### Identify Project Languages Scan for language indicators: | Language | Detection Files | |----------|-----------------| | Python | `*.py`, `pyproject.toml`, `requirements.txt`, `setup.py` | | C# | `*.cs`, `*.csproj`, `*.sln` | | TypeScript | `*.ts`, `*.tsx`, `tsconfig.json` | ```bash # Count files by type find . -name "*.py" -type f | wc -l find . -name "*.cs" -type f | wc -l find . -name "*.ts" -o -name "*.tsx" -type f | wc -l ``` ### Identify Source Roots Look for common source directory patterns: - Python: `src/`, `app/`, `<project_name>/` - C#: `src/`, solution folder structure from `.sln` - TypeScript: `src/`, `lib/`, `app/` --- ## Phase 2: PARSE Run the appropriate mapper scripts based on detected languages. ### Python Projects ```bash python scripts/map_python.py --root ./src --output /tmp/map_python.md ``` **What it extracts:** - Modules and packages - Classes with base classes - Public methods and their signatures - Key decorators (`@app.route`, `@property`, `@staticmethod`) - Module-level functions - Import dependencies (FastAPI, Django, Flask, SQLAlchemy detection) ### C# Projects ```bash python scripts/map_csharp.py --root ./src --output /tmp/map_csharp.md ``` **What it extracts:** - Namespaces - Classes, interfaces, enums, records - Inheritance and interface implementations - Public methods and properties - Key attributes (`[ApiController]`, `[HttpGet]`, `[Authorize]`) - Using statements for dependency detection ### TypeScript Projects ```bash python scripts/map_typescript.py --root ./src --output /tmp/map_typescript.md ``` **What it extracts:** - Modules and exports - Classes with inheritance - Interfaces and types - Functions (exported and module-level) - React components (function and class-based) - Key decorators (Angular `@Component`, `@Injectable`, etc.) --- ## Phase 3: MERGE Use the update script to merge maps into CLAUDE.md: ```bash python scripts/update_claude_md.py \ --claude-md ./CLAUDE.md \ --maps /tmp/map_python.md /tmp/map_csharp.md /tmp/map_typescript.md ``` ### Marker System The script uses markers to preserve hand-written sections: ```markdown <!-- CODEBASE-MAP:AUTO-START --> ## Architecture Map [Auto-generated content here] <!-- CODEBASE-MAP:AUTO-END --> ``` - If markers exist: Replace content between them - If no markers: Append after `## Project Context` section - Hand-written sections outside markers are preserved --- ## Phase 4: REPORT Display summary: ``` Codebase Map Generated ====================== Languages: Python, C# Files scanned: 142 Classes mapped: 47 Methods mapped: 312 Output added to CLAUDE.md Token estimate: ~450 tokens Markers: <!-- CODEBASE-MAP:AUTO-START/END --> Re-run this skill anytime to update. ``` --- ## Output Format Compact, scannable format optimized for LLM consumption: ```markdown <!-- CODEBASE-MAP:AUTO-START --> ## Architecture Map ### Python: src/ - `api/` — FastAPI REST endpoints - `routes/users.py`: `UserRouter` → get_user(), create_user(), update_user() - `routes/orders.py`: `OrderRouter` → list_orders(), create_order() - `models/` — SQLAlchemy ORM models - `user.py`: `User(Base)` — id, email, name, created_at - `order.py`: `Order(Base)` — id, user_id, total, status ### C#: src/MyApp/ - `MyApp.Api` — ASP.NET Core Web API - `Controllers/UserController.cs`: `UserController : ControllerBase` → Get(), Post(), Put() - `MyApp.Core` — Domain models and interfaces - `Models/User.cs`: `User` — Id, Email, Name, CreatedAt - `Interfaces/IUserRepository.cs`: `IUserRepository` → GetByIdAsync(), CreateAsync() ### TypeScript: src/ - `components/` — React components - `UserCard.tsx`: `UserCard` (FC) — props: user, onSelect - `OrderList.tsx`: `OrderList` (FC) — props: orders, loading - `services/` — API clients - `userService.ts`: fetchUser(), createUser(), updateUser() <!-- CODEBASE-MAP:AUTO-END --> ``` --- ## Configuration Options ### Depth Control Control output verbosity via `--depth` flag: | Depth | Output | |-------|--------| | `classes` | Namespaces and classes only | | `methods` | Classes + public methods (default) | | `full` | Classes + methods + properties + private members | ```bash python scripts/map_python.py --root ./src --depth classes ``` ### Exclusions Exclude directories via `--exclude`: ```bash python scripts/map_python.py --root ./src --exclude tests,migrations,__pycache__ ``` Default exclusions: `node_modules`, `bin`, `obj`, `.git`, `__pycache__`, `venv`, `.venv` --- ## Integration with /ai-plugins-and-skills-init This skill can be invoked automatically during `/ai-plugins-and-skills-init`: 1. After CLAUDE.md is generated, user is asked: "Generate codebase architecture map?" 2. If yes, this skill runs and inserts the map section 3. The map updates whenever this skill is re-run To manually invoke after init: ``` Using the codebase-mapper skill, generate an architecture map for this project ``` --- ## Script Locations Scripts are located in `scripts/` relative to this skill: | Script | Purpose | |--------|---------| | `map_python.py` | Python AST-based structure extractor | | `map_csharp.py` | C# structure extractor (regex-based) | | `map_typescript.py` | TypeScript structure extractor | | `update_claude_md.py` | Merges map output into CLAUDE.md | All scripts use Python stdlib only (no external dependencies). --- ## Troubleshooting ### "No source files found" - Verify source root directory is correct - Check that file extensions match expected patterns ### "CLAUDE.md not found" - Run `/ai-plugins-and-skills-init` first to create CLAUDE.md - Or specify path: `--claude-md ./path/to/CLAUDE.md` ### "Parse errors in file X" - Script continues on parse errors, logs warning - Check for syntax errors in source file - Non-UTF8 files are skipped with warning
Related Skills
codebase-cleanup-tech-debt
You are a technical debt expert specializing in identifying, quantifying, and prioritizing technical debt in software projects. Analyze the codebase to uncover debt, assess its impact, and create acti
codebase-analyzer
Understand existing codebase patterns and context to inform feature judgement.
Codebase Analyzer Skill
Analyze existing code to reverse-engineer specifications (requirements, design, tasks). Use when user wants to document existing code, refactor legacy systems, or understand what has been implemented. Identifies implemented features, architecture, and missing pieces.
codebase-analysis
Systematically analyze codebase structure, complexity, dependencies, and architectural patterns to understand project organization
assess-codebase
Assess a codebase for patterns, anti-patterns, and quality opportunities; use when asked to generate coding rules, standards, or quality guidelines.
analyzing-unknown-codebases
Analyze unfamiliar codebases systematically to produce subsystem catalog entries - emphasizes strict contract compliance and confidence marking
analyzing-codebases
Generates LLM-optimized code context with function call graphs, side effect detection, and incremental updates. Processes JavaScript/TypeScript codebases to create compact semantic representations including multi-level summaries, entry point identification, and hash-based change tracking. Provides 74-97% token reduction compared to reading raw source files. Useful for understanding code architecture, debugging complex systems, reviewing pull requests, and onboarding to unfamiliar projects.
analyze-codebase
Analyze a codebase to generate a comprehensive architecture and structure report. Use when user wants to understand a codebase, explore project structure, or generate analysis.
ado-mapper
Bidirectional conversion between SpecWeave increments and Azure DevOps work items. Use when exporting increments to ADO epics, importing ADO epics as increments, or resolving sync conflicts. Handles Epic/Feature/User Story/Task hierarchy mapping.
codebase-cleanup-refactor-clean
You are a code refactoring expert specializing in clean code principles, SOLID design patterns, and modern software engineering best practices. Analyze and refactor the provided code to improve its...
deep-codebase-analysis
Agent capable of reading and analyzing the entire source code of a software project to gain a thorough understanding of architecture, communication, design patterns, and business flows. Use when exploring new systems, maintenance, or refactoring.
Codebase context
Create a lightweight codebase_context.md that anchors the idea in the existing repo (modules, constraints, extension points). Generic framework prompt.