# Develop Story - Workflow Instructions
```xml
The workflow execution engine is governed by: {project_root}/bmad/core/tasks/workflow.md
You MUST have already loaded and processed: {installed_path}/workflow.yaml
Only modify the story file in these areas: Tasks/Subtasks checkboxes, Dev Agent Record (Debug Log, Completion Notes), File List, Change Log, and Status
Execute ALL steps in exact order; do NOT skip steps
If {{run_until_complete}} == true, run non-interactively: do not pause between steps unless a HALT condition is reached or explicit user approval is required for unapproved dependencies.
Absolutely DO NOT stop because of "milestones", "significant progress", or "session boundaries". Continue in a single execution until the story is COMPLETE (all ACs satisfied and all tasks/subtasks checked) or a HALT condition is triggered.
Do NOT schedule a "next session" or request review pauses unless a HALT condition applies. Only Step 6 decides completion.
If {{story_path}} was explicitly provided and is valid → use it. Otherwise, attempt auto-discovery.
Auto-discovery: Read {{story_dir}} from config (dev_story_location). If invalid/missing or contains no .md files, ASK user to provide either: (a) a story file path, or (b) a directory to scan.
If a directory is provided, list story markdown files recursively under that directory matching pattern: "story-*.md".
Sort candidates by last modified time (newest first) and take the top {{story_selection_limit}} items.
Present the list with index, filename, and modified time. Ask: "Select a story (1-{{story_selection_limit}}) or enter a path:"
Resolve the selected item into {{story_path}}
Read the COMPLETE story file from {{story_path}}
Parse sections: Story, Acceptance Criteria, Tasks/Subtasks (including subtasks), Dev Notes, Dev Agent Record, File List, Change Log, Status
Identify the first incomplete task (unchecked [ ]) in Tasks/Subtasks; if subtasks exist, treat all subtasks as part of the selected task scope
If no incomplete tasks found → "All tasks completed - proceed to completion sequence" and Continue
If story file inaccessible → HALT: "Cannot develop story without access to story file"
If task requirements ambiguous → ASK user to clarify; if unresolved, HALT: "Task requirements must be clear before implementation"
Review acceptance criteria and dev notes for the selected task
Plan implementation steps and edge cases; write down a brief plan in Dev Agent Record → Debug Log
Implement the task COMPLETELY including all subtasks, following architecture patterns and coding standards in this repo
Handle error conditions and edge cases appropriately
If unapproved dependencies are needed → ASK user for approval before adding
If 3 consecutive implementation failures occur → HALT and request guidance
If required configuration is missing → HALT: "Cannot proceed without necessary configuration files"
If {{run_until_complete}} == true → Do not stop after partial progress; continue iterating tasks until all ACs are satisfied or a HALT condition triggers
Do NOT propose to pause for review, standups, or validation until Step 6 gates are satisfied
Create unit tests for business logic and core functionality introduced/changed by the task
Add integration tests for component interactions where applicable
Include end-to-end tests for critical user flows if applicable
Cover edge cases and error handling scenarios noted in the plan
Determine how to run tests for this repo (infer or use {{run_tests_command}} if provided)
Run all existing tests to ensure no regressions
Run the new tests to verify implementation correctness
Run linting and code quality checks if configured
Validate implementation meets ALL story acceptance criteria; if ACs include quantitative thresholds (e.g., test pass rate), ensure they are met before marking complete
If regression tests fail → STOP and fix before continuing
If new tests fail → STOP and fix before continuing
ONLY mark the task (and subtasks) checkbox with [x] if ALL tests pass and validation succeeds
Update File List section with any new, modified, or deleted files (paths relative to repo root)
Add completion notes to Dev Agent Record if significant changes were made (summarize intent, approach, and any follow-ups)
Append a brief entry to Change Log describing the change
Save the story file
Determine if more incomplete tasks remain
If more tasks remain → Next task
If no tasks remain → Completion
Verify ALL tasks and subtasks are marked [x] (re-scan the story document now)
Run the full regression suite (do not skip)
Confirm File List includes every changed file
Execute story definition-of-done checklist, if the story includes one
Update the story Status to: Ready for Review
If any task is incomplete → Return to step 1 to complete remaining work (Do NOT finish with partial progress)
If regression failures exist → STOP and resolve before completing
If File List is incomplete → Update it before completing
Optionally run the workflow validation task against the story using {project-root}/bmad/core/tasks/validate-workflow.md
Prepare a concise summary in Dev Agent Record → Completion Notes
Communicate that the story is Ready for Review
```