name: ‘step-05-generate-output’ description: ‘Generate output documents with adaptive orchestration (agent-team, subagent, or sequential)’ outputFile: ‘{test_artifacts}/test-design-epic-{epic_num}.md’
Write the final test-design document(s) using the correct template(s), then validate against the checklist.
{communication_language}CRITICAL: Follow this sequence exactly. Do not skip, reorder, or improvise.
const orchestrationContext = {
config: {
execution_mode: config.tea_execution_mode || 'auto', // "auto" | "subagent" | "agent-team" | "sequential"
capability_probe: config.tea_capability_probe !== false, // true by default
},
timestamp: new Date().toISOString().replace(/[:.]/g, '-'),
};
const normalizeUserExecutionMode = (mode) => {
if (typeof mode !== 'string') return null;
const normalized = mode.trim().toLowerCase().replace(/[-_]/g, ' ').replace(/\s+/g, ' ');
if (normalized === 'auto') return 'auto';
if (normalized === 'sequential') return 'sequential';
if (normalized === 'subagent' || normalized === 'sub agent' || normalized === 'subagents' || normalized === 'sub agents') {
return 'subagent';
}
if (normalized === 'agent team' || normalized === 'agent teams' || normalized === 'agentteam') {
return 'agent-team';
}
return null;
};
const normalizeConfigExecutionMode = (mode) => {
if (mode === 'subagent') return 'subagent';
if (mode === 'auto' || mode === 'sequential' || mode === 'subagent' || mode === 'agent-team') {
return mode;
}
return null;
};
// Explicit user instruction in the active run takes priority over config.
const explicitModeFromUser = normalizeUserExecutionMode(runtime.getExplicitExecutionModeHint?.() || null);
const requestedMode = explicitModeFromUser || normalizeConfigExecutionMode(orchestrationContext.config.execution_mode) || 'auto';
const probeEnabled = orchestrationContext.config.capability_probe;
const supports = { subagent: false, agentTeam: false };
if (probeEnabled) {
supports.subagent = runtime.canLaunchSubagents?.() === true;
supports.agentTeam = runtime.canLaunchAgentTeams?.() === true;
}
let resolvedMode = requestedMode;
if (requestedMode === 'auto') {
if (supports.agentTeam) resolvedMode = 'agent-team';
else if (supports.subagent) resolvedMode = 'subagent';
else resolvedMode = 'sequential';
} else if (probeEnabled && requestedMode === 'agent-team' && !supports.agentTeam) {
resolvedMode = supports.subagent ? 'subagent' : 'sequential';
} else if (probeEnabled && requestedMode === 'subagent' && !supports.subagent) {
resolvedMode = 'sequential';
}
Resolution precedence:
agent team => agent-team; subagent => subagent; sequential; auto)tea_execution_mode from configGenerate two documents:
{test_artifacts}/test-design-architecture.md using test-design-architecture-template.md{test_artifacts}/test-design-qa.md using test-design-qa-template.mdIf resolvedMode is agent-team or subagent, these two documents can be generated in parallel as independent workers, then reconciled for consistency.
Generate one document:
{outputFile} using test-design-template.mdepic_num is unclear, ask the userEpic-level mode remains single-worker by default (one output artifact).
Ensure the outputs include:
Validate the output(s) against:
checklist.md in this workflow folder{test_artifacts}/ not random locationsIf any checklist criteria are missing, fix before completion.
If this is a system-level test design (not component/feature level):
test-design-handoff-template.md to {test_artifacts}/test-design/{project_name}-handoff.mdNote: The handoff document is designed for consumption by BMAD’s
create-epics-and-storiesworkflow. It is only generated for system-level test designs where epic/story decomposition is relevant.
Before finalizing, review the complete output document for quality:
Summarize:
Save this step’s accumulated work to {progressFile}.
{progressFile} does not exist (first save), create it with YAML frontmatter: ---
workflowStatus: 'completed'
totalSteps: 5
stepsCompleted: ['step-05-generate-output']
lastStep: 'step-05-generate-output'
nextStep: ''
lastSaved: '{date}'
---
Then write this step’s output below the frontmatter.
{progressFile} already exists, update:
workflowStatus: 'completed'totalSteps: 5'step-05-generate-output' to stepsCompleted array (only if not already present)lastStep: 'step-05-generate-output'nextStep: ''lastSaved: '{date}'Run: python3 {project-root}/_bmad/scripts/resolve_customization.py --skill {skill-root} --key workflow.on_complete
If the resolver succeeds and returns a non-empty workflow.on_complete, execute that value as the final terminal instruction before exiting.
If the resolver fails, returns no output, or resolves an empty value, skip the hook and exit normally.