BMAD-METHOD/src/bmm/workflows/document-project/instructions.md

15 KiB

Document Project Workflow Router

The workflow execution engine is governed by: {project-root}/_bmad/core/tasks/workflow.md You MUST have already loaded and processed: {project-root}/_bmad/bmm/workflows/document-project/workflow.md Communicate all responses in {communication_language}

This router determines workflow mode and delegates to specialized sub-workflows

Initialize status defaults:

  • Set status_exists = false
  • Set status_file_found = false
  • Set standalone_mode = true
  • Set warning = ""
  • Set status_load_error_reason = ""
  • Set suggestion = ""
  • Set next_workflow = ""
  • Set next_agent = ""
  • Set status_file_path = ""
  • Set field_type = ""
  • Set workflow_mode = ""
  • Set scan_level = ""
  • Set subworkflow_success = false
  • Set status_update_success = false
  • Set cached_project_types = ""

Attempt to load workflow status directly from {output_folder}/bmm-workflow-status.yaml:

  • If file exists, is readable, and parses correctly:
    • Set status_exists = true
    • Set status_file_found = true
    • Set standalone_mode = false
    • Set status_file_path = {output_folder}/bmm-workflow-status.yaml
    • Extract field_type, warning, suggestion, next_workflow, next_agent if present
  • If file is missing, unreadable, or malformed:
    • Keep defaults and continue in standalone mode
    • Set status_load_error_reason from the caught file/parse error (e.g., missing file, permission denied, YAML parse error)
    • Set warning = "Unable to load workflow status from {output_folder}/bmm-workflow-status.yaml: {{status_load_error_reason}}"
    • Output warning and continue in standalone mode
{{suggestion}} {{warning}} Note: Documentation workflow can run standalone. Continuing without progress tracking. Set standalone_mode = true Set status_file_found = false Store {{status_file_path}} for later updates Set status_file_found = true Note: This is a greenfield project. Documentation workflow is typically for brownfield projects. Continue anyway to document planning artifacts? (y/n) Exit workflow

Validate sequencing locally from loaded status fields: - If warning is empty, continue - If warning contains guidance, require explicit user confirmation before continuing

{{warning}} Note: This may be auto-invoked by prd for brownfield documentation. Continue with documentation? (y/n) {{suggestion}} Exit workflow SMART LOADING STRATEGY: Check state file FIRST before loading any CSV files

Check for existing state file at: {project_knowledge}/project-scan-report.json Set resume_mode = false

Read state file and extract: timestamps, mode, scan_level, current_step, completed_steps, project_classification Validate last_updated from state file: - If last_updated is missing or invalid, set state_age_hours = 999 and mark state as stale - Otherwise parse last_updated into validated_last_updated Extract cached project_type_id(s) from state file if present Calculate state_age_hours: - If validated_last_updated exists, compute current time - validated_last_updated - Otherwise keep state_age_hours = 999 Display: "Found old state file (>24 hours). Starting fresh scan." Attempt to create archive directory: {project_knowledge}/.archive/ Failed to create archive directory at {project_knowledge}/.archive/. Keeping existing state and exiting to avoid data loss. Set resume_mode = true Exit workflow Attempt to archive old state file to: {project_knowledge}/.archive/project-scan-report-{{timestamp}}.json Failed to archive old state file. Keeping existing state and exiting to avoid data loss. Set resume_mode = true Exit workflow Set resume_mode = false Set workflow_mode = "" Set scan_level = "" Set cached_project_types = "" Set current_step = "" Set subworkflow_success = false Continue to Step 3

I found an in-progress workflow state from {{last_updated}}.

Current Progress:

  • Mode: {{mode}}
  • Scan Level: {{scan_level}}
  • Completed Steps: {{completed_steps_count}}/{{total_steps}}
  • Last Step: {{current_step}}
  • Project Type(s): {{cached_project_types}}

Would you like to:

  1. Resume from where we left off - Continue from step {{current_step}}
  2. Start fresh - Archive old state and begin new scan
  3. Cancel - Exit without changes

Your choice [1/2/3]:

Set resume_mode = true Validate persisted mode before assigning workflow_mode: - If mode is one of [deep_dive, initial_scan, full_rescan], set workflow_mode = {{mode}} - Otherwise set workflow_mode = "full_rescan", set resume_mode = false, and continue as fresh scan Set subworkflow_success = false Load findings summaries from state file Load cached project_type_id(s) from state file
<critical>CONDITIONAL CSV LOADING FOR RESUME:</critical>
<check if="cached_project_types == ''">
  <output>No cached project types found. Falling back to full CSV load.</output>
  <action>Load project-types.csv and architecture_registry.csv</action>
  <action>Load documentation_requirements_csv for active project classification</action>
</check>
<check if="cached_project_types != ''">
<action>For each cached project_type_id, load ONLY the corresponding row from: {documentation_requirements_csv}</action>
<action>Skip loading project-types.csv and architecture_registry.csv (not needed on resume)</action>
<action>Store loaded doc requirements for use in remaining steps</action>
</check>

