Skip to main content

Document Project Workflow

The Document Project workflow generates comprehensive documentation for existing (brownfield) projects. It automatically scans your codebase, understands the architecture, and creates AI-friendly documentation.

Purpose

This workflow serves two primary purposes:
  1. AI Context Generation: Create documentation that AI agents can use to understand your project
  2. Team Knowledge: Provide human-readable project documentation

When to Use

Use Document Project when:
  • Starting work on an existing codebase
  • Onboarding new team members
  • Project lacks current documentation
  • Need to refresh outdated documentation
  • Preparing for AI-assisted development

Trigger Commands


Workflow Modes

The Document Project workflow has three modes:

Initial Scan

First-time documentation of a project

Full Rescan

Update all documentation with latest changes

Deep Dive

Detailed documentation of specific area

Initial Scan

Trigger: No existing documentation found Process:
  1. Detect project type
  2. Scan codebase structure
  3. Generate comprehensive documentation
  4. Create project overview
  5. Document key areas
Output: Complete documentation suite in {project_knowledge}/

Full Rescan

Trigger: Existing documentation found, user chooses “Re-scan entire project” Process:
  1. Load existing documentation
  2. Re-scan codebase for changes
  3. Update all documentation
  4. Preserve manual additions
  5. Track what changed
Output: Updated documentation with changelog

Deep Dive

Trigger: Existing documentation found, user chooses “Deep-dive into specific area” Process:
  1. User specifies area (folder, feature, module)
  2. Exhaustive scan of that area
  3. Generate detailed documentation
  4. Link to existing docs
  5. Update index
Output: Detailed documentation for specific area

Workflow Process

Step 1: Mode Detection

The workflow checks for existing documentation and determines the mode:
If no documentation exists:
→ Proceeds to Initial Scan mode If documentation exists:

Step 2: Project Type Detection

Purpose: Understand what kind of project this is to generate relevant documentation. Detection Process:
  1. Examine project structure
    • Look for framework indicators (package.json, requirements.txt, etc.)
    • Identify build tools and configs
    • Detect languages used
  2. Load documentation requirements
    • Uses documentation-requirements.csv to map project type to documentation needs
    • Determines what should be documented
  3. Architecture detection
    • Identifies architectural patterns
    • Detects folder structure conventions
    • Finds entry points
Supported Project Types:
  • Web Applications (React, Vue, Angular, etc.)
  • Backend APIs (Node.js, Python, etc.)
  • Full-stack applications
  • Mobile apps
  • Libraries and SDKs
  • CLI tools
  • Microservices

Step 3: Codebase Scanning

Scan Levels:
  • Standard Scan (Initial/Rescan): Covers main areas
  • Exhaustive Scan (Deep Dive): Every detail of specific area
Scanning Process:
  1. Structure Discovery
    • Map folder structure
    • Identify key directories
    • Find configuration files
  2. Entry Points
    • Locate main files
    • Find routing definitions
    • Identify API endpoints
  3. Dependencies
    • External packages
    • Internal modules
    • Third-party services
  4. Patterns & Conventions
    • Code organization
    • Naming conventions
    • Architectural patterns
  5. Key Features
    • Main functionality areas
    • User-facing features
    • Background processes

Step 4: Documentation Generation

Generated Documents:

1. Project Overview

File: {project_knowledge}/project-overview.md Contains:
  • Project description
  • Technology stack
  • Architecture overview
  • Key features
  • Getting started guide
  • Development workflow

2. Source Tree

File: {project_knowledge}/source-tree.md Contains:
  • Complete folder structure
  • Purpose of each directory
  • Key files and their roles
  • Organization principles

3. Deep Dive Documents

Files: {project_knowledge}/deep-dive-[area].md Contains (for specific area):
  • Detailed component breakdown
  • Data flow
  • API documentation
  • State management
  • Code examples
  • Integration points

4. Index

File: {project_knowledge}/index.md Contains:
  • Table of contents
  • Document links
  • Quick navigation
  • Last updated dates

Step 5: State Management

State File: {project_knowledge}/project-scan-report.json Tracks:
  • Scan progress
  • Completed steps
  • Project classification
  • Timestamps
  • Resume capability
Resume Capability: If workflow is interrupted:

Initial Scan Workflow

Full Scan Process

