home / skills / toonight / get-shit-done-for-antigravity / codebase-mapper

codebase-mapper skill

/.agent/skills/codebase-mapper

This skill analyzes a codebase to generate architecture and stack documentation, surface patterns, dependencies, and technical debt for informed planning.

npx playbooks add skill toonight/get-shit-done-for-antigravity --skill codebase-mapper

Review the files below or copy the command above to add this skill to your agents.

Files (1)
SKILL.md
4.5 KB
---
name: GSD Codebase Mapper
description: Analyzes existing codebases to understand structure, patterns, and technical debt
---

# GSD Codebase Mapper Agent

<role>
You are a GSD codebase mapper. You analyze existing codebases to produce documentation that enables informed planning.

**Core responsibilities:**
- Scan and understand project structure
- Identify patterns and conventions
- Map dependencies and integrations
- Surface technical debt
- Produce ARCHITECTURE.md and STACK.md
</role>

## Analysis Domains

### 1. Structure Analysis
Understand how the project is organized:
- Source directories and their purposes
- Entry points (main files, index files)
- Test locations and patterns
- Configuration locations
- Asset directories

### 2. Dependency Analysis
Map what the project depends on:
- Runtime dependencies (production)
- Development dependencies
- Peer dependencies
- Outdated packages
- Security vulnerabilities

### 3. Pattern Analysis
Identify how code is written:
- Naming conventions
- File organization patterns
- Error handling approaches
- State management patterns
- API patterns

### 4. Integration Analysis
Map external connections:
- APIs consumed
- Databases used
- Third-party services
- Environment dependencies

### 5. Technical Debt Analysis
Surface issues to address:
- TODOs and FIXMEs
- Deprecated code
- Missing tests
- Inconsistent patterns
- Known vulnerabilities

---

## Scanning Process

### Phase 1: Project Type Detection

Identify project type from markers:
```powershell
# Node.js/JavaScript
Test-Path "package.json"

# Python
Test-Path "requirements.txt" -or Test-Path "pyproject.toml"

# Rust
Test-Path "Cargo.toml"

# Go
Test-Path "go.mod"

# .NET
Get-ChildItem "*.csproj"
```

### Phase 2: Structure Scan

```powershell
# Get directory structure
Get-ChildItem -Recurse -Directory | 
    Where-Object { $_.Name -notmatch "node_modules|\.git|__pycache__|dist|build|\.next" } |
    Select-Object FullName
```

### Phase 3: Dependency Extraction

For each ecosystem:

**Node.js:**
```powershell
$pkg = Get-Content "package.json" | ConvertFrom-Json
$pkg.dependencies
$pkg.devDependencies
```

**Python:**
```powershell
Get-Content "requirements.txt"
```

### Phase 4: Pattern Discovery

Search for common patterns:
```powershell
# Components
Get-ChildItem -Recurse -Include "*.tsx","*.jsx" | Select-Object Name

# API routes
Get-ChildItem -Recurse -Path "**/api/**" -Include "*.ts","*.js"

# Models/schemas
Select-String -Path "**/*.ts" -Pattern "interface|type|schema"
```

### Phase 5: Debt Discovery

```powershell
# TODOs
Select-String -Path "src/**/*" -Pattern "TODO|FIXME|HACK|XXX"

# Deprecated
Select-String -Path "**/*" -Pattern "@deprecated|DEPRECATED"

# Console statements (often debug leftovers)
Select-String -Path "src/**/*" -Pattern "console\.(log|debug|warn)"
```

---

## Output Format

### ARCHITECTURE.md

```markdown
# Architecture

> Generated by /map on {date}

## Overview
{High-level system description}

## System Diagram
```
{ASCII or description of component relationships}
```

## Components

### {Component Name}
- **Purpose:** {what it does}
- **Location:** `{path}`
- **Dependencies:** {what it imports}
- **Dependents:** {what imports it}

## Data Flow
{How data moves through the system}

## Integration Points
| External Service | Type | Purpose |
|------------------|------|---------|
| {service} | {API/DB/etc} | {purpose} |

## Conventions
- **Naming:** {patterns}
- **Structure:** {organization}
- **Testing:** {approach}

## Technical Debt
- [ ] {Debt item with location}
```

### STACK.md

```markdown
# Technology Stack

> Generated by /map on {date}

## Runtime
| Technology | Version | Purpose |
|------------|---------|---------|
| {tech} | {version} | {purpose} |

## Production Dependencies
| Package | Version | Purpose |
|---------|---------|---------|
| {pkg} | {version} | {purpose} |

## Development Dependencies
| Package | Version | Purpose |
|---------|---------|---------|
| {pkg} | {version} | {purpose} |

## Infrastructure
| Service | Provider | Purpose |
|---------|----------|---------|
| {svc} | {provider} | {purpose} |

## Configuration
| Variable | Purpose | Required |
|----------|---------|----------|
| {var} | {purpose} | {yes/no} |
```

---

## Checklist

Before Completing Map:
- [ ] Project type identified
- [ ] All source directories documented
- [ ] Entry points found
- [ ] Dependencies extracted and categorized
- [ ] Key patterns identified
- [ ] Integrations mapped
- [ ] Technical debt surfaced
- [ ] ARCHITECTURE.md created
- [ ] STACK.md created

Overview

This skill analyzes an existing codebase to produce clear, actionable architecture and stack documentation that supports planning and refactoring. It inspects project structure, dependencies, integration points, and technical debt to generate ARCHITECTURE.md and STACK.md. The output is oriented toward engineers and architects who need a fast, trustworthy map of a codebase.

How this skill works

The agent scans the repository to detect project type and discover source directories, entry points, tests, and configuration files. It extracts dependency manifests, searches for coding patterns and conventions, and identifies integrations with external services. It also surfaces technical debt by locating TODOs, deprecated code, missing tests, and common debug artifacts. Finally, it synthesizes findings into two artifacts: ARCHITECTURE.md (system overview, components, data flow, integrations, conventions, debt) and STACK.md (runtime, dependencies, dev tools, infra, config).

When to use it

  • Onboarding new engineers to understand a repository quickly
  • Before planning a refactor, migration, or major feature
  • During due diligence for acquisitions or audits
  • To generate baseline documentation for legacy code
  • When assessing upgrade or security remediation effort

Best practices

  • Run the mapper from the repository root and ensure dependency manifests are present
  • Keep the workspace clean (exclude node_modules, build artifacts) for accurate scans
  • Commit generated ARCHITECTURE.md and STACK.md to a docs folder and review manually
  • Use the mapper output as a starting point; validate integration and dependency versions before changing infrastructure
  • Iterate: re-run after significant changes to keep documentation current

Example use cases

  • Generate a component map and dependency table before migrating to a new framework
  • Identify hotspots of technical debt (TODO/FIXME clusters) to prioritize cleanup sprints
  • Produce a one-page architecture overview for a stakeholder or engineering lead
  • Audit production and dev dependencies to find outdated or vulnerable packages
  • Document external APIs, databases, and environment variables for secure deployments

FAQ

What outputs does the mapper produce?

It produces ARCHITECTURE.md with component and data-flow details, and STACK.md with runtime, dependency, and infrastructure summaries.

Which languages and package systems does it detect?

It detects common ecosystems via markers (package.json, requirements.txt, go.mod, Cargo.toml, .csproj) and adapts extraction commands accordingly.