Orchestrate multi-stage agent pipelines with dependency management{project-root}/_bmad/core/pipeline/pipeline-config.yaml{project-root}/_bmad-output/pipelinesAsk user for pipeline source:
1. Use template (show available templates)
2. Define custom pipeline
List templates from config: full_sdlc, quick_flow, analysis_only, design_review, test_suiteUser selects templateCopy template stages to new pipeline definitionAsk for pipeline nameAsk for stages (agent, parallel, depends_on, outputs)Build pipeline definitionSanitize {name} to {sanitized_name}:
- Convert to lowercase
- Replace spaces and special chars with hyphens
- Remove any chars not in [a-z0-9-_]
- Collapse multiple hyphens to single hyphen
- Trim leading/trailing hyphens
HALT with error: "Pipeline name is required and must contain at least one alphanumeric character"
Generate pipeline_id: "PIPE-{YYYYMMDD}-{sanitized_name}-{HHmmss}"Create pipeline file at {pipeline_dir}/{pipeline_id}.yaml:
- MUST fail if file already exists (no overwrite)
- Use exclusive create mode (O_CREAT | O_EXCL or equivalent)
Retry with new timestamp or append random 4-char suffix
Initialize all stages as "pending"Validate {pipeline_id} format:
- Must match pattern: PIPE-[0-9]{8}-[a-z0-9_-]+-[0-9]{6}
- Must not contain path separators (/, \, ..)
- Must not be empty
HALT with error: "Invalid pipeline_id format"
Load pipeline from {pipeline_dir}/{pipeline_id}.yamlValidate pipeline definition (agents exist, dependencies valid)Default error_handling to "halt" if not set in pipeline definitionSet pipeline status to "running"Initialize execution state tracking (track has_failures flag = false)Find stages where:
- Status == "pending" AND
- All depends_on stages are "completed"
Collect names of all stages still in "pending" statusMark pipeline status as "failed"Update pipeline file with failed stateHALT with error:
"Deadlock detected (cycle or unmet dependencies). Pending stages: {pending_stage_names}"
Mark found stages as "queued"Launch agents in parallel using Task tool with run_in_background=trueTrack agent_ids for each stageLaunch agent using Task tool with run_in_background=falseWait for completionFor parallel stages: Use TaskOutput to collect resultsUpdate stage status based on result (completed/failed)Store outputs in {pipeline_dir}/outputs/{stage_name}/Set has_failures = trueMark pipeline as "failed"Mark dependent stages as "skipped"Update pipeline file with failed stateHALT: "Pipeline failed at stage: {stage_name}"Set has_failures = trueMark dependent stages as "skipped"Continue with non-dependent stagesUpdate pipeline file with current stateMark pipeline as "completed_with_failures"Mark pipeline as "completed"Update pipeline file with final stateValidate {pipeline_id} format:
- Must match pattern: PIPE-[0-9]{8}-[a-z0-9_-]+-[0-9]{6}
- Must not contain path separators (/, \, ..)
HALT with error: "Invalid pipeline_id format"
Load pipeline from {pipeline_dir}/{pipeline_id}.yaml (or active-pipeline.yaml if no id)Calculate progress percentageScan {pipeline_dir} for pipeline filesLoad templates from configValidate {pipeline_id} format:
- Must match pattern: PIPE-[0-9]{8}-[a-z0-9_-]+-[0-9]{6}
- Must not contain path separators (/, \, ..)
HALT with error: "Invalid pipeline_id format"
Load running pipeline from {pipeline_dir}/{pipeline_id}.yaml (or active-pipeline.yaml)Send abort signal to running agentsMark running stages as "aborted"Mark pipeline as "aborted"Validate {pipeline_id} format:
- Must match pattern: PIPE-[0-9]{8}-[a-z0-9_-]+-[0-9]{6}
- Must not contain path separators (/, \, ..)
HALT with error: "Invalid pipeline_id format"
Load failed/aborted pipeline from {pipeline_dir}/{pipeline_id}.yamlIdentify failed/aborted stagesAsk user: Retry failed stages or skip?Reset failed stages to "pending"Continue with run logicMark failed stages as "skipped"Continue with remaining stages