Skip to main content

Overview

The map-codebase command analyzes your existing codebase using parallel specialized agents, producing comprehensive documentation in .planning/codebase/. This creates a foundation for informed planning and development.

Syntax

string
Optional focus area to map (e.g., ‘api’, ‘auth’, ‘frontend’). If provided, agents concentrate on that subsystem while maintaining full codebase awareness.

How It Works

GSD spawns 4 parallel mapper agents, each with specialized focus:
  1. Tech AgentSTACK.md, INTEGRATIONS.md
  2. Architecture AgentARCHITECTURE.md, STRUCTURE.md
  3. Quality AgentCONVENTIONS.md, TESTING.md
  4. Concerns AgentCONCERNS.md
Each agent explores the codebase independently and writes documents directly to .planning/codebase/, keeping orchestrator context usage minimal.

Documents Created

The mapping process creates 7 comprehensive documents:

STACK.md

  • Languages and frameworks
  • Core dependencies
  • Build and runtime tools
  • Version requirements

INTEGRATIONS.md

  • External services and APIs
  • Database connections
  • Authentication providers
  • Third-party libraries
  • Environment configuration

ARCHITECTURE.md

  • System design patterns
  • Component relationships
  • Data flow
  • Key architectural decisions

STRUCTURE.md

  • Directory layout
  • Module organization
  • File naming conventions
  • Code organization patterns

CONVENTIONS.md

  • Code style and formatting
  • Naming conventions
  • Comment standards
  • Best practices in use

TESTING.md

  • Test frameworks and tools
  • Test coverage
  • Testing patterns
  • CI/CD integration

CONCERNS.md

  • Technical debt
  • Security issues
  • Performance bottlenecks
  • Maintenance risks
  • Deprecated patterns

Usage Examples

Map entire codebase

GSD spawns 4 agents in parallel, each analyzing the full codebase from their perspective.

Focus on specific area

Agents focus on API-related code while maintaining awareness of dependencies and context.

Refresh existing map

If .planning/codebase/ exists, GSD offers:
  • Refresh - Update all documents
  • Skip - Use existing map
  • Focus - Update specific documents

When to Use

Perfect for

  • Brownfield projects - Understand existing code before planning
  • Onboarding - Learn unfamiliar codebase structure
  • Before refactoring - Document current state
  • After major changes - Update codebase documentation
  • Outdated STATE.md - Refresh codebase understanding

Skip for

  • Greenfield projects - No code to map yet
  • Trivial codebases - Less than 5 files
  • Just created project - Map after initial implementation

Workflow Integration

Brownfield Project Flow

Greenfield Project Flow

Refresh During Development

Parallel Agent Execution

The mapping process uses parallel execution for efficiency:

Verification

After agents complete, GSD verifies:
  • All 7 documents exist
  • Files have substantial content (line counts)
  • Documents follow template structure
  • No agent errors occurred

Commit Behavior

After successful mapping, GSD commits the codebase documentation:

Output Directory Structure

Success Criteria

Mapping succeeds when:
  • .planning/codebase/ directory created
  • ✅ All 7 documents written by mapper agents
  • ✅ Documents follow template structure
  • ✅ Parallel agents completed without errors
  • ✅ Changes committed to git
  • ✅ User knows next steps

Next Steps After Mapping

GSD suggests appropriate next commands:
  • New brownfield project: /gsd:new-project
  • Existing project: /gsd:plan-phase
  • Architecture changes: /gsd:discuss
  • Found issues: /gsd:add-todo
  • new-project - Initialize project (uses codebase docs)
  • plan-phase - Create phase plans (references codebase docs)
  • health - Validate codebase documentation exists