instructions.xml 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410
  1. <workflow>
  2. <critical>The workflow execution engine is governed by: {project-root}/_bmad/core/tasks/workflow.xml</critical>
  3. <critical>You MUST have already loaded and processed: {installed_path}/workflow.yaml</critical>
  4. <critical>Communicate all responses in {communication_language} and language MUST be tailored to {user_skill_level}</critical>
  5. <critical>Generate all documents in {document_output_language}</critical>
  6. <critical>Only modify the story file in these areas: Tasks/Subtasks checkboxes, Dev Agent Record (Debug Log, Completion Notes), File List,
  7. Change Log, and Status</critical>
  8. <critical>Execute ALL steps in exact order; do NOT skip steps</critical>
  9. <critical>Absolutely DO NOT stop because of "milestones", "significant progress", or "session boundaries". Continue in a single execution
  10. until the story is COMPLETE (all ACs satisfied and all tasks/subtasks checked) UNLESS a HALT condition is triggered or the USER gives
  11. other instruction.</critical>
  12. <critical>Do NOT schedule a "next session" or request review pauses unless a HALT condition applies. Only Step 6 decides completion.</critical>
  13. <critical>User skill level ({user_skill_level}) affects conversation style ONLY, not code updates.</critical>
  14. <step n="1" goal="Find next ready story and load it" tag="sprint-status">
  15. <check if="{{story_path}} is provided">
  16. <action>Use {{story_path}} directly</action>
  17. <action>Read COMPLETE story file</action>
  18. <action>Extract story_key from filename or metadata</action>
  19. <goto anchor="task_check" />
  20. </check>
  21. <!-- Sprint-based story discovery -->
  22. <check if="{{sprint_status}} file exists">
  23. <critical>MUST read COMPLETE sprint-status.yaml file from start to end to preserve order</critical>
  24. <action>Load the FULL file: {{sprint_status}}</action>
  25. <action>Read ALL lines from beginning to end - do not skip any content</action>
  26. <action>Parse the development_status section completely to understand story order</action>
  27. <action>Find the FIRST story (by reading in order from top to bottom) where:
  28. - Key matches pattern: number-number-name (e.g., "1-2-user-auth")
  29. - NOT an epic key (epic-X) or retrospective (epic-X-retrospective)
  30. - Status value equals "ready-for-dev"
  31. </action>
  32. <check if="no ready-for-dev or in-progress story found">
  33. <output>📋 No ready-for-dev stories found in sprint-status.yaml
  34. **Current Sprint Status:** {{sprint_status_summary}}
  35. **What would you like to do?**
  36. 1. Run `create-story` to create next story from epics with comprehensive context
  37. 2. Run `*validate-create-story` to improve existing stories before development (recommended quality check)
  38. 3. Specify a particular story file to develop (provide full path)
  39. 4. Check {{sprint_status}} file to see current sprint status
  40. 💡 **Tip:** Stories in `ready-for-dev` may not have been validated. Consider running `validate-create-story` first for a quality
  41. check.
  42. </output>
  43. <ask>Choose option [1], [2], [3], or [4], or specify story file path:</ask>
  44. <check if="user chooses '1'">
  45. <action>HALT - Run create-story to create next story</action>
  46. </check>
  47. <check if="user chooses '2'">
  48. <action>HALT - Run validate-create-story to improve existing stories</action>
  49. </check>
  50. <check if="user chooses '3'">
  51. <ask>Provide the story file path to develop:</ask>
  52. <action>Store user-provided story path as {{story_path}}</action>
  53. <goto anchor="task_check" />
  54. </check>
  55. <check if="user chooses '4'">
  56. <output>Loading {{sprint_status}} for detailed status review...</output>
  57. <action>Display detailed sprint status analysis</action>
  58. <action>HALT - User can review sprint status and provide story path</action>
  59. </check>
  60. <check if="user provides story file path">
  61. <action>Store user-provided story path as {{story_path}}</action>
  62. <goto anchor="task_check" />
  63. </check>
  64. </check>
  65. </check>
  66. <!-- Non-sprint story discovery -->
  67. <check if="{{sprint_status}} file does NOT exist">
  68. <action>Search {story_dir} for stories directly</action>
  69. <action>Find stories with "ready-for-dev" status in files</action>
  70. <action>Look for story files matching pattern: *-*-*.md</action>
  71. <action>Read each candidate story file to check Status section</action>
  72. <check if="no ready-for-dev stories found in story files">
  73. <output>📋 No ready-for-dev stories found
  74. **Available Options:**
  75. 1. Run `create-story` to create next story from epics with comprehensive context
  76. 2. Run `*validate-create-story` to improve existing stories
  77. 3. Specify which story to develop
  78. </output>
  79. <ask>What would you like to do? Choose option [1], [2], or [3]:</ask>
  80. <check if="user chooses '1'">
  81. <action>HALT - Run create-story to create next story</action>
  82. </check>
  83. <check if="user chooses '2'">
  84. <action>HALT - Run validate-create-story to improve existing stories</action>
  85. </check>
  86. <check if="user chooses '3'">
  87. <ask>It's unclear what story you want developed. Please provide the full path to the story file:</ask>
  88. <action>Store user-provided story path as {{story_path}}</action>
  89. <action>Continue with provided story file</action>
  90. </check>
  91. </check>
  92. <check if="ready-for-dev story found in files">
  93. <action>Use discovered story file and extract story_key</action>
  94. </check>
  95. </check>
  96. <action>Store the found story_key (e.g., "1-2-user-authentication") for later status updates</action>
  97. <action>Find matching story file in {story_dir} using story_key pattern: {{story_key}}.md</action>
  98. <action>Read COMPLETE story file from discovered path</action>
  99. <anchor id="task_check" />
  100. <action>Parse sections: Story, Acceptance Criteria, Tasks/Subtasks, Dev Notes, Dev Agent Record, File List, Change Log, Status</action>
  101. <action>Load comprehensive context from story file's Dev Notes section</action>
  102. <action>Extract developer guidance from Dev Notes: architecture requirements, previous learnings, technical specifications</action>
  103. <action>Use enhanced story context to inform implementation decisions and approaches</action>
  104. <action>Identify first incomplete task (unchecked [ ]) in Tasks/Subtasks</action>
  105. <action if="no incomplete tasks">
  106. <goto step="6">Completion sequence</goto>
  107. </action>
  108. <action if="story file inaccessible">HALT: "Cannot develop story without access to story file"</action>
  109. <action if="incomplete task or subtask requirements ambiguous">ASK user to clarify or HALT</action>
  110. </step>
  111. <step n="2" goal="Load project context and story information">
  112. <critical>Load all available context to inform implementation</critical>
  113. <action>Load {project_context} for coding standards and project-wide patterns (if exists)</action>
  114. <action>Parse sections: Story, Acceptance Criteria, Tasks/Subtasks, Dev Notes, Dev Agent Record, File List, Change Log, Status</action>
  115. <action>Load comprehensive context from story file's Dev Notes section</action>
  116. <action>Extract developer guidance from Dev Notes: architecture requirements, previous learnings, technical specifications</action>
  117. <action>Use enhanced story context to inform implementation decisions and approaches</action>
  118. <output>✅ **Context Loaded**
  119. Story and project context available for implementation
  120. </output>
  121. </step>
  122. <step n="3" goal="Detect review continuation and extract review context">
  123. <critical>Determine if this is a fresh start or continuation after code review</critical>
  124. <action>Check if "Senior Developer Review (AI)" section exists in the story file</action>
  125. <action>Check if "Review Follow-ups (AI)" subsection exists under Tasks/Subtasks</action>
  126. <check if="Senior Developer Review section exists">
  127. <action>Set review_continuation = true</action>
  128. <action>Extract from "Senior Developer Review (AI)" section:
  129. - Review outcome (Approve/Changes Requested/Blocked)
  130. - Review date
  131. - Total action items with checkboxes (count checked vs unchecked)
  132. - Severity breakdown (High/Med/Low counts)
  133. </action>
  134. <action>Count unchecked [ ] review follow-up tasks in "Review Follow-ups (AI)" subsection</action>
  135. <action>Store list of unchecked review items as {{pending_review_items}}</action>
  136. <output>⏯️ **Resuming Story After Code Review** ({{review_date}})
  137. **Review Outcome:** {{review_outcome}}
  138. **Action Items:** {{unchecked_review_count}} remaining to address
  139. **Priorities:** {{high_count}} High, {{med_count}} Medium, {{low_count}} Low
  140. **Strategy:** Will prioritize review follow-up tasks (marked [AI-Review]) before continuing with regular tasks.
  141. </output>
  142. </check>
  143. <check if="Senior Developer Review section does NOT exist">
  144. <action>Set review_continuation = false</action>
  145. <action>Set {{pending_review_items}} = empty</action>
  146. <output>🚀 **Starting Fresh Implementation**
  147. Story: {{story_key}}
  148. Story Status: {{current_status}}
  149. First incomplete task: {{first_task_description}}
  150. </output>
  151. </check>
  152. </step>
  153. <step n="4" goal="Mark story in-progress" tag="sprint-status">
  154. <check if="{{sprint_status}} file exists">
  155. <action>Load the FULL file: {{sprint_status}}</action>
  156. <action>Read all development_status entries to find {{story_key}}</action>
  157. <action>Get current status value for development_status[{{story_key}}]</action>
  158. <check if="current status == 'ready-for-dev' OR review_continuation == true">
  159. <action>Update the story in the sprint status report to = "in-progress"</action>
  160. <output>🚀 Starting work on story {{story_key}}
  161. Status updated: ready-for-dev → in-progress
  162. </output>
  163. </check>
  164. <check if="current status == 'in-progress'">
  165. <output>⏯️ Resuming work on story {{story_key}}
  166. Story is already marked in-progress
  167. </output>
  168. </check>
  169. <check if="current status is neither ready-for-dev nor in-progress">
  170. <output>⚠️ Unexpected story status: {{current_status}}
  171. Expected ready-for-dev or in-progress. Continuing anyway...
  172. </output>
  173. </check>
  174. <action>Store {{current_sprint_status}} for later use</action>
  175. </check>
  176. <check if="{{sprint_status}} file does NOT exist">
  177. <output>ℹ️ No sprint status file exists - story progress will be tracked in story file only</output>
  178. <action>Set {{current_sprint_status}} = "no-sprint-tracking"</action>
  179. </check>
  180. </step>
  181. <step n="5" goal="Implement task following red-green-refactor cycle">
  182. <critical>FOLLOW THE STORY FILE TASKS/SUBTASKS SEQUENCE EXACTLY AS WRITTEN - NO DEVIATION</critical>
  183. <action>Review the current task/subtask from the story file - this is your authoritative implementation guide</action>
  184. <action>Plan implementation following red-green-refactor cycle</action>
  185. <!-- RED PHASE -->
  186. <action>Write FAILING tests first for the task/subtask functionality</action>
  187. <action>Confirm tests fail before implementation - this validates test correctness</action>
  188. <!-- GREEN PHASE -->
  189. <action>Implement MINIMAL code to make tests pass</action>
  190. <action>Run tests to confirm they now pass</action>
  191. <action>Handle error conditions and edge cases as specified in task/subtask</action>
  192. <!-- REFACTOR PHASE -->
  193. <action>Improve code structure while keeping tests green</action>
  194. <action>Ensure code follows architecture patterns and coding standards from Dev Notes</action>
  195. <action>Document technical approach and decisions in Dev Agent Record → Implementation Plan</action>
  196. <action if="new dependencies required beyond story specifications">HALT: "Additional dependencies need user approval"</action>
  197. <action if="3 consecutive implementation failures occur">HALT and request guidance</action>
  198. <action if="required configuration is missing">HALT: "Cannot proceed without necessary configuration files"</action>
  199. <critical>NEVER implement anything not mapped to a specific task/subtask in the story file</critical>
  200. <critical>NEVER proceed to next task until current task/subtask is complete AND tests pass</critical>
  201. <critical>Execute continuously without pausing until all tasks/subtasks are complete or explicit HALT condition</critical>
  202. <critical>Do NOT propose to pause for review until Step 9 completion gates are satisfied</critical>
  203. </step>
  204. <step n="6" goal="Author comprehensive tests">
  205. <action>Create unit tests for business logic and core functionality introduced/changed by the task</action>
  206. <action>Add integration tests for component interactions specified in story requirements</action>
  207. <action>Include end-to-end tests for critical user flows when story requirements demand them</action>
  208. <action>Cover edge cases and error handling scenarios identified in story Dev Notes</action>
  209. </step>
  210. <step n="7" goal="Run validations and tests">
  211. <action>Determine how to run tests for this repo (infer test framework from project structure)</action>
  212. <action>Run all existing tests to ensure no regressions</action>
  213. <action>Run the new tests to verify implementation correctness</action>
  214. <action>Run linting and code quality checks if configured in project</action>
  215. <action>Validate implementation meets ALL story acceptance criteria; enforce quantitative thresholds explicitly</action>
  216. <action if="regression tests fail">STOP and fix before continuing - identify breaking changes immediately</action>
  217. <action if="new tests fail">STOP and fix before continuing - ensure implementation correctness</action>
  218. </step>
  219. <step n="8" goal="Validate and mark task complete ONLY when fully done">
  220. <critical>NEVER mark a task complete unless ALL conditions are met - NO LYING OR CHEATING</critical>
  221. <!-- VALIDATION GATES -->
  222. <action>Verify ALL tests for this task/subtask ACTUALLY EXIST and PASS 100%</action>
  223. <action>Confirm implementation matches EXACTLY what the task/subtask specifies - no extra features</action>
  224. <action>Validate that ALL acceptance criteria related to this task are satisfied</action>
  225. <action>Run full test suite to ensure NO regressions introduced</action>
  226. <!-- REVIEW FOLLOW-UP HANDLING -->
  227. <check if="task is review follow-up (has [AI-Review] prefix)">
  228. <action>Extract review item details (severity, description, related AC/file)</action>
  229. <action>Add to resolution tracking list: {{resolved_review_items}}</action>
  230. <!-- Mark task in Review Follow-ups section -->
  231. <action>Mark task checkbox [x] in "Tasks/Subtasks → Review Follow-ups (AI)" section</action>
  232. <!-- CRITICAL: Also mark corresponding action item in review section -->
  233. <action>Find matching action item in "Senior Developer Review (AI) → Action Items" section by matching description</action>
  234. <action>Mark that action item checkbox [x] as resolved</action>
  235. <action>Add to Dev Agent Record → Completion Notes: "✅ Resolved review finding [{{severity}}]: {{description}}"</action>
  236. </check>
  237. <!-- ONLY MARK COMPLETE IF ALL VALIDATION PASS -->
  238. <check if="ALL validation gates pass AND tests ACTUALLY exist and pass">
  239. <action>ONLY THEN mark the task (and subtasks) checkbox with [x]</action>
  240. <action>Update File List section with ALL new, modified, or deleted files (paths relative to repo root)</action>
  241. <action>Add completion notes to Dev Agent Record summarizing what was ACTUALLY implemented and tested</action>
  242. </check>
  243. <check if="ANY validation fails">
  244. <action>DO NOT mark task complete - fix issues first</action>
  245. <action>HALT if unable to fix validation failures</action>
  246. </check>
  247. <check if="review_continuation == true and {{resolved_review_items}} is not empty">
  248. <action>Count total resolved review items in this session</action>
  249. <action>Add Change Log entry: "Addressed code review findings - {{resolved_count}} items resolved (Date: {{date}})"</action>
  250. </check>
  251. <action>Save the story file</action>
  252. <action>Determine if more incomplete tasks remain</action>
  253. <action if="more tasks remain">
  254. <goto step="5">Next task</goto>
  255. </action>
  256. <action if="no tasks remain">
  257. <goto step="9">Completion</goto>
  258. </action>
  259. </step>
  260. <step n="9" goal="Story completion and mark for review" tag="sprint-status">
  261. <action>Verify ALL tasks and subtasks are marked [x] (re-scan the story document now)</action>
  262. <action>Run the full regression suite (do not skip)</action>
  263. <action>Confirm File List includes every changed file</action>
  264. <action>Execute enhanced definition-of-done validation</action>
  265. <action>Update the story Status to: "review"</action>
  266. <!-- Enhanced Definition of Done Validation -->
  267. <action>Validate definition-of-done checklist with essential requirements:
  268. - All tasks/subtasks marked complete with [x]
  269. - Implementation satisfies every Acceptance Criterion
  270. - Unit tests for core functionality added/updated
  271. - Integration tests for component interactions added when required
  272. - End-to-end tests for critical flows added when story demands them
  273. - All tests pass (no regressions, new tests successful)
  274. - Code quality checks pass (linting, static analysis if configured)
  275. - File List includes every new/modified/deleted file (relative paths)
  276. - Dev Agent Record contains implementation notes
  277. - Change Log includes summary of changes
  278. - Only permitted story sections were modified
  279. </action>
  280. <!-- Mark story ready for review - sprint status conditional -->
  281. <check if="{sprint_status} file exists AND {{current_sprint_status}} != 'no-sprint-tracking'">
  282. <action>Load the FULL file: {sprint_status}</action>
  283. <action>Find development_status key matching {{story_key}}</action>
  284. <action>Verify current status is "in-progress" (expected previous state)</action>
  285. <action>Update development_status[{{story_key}}] = "review"</action>
  286. <action>Save file, preserving ALL comments and structure including STATUS DEFINITIONS</action>
  287. <output>✅ Story status updated to "review" in sprint-status.yaml</output>
  288. </check>
  289. <check if="{sprint_status} file does NOT exist OR {{current_sprint_status}} == 'no-sprint-tracking'">
  290. <output>ℹ️ Story status updated to "review" in story file (no sprint tracking configured)</output>
  291. </check>
  292. <check if="story key not found in sprint status">
  293. <output>⚠️ Story file updated, but sprint-status update failed: {{story_key}} not found
  294. Story status is set to "review" in file, but sprint-status.yaml may be out of sync.
  295. </output>
  296. </check>
  297. <!-- Final validation gates -->
  298. <action if="any task is incomplete">HALT - Complete remaining tasks before marking ready for review</action>
  299. <action if="regression failures exist">HALT - Fix regression issues before completing</action>
  300. <action if="File List is incomplete">HALT - Update File List with all changed files</action>
  301. <action if="definition-of-done validation fails">HALT - Address DoD failures before completing</action>
  302. </step>
  303. <step n="10" goal="Completion communication and user support">
  304. <action>Execute the enhanced definition-of-done checklist using the validation framework</action>
  305. <action>Prepare a concise summary in Dev Agent Record → Completion Notes</action>
  306. <action>Communicate to {user_name} that story implementation is complete and ready for review</action>
  307. <action>Summarize key accomplishments: story ID, story key, title, key changes made, tests added, files modified</action>
  308. <action>Provide the story file path and current status (now "review")</action>
  309. <action>Based on {user_skill_level}, ask if user needs any explanations about:
  310. - What was implemented and how it works
  311. - Why certain technical decisions were made
  312. - How to test or verify the changes
  313. - Any patterns, libraries, or approaches used
  314. - Anything else they'd like clarified
  315. </action>
  316. <check if="user asks for explanations">
  317. <action>Provide clear, contextual explanations tailored to {user_skill_level}</action>
  318. <action>Use examples and references to specific code when helpful</action>
  319. </check>
  320. <action>Once explanations are complete (or user indicates no questions), suggest logical next steps</action>
  321. <action>Recommended next steps (flexible based on project setup):
  322. - Review the implemented story and test the changes
  323. - Verify all acceptance criteria are met
  324. - Ensure deployment readiness if applicable
  325. - Run `code-review` workflow for peer review
  326. - Optional: Run TEA `*automate` to expand guardrail tests
  327. </action>
  328. <output>💡 **Tip:** For best results, run `code-review` using a **different** LLM than the one that implemented this story.</output>
  329. <check if="{sprint_status} file exists">
  330. <action>Suggest checking {sprint_status} to see project progress</action>
  331. </check>
  332. <action>Remain flexible - allow user to choose their own path or ask for other assistance</action>
  333. </step>
  334. </workflow>