<action>Display: "Resuming {{workflow_mode}} from {{current_step}} with cached project type(s): {{cached_project_types}}"</action>

<check if="workflow_mode == deep_dive">
  <action>Read fully and follow: {installed_path}/workflows/deep-dive-instructions.md with resume context</action>
  <action>Set subworkflow_success = true only if delegated workflow completed without HALT/error</action>
  <check if="subworkflow_success != true">
    <output>Sub-workflow failed or was aborted during resume deep-dive mode. Exiting without marking completion.</output>
    <action>Exit workflow</action>
  </check>
  <action>After sub-workflow completes, continue to Step 4</action>
</check>

<check if="workflow_mode == initial_scan OR workflow_mode == full_rescan">
  <action>Read fully and follow: {installed_path}/workflows/full-scan-instructions.md with resume context</action>
  <action>Set subworkflow_success = true only if delegated workflow completed without HALT/error</action>
  <check if="subworkflow_success != true">
    <output>Sub-workflow failed or was aborted during resume full-scan mode. Exiting without marking completion.</output>
    <action>Exit workflow</action>
  </check>
  <action>After sub-workflow completes, continue to Step 4</action>
</check>

<check if="workflow_mode != deep_dive AND workflow_mode != initial_scan AND workflow_mode != full_rescan">
  <output>Invalid resume workflow mode '{{workflow_mode}}'. Exiting without marking completion.</output>
  <action>Exit workflow</action>
</check>
Attempt to create archive directory: {project_knowledge}/.archive/ Failed to create archive directory. Keeping existing state and exiting to avoid data loss. Set resume_mode = true Exit workflow Attempt to move old state file to: {project_knowledge}/.archive/project-scan-report-{{timestamp}}.json Failed to archive old state file. Keeping existing state and exiting to avoid data loss. Set resume_mode = true Exit workflow Set resume_mode = false Reset workflow_mode, scan_level, cached_project_types, current_step to defaults Set subworkflow_success = false Continue to Step 3 Display: "Exiting workflow without changes." Exit workflow Invalid selection. Expected 1, 2, or 3. Exiting workflow without changes. Exit workflow Set resume_mode = false Continue to Step 3 Check if {project_knowledge}/index.md exists Read existing index.md to extract metadata (date, project structure, parts count) Store as {{existing_doc_date}}, {{existing_structure}}

I found existing documentation generated on {{existing_doc_date}}.

What would you like to do?

  1. Re-scan entire project - Update all documentation with latest changes
  2. Deep-dive into specific area - Generate detailed documentation for a particular feature/module/folder
  3. Cancel - Keep existing documentation as-is

Your choice [1/2/3]:

Set workflow_mode = "full_rescan" Set scan_level = "standard" Display: "Starting full project rescan..." Read fully and follow: {installed_path}/workflows/full-scan-instructions.md Set subworkflow_success = true only if delegated workflow completed without HALT/error Sub-workflow failed or was aborted during full rescan. Exiting without marking completion. Exit workflow After sub-workflow completes, continue to Step 4 Set workflow_mode = "deep_dive" Set scan_level = "exhaustive" Display: "Starting deep-dive documentation mode..." Read fully and follow: {installed_path}/workflows/deep-dive-instructions.md Set subworkflow_success = true only if delegated workflow completed without HALT/error Sub-workflow failed or was aborted during deep-dive mode. Exiting without marking completion. Exit workflow After sub-workflow completes, continue to Step 4 Display message: "Keeping existing documentation. Exiting workflow." Exit workflow Invalid selection. Expected 1, 2, or 3. Exiting workflow without changes. Exit workflow Set workflow_mode = "initial_scan" Set scan_level = "initial" Display: "No existing documentation found. Starting initial project scan..." Read fully and follow: {installed_path}/workflows/full-scan-instructions.md Set subworkflow_success = true only if delegated workflow completed without HALT/error Sub-workflow failed or was aborted during initial scan. Exiting without marking completion. Exit workflow After sub-workflow completes, continue to Step 4 Resume flow did not complete a delegated sub-workflow successfully. Exiting without completion update. Exit workflow Attempt status update in {{status_file_path}}: - Mark workflow `document-project` as completed - Persist updated timestamp and completion metadata - Set status_update_success = true on success - If write fails, set status_update_success = false and capture status_update_error Status updated! ⚠️ Status update skipped: {{status_update_error}}

Document Project Workflow Complete, {user_name}!

Documentation Generated:

  • Mode: {{workflow_mode}}
  • Scan Level: {{scan_level}}
  • Output: {project_knowledge}/index.md and related files
**Status Updated:** Progress tracking updated.

Next Steps:

  • Run bmad-help if you need recommended next workflows. - Next required: {{next_workflow}} ({{next_agent}} agent) - Next required: not specified
**Next Steps:** - Refer to the BMM workflow guide if unsure what to do next - Run `bmad-help` to get guided workflow recommendations