File: src/bmm/workflows/document-project/workflows/full-scan.yaml Steps:
  1. Project Discovery
    • Detect project type
    • Load requirements CSV
    • Configure scan scope
  2. Structure Mapping
    • Scan folder structure
    • Identify key directories
    • Map file organization
  3. Entry Point Analysis
    • Find application entry points
    • Identify routing files
    • Locate configuration
  4. Feature Detection
    • Identify feature areas
    • Map user-facing functionality
    • Document API endpoints
  5. Documentation Generation
    • Generate project overview
    • Create source tree
    • Write index
  6. State Persistence
    • Save scan state
    • Enable resume
    • Track completion

Example Invocation


Deep Dive Workflow

Purpose

Generate exhaustive documentation for a specific feature, module, or folder.

Deep Dive Process

File: src/bmm/workflows/document-project/workflows/deep-dive.yaml Steps:
  1. Area Selection
    • User specifies area
    • Validate area exists
    • Determine scope
  2. Exhaustive Scan
    • Read all files in area
    • Analyze all components
    • Map all dependencies
    • Trace data flow
  3. Pattern Analysis
    • Identify patterns used
    • Document conventions
    • Note architectural decisions
  4. Documentation Generation
    • Create deep-dive document
    • Include code examples
    • Add diagrams (text-based)
    • Link to related areas
  5. Index Update
    • Add to main index
    • Create cross-references
    • Update navigation

Example Invocation


Documentation Templates

Project Overview Template

File: src/bmm/workflows/document-project/templates/project-overview-template.md Sections:
  • Project Description
  • Technology Stack
  • Architecture Overview
  • Folder Structure
  • Getting Started
  • Development Workflow
  • Key Features
  • External Dependencies
  • Configuration
  • Deployment

Source Tree Template

File: src/bmm/workflows/document-project/templates/source-tree-template.md Format:
project-root/ ├── src/ │ ├── components/ # Reusable UI components │ ├── pages/ # Page-level components │ ├── api/ # API integration │ └── utils/ # Utility functions ├── public/ # Static assets └── tests/ # Test files

Deep Dive Template

File: src/bmm/workflows/document-project/templates/deep-dive-template.md Sections:
  • Area Overview
  • Architecture
  • Component Breakdown
  • Data Flow
  • API Integration
  • State Management
  • Code Examples
  • Patterns & Conventions
  • Testing Strategy
  • Related Areas

Configuration

Documentation Requirements CSV

File: src/bmm/workflows/document-project/documentation-requirements.csv Maps project types to documentation requirements:

Workflow Configuration

File: src/bmm/workflows/document-project/workflow.yaml Key Settings:

Output Files

All documentation is generated in {project_knowledge}/ directory:

Best Practices

Initial Documentation

  1. Run Initial Scan Early: Document projects before starting work
  2. Review Generated Docs: Verify accuracy, add manual notes
  3. Deep Dive Key Areas: Document complex features in detail
  4. Keep Updated: Re-scan when major changes occur

Using Documentation

  1. Load for Context: AI agents use docs for context
  2. Reference in Specs: Link to deep-dive docs in quick specs
  3. Onboarding: Share with new team members
  4. Architecture Decisions: Use as input for ADRs

Maintenance

  1. Periodic Rescans: Run full rescan monthly or after major features
  2. Deep Dive New Features: Document new major features
  3. Archive Old Scans: Keep history in .archive/
  4. Manual Additions: Add notes to generated docs (preserved on rescan)

Integration with BMad Method

Document Project workflow integrates with other BMad workflows:

For Greenfield Projects

  • After Phase 3: Document initial architecture
  • After Each Epic: Update documentation
  • Before Handoff: Generate complete docs

For Brownfield Projects

  • Start Here: Document before planning changes
  • Use in Planning: Reference in PRD and Architecture
  • Use in Development: Provide context for story implementation
  • Correct Course: Update docs when changing direction

Source Files

  • Main Workflow: src/bmm/workflows/document-project/workflow.yaml
  • Instructions: src/bmm/workflows/document-project/instructions.md
  • Full Scan: src/bmm/workflows/document-project/workflows/full-scan.yaml
  • Deep Dive: src/bmm/workflows/document-project/workflows/deep-dive.yaml
  • Templates: src/bmm/workflows/document-project/templates/
  • Requirements CSV: src/bmm/workflows/document-project/documentation-requirements.csv

Next Steps