您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

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