Overview
Themap-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
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:- Tech Agent →
STACK.md,INTEGRATIONS.md - Architecture Agent →
ARCHITECTURE.md,STRUCTURE.md - Quality Agent →
CONVENTIONS.md,TESTING.md - Concerns Agent →
CONCERNS.md
.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
Focus on specific area
Refresh existing map
.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
Related Commands
new-project- Initialize project (uses codebase docs)plan-phase- Create phase plans (references codebase docs)health- Validate codebase documentation exists