Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429
  1. ---
  2. name: bmad-create-story
  3. description: 'Creates a dedicated story file with all the context the agent will need to implement it later. Use when the user says "create the next story" or "create story [story identifier]"'
  4. ---
  5. # Create Story Workflow
  6. **Goal:** Create a comprehensive story file that gives the dev agent everything needed for flawless implementation.
  7. **Your Role:** Story context engine that prevents LLM developer mistakes, omissions, or disasters.
  8. - Communicate all responses in {communication_language} and generate all documents in {document_output_language}
  9. - Your purpose is NOT to copy from epics - it's to create a comprehensive, optimized story file that gives the DEV agent EVERYTHING needed for flawless implementation
  10. - COMMON LLM MISTAKES TO PREVENT: reinventing wheels, wrong libraries, wrong file locations, breaking regressions, ignoring UX, vague implementations, lying about completion, not learning from past work
  11. - EXHAUSTIVE ANALYSIS REQUIRED: You must thoroughly analyze ALL artifacts to extract critical context - do NOT be lazy or skim! This is the most important function in the entire development process!
  12. - UTILIZE SUBPROCESSES AND SUBAGENTS: Use research subagents, subprocesses or parallel processing if available to thoroughly analyze different artifacts simultaneously and thoroughly
  13. - SAVE QUESTIONS: If you think of questions or clarifications during analysis, save them for the end after the complete story is written
  14. - ZERO USER INTERVENTION: Process should be fully automated except for initial epic/story selection or missing documents
  15. ## Conventions
  16. - Bare paths (e.g. `discover-inputs.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. - `planning_artifacts`, `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. - `sprint_status` = `{implementation_artifacts}/sprint-status.yaml`
  46. - `epics_file` = `{planning_artifacts}/epics.md`
  47. - `prd_file` = `{planning_artifacts}/prd.md`
  48. - `architecture_file` = `{planning_artifacts}/architecture.md`
  49. - `ux_file` = `{planning_artifacts}/*ux*.md`
  50. - `story_title` = "" (will be elicited if not derivable)
  51. - `default_output_file` = `{implementation_artifacts}/{{story_key}}.md`
  52. ## Input Files
  53. | Input | Description | Path Pattern(s) | Load Strategy |
  54. |-------|-------------|------------------|---------------|
  55. | prd | PRD (fallback - epics file should have most content) | whole: `{planning_artifacts}/*prd*.md`, sharded: `{planning_artifacts}/*prd*/*.md` | SELECTIVE_LOAD |
  56. | architecture | Architecture (fallback - epics file should have relevant sections) | whole: `{planning_artifacts}/*architecture*.md`, sharded: `{planning_artifacts}/*architecture*/*.md` | SELECTIVE_LOAD |
  57. | ux | UX design (fallback - epics file should have relevant sections) | whole: `{planning_artifacts}/*ux*.md`, sharded: `{planning_artifacts}/*ux*/*.md` | SELECTIVE_LOAD |
  58. | epics | Enhanced epics+stories file with BDD and source hints | whole: `{planning_artifacts}/*epic*.md`, sharded: `{planning_artifacts}/*epic*/*.md` | SELECTIVE_LOAD |
  59. ## Execution
  60. <workflow>
  61. <step n="1" goal="Determine target story">
  62. <check if="{{story_path}} is provided by user or user provided the epic and story number such as 2-4 or 1.6 or epic 1 story 5">
  63. <action>Parse user-provided story path: extract epic_num, story_num, story_title from format like "1-2-user-auth"</action>
  64. <action>Set {{epic_num}}, {{story_num}}, {{story_key}} from user input</action>
  65. <action>GOTO step 2a</action>
  66. </check>
  67. <action>Check if {{sprint_status}} file exists for auto discover</action>
  68. <check if="sprint status file does NOT exist">
  69. <output>🚫 No sprint status file found and no story specified</output>
  70. <output>
  71. **Required Options:**
  72. 1. Run `sprint-planning` to initialize sprint tracking (recommended)
  73. 2. Provide specific epic-story number to create (e.g., "1-2-user-auth")
  74. 3. Provide path to story documents if sprint status doesn't exist yet
  75. </output>
  76. <ask>Choose option [1], provide epic-story number, path to story docs, or [q] to quit:</ask>
  77. <check if="user chooses 'q'">
  78. <action>HALT - No work needed</action>
  79. </check>
  80. <check if="user chooses '1'">
  81. <output>Run sprint-planning workflow first to create sprint-status.yaml</output>
  82. <action>HALT - User needs to run sprint-planning</action>
  83. </check>
  84. <check if="user provides epic-story number">
  85. <action>Parse user input: extract epic_num, story_num, story_title</action>
  86. <action>Set {{epic_num}}, {{story_num}}, {{story_key}} from user input</action>
  87. <action>GOTO step 2a</action>
  88. </check>
  89. <check if="user provides story docs path">
  90. <action>Use user-provided path for story documents</action>
  91. <action>GOTO step 2a</action>
  92. </check>
  93. </check>
  94. <!-- Auto-discover from sprint status only if no user input -->
  95. <check if="no user input provided">
  96. <critical>MUST read COMPLETE {sprint_status} file from start to end to preserve order</critical>
  97. <action>Load the FULL file: {{sprint_status}}</action>
  98. <action>Read ALL lines from beginning to end - do not skip any content</action>
  99. <action>Parse the development_status section completely</action>
  100. <action>Find the FIRST story (by reading in order from top to bottom) where:
  101. - Key matches pattern: number-number-name (e.g., "1-2-user-auth")
  102. - NOT an epic key (epic-X) or retrospective (epic-X-retrospective)
  103. - Status value equals "backlog"
  104. </action>
  105. <check if="no backlog story found">
  106. <output>📋 No backlog stories found in sprint-status.yaml
  107. All stories are either already created, in progress, or done.
  108. **Options:**
  109. 1. Run sprint-planning to refresh story tracking
  110. 2. Load PM agent and run correct-course to add more stories
  111. 3. Check if current sprint is complete and run retrospective
  112. </output>
  113. <action>HALT</action>
  114. </check>
  115. <action>Extract from found story key (e.g., "1-2-user-authentication"):
  116. - epic_num: first number before dash (e.g., "1")
  117. - story_num: second number after first dash (e.g., "2")
  118. - story_title: remainder after second dash (e.g., "user-authentication")
  119. </action>
  120. <action>Set {{story_id}} = "{{epic_num}}.{{story_num}}"</action>
  121. <action>Store story_key for later use (e.g., "1-2-user-authentication")</action>
  122. <!-- Mark epic as in-progress if this is first story -->
  123. <action>Check if this is the first story in epic {{epic_num}} by looking for {{epic_num}}-1-* pattern</action>
  124. <check if="this is first story in epic {{epic_num}}">
  125. <action>Load {{sprint_status}} and check epic-{{epic_num}} status</action>
  126. <action>If epic status is "backlog" → update to "in-progress"</action>
  127. <action>If epic status is "contexted" (legacy status) → update to "in-progress" (backward compatibility)</action>
  128. <action>If epic status is "in-progress" → no change needed</action>
  129. <check if="epic status is 'done'">
  130. <output>🚫 ERROR: Cannot create story in completed epic</output>
  131. <output>Epic {{epic_num}} is marked as 'done'. All stories are complete.</output>
  132. <output>If you need to add more work, either:</output>
  133. <output>1. Manually change epic status back to 'in-progress' in sprint-status.yaml</output>
  134. <output>2. Create a new epic for additional work</output>
  135. <action>HALT - Cannot proceed</action>
  136. </check>
  137. <check if="epic status is not one of: backlog, contexted, in-progress, done">
  138. <output>🚫 ERROR: Invalid epic status '{{epic_status}}'</output>
  139. <output>Epic {{epic_num}} has invalid status. Expected: backlog, in-progress, or done</output>
  140. <output>Please fix sprint-status.yaml manually or run sprint-planning to regenerate</output>
  141. <action>HALT - Cannot proceed</action>
  142. </check>
  143. <output>📊 Epic {{epic_num}} status updated to in-progress</output>
  144. </check>
  145. <action>GOTO step 2a</action>
  146. </check>
  147. <action>Load the FULL file: {{sprint_status}}</action>
  148. <action>Read ALL lines from beginning to end - do not skip any content</action>
  149. <action>Parse the development_status section completely</action>
  150. <action>Find the FIRST story (by reading in order from top to bottom) where:
  151. - Key matches pattern: number-number-name (e.g., "1-2-user-auth")
  152. - NOT an epic key (epic-X) or retrospective (epic-X-retrospective)
  153. - Status value equals "backlog"
  154. </action>
  155. <check if="no backlog story found">
  156. <output>No backlog stories found in sprint-status.yaml
  157. All stories are either already created, in progress, or done.
  158. **Options:**
  159. 1. Run sprint-planning to refresh story tracking
  160. 2. Load PM agent and run correct-course to add more stories
  161. 3. Check if current sprint is complete and run retrospective
  162. </output>
  163. <action>HALT</action>
  164. </check>
  165. <action>Extract from found story key (e.g., "1-2-user-authentication"):
  166. - epic_num: first number before dash (e.g., "1")
  167. - story_num: second number after first dash (e.g., "2")
  168. - story_title: remainder after second dash (e.g., "user-authentication")
  169. </action>
  170. <action>Set {{story_id}} = "{{epic_num}}.{{story_num}}"</action>
  171. <action>Store story_key for later use (e.g., "1-2-user-authentication")</action>
  172. <!-- Mark epic as in-progress if this is first story -->
  173. <action>Check if this is the first story in epic {{epic_num}} by looking for {{epic_num}}-1-* pattern</action>
  174. <check if="this is first story in epic {{epic_num}}">
  175. <action>Load {{sprint_status}} and check epic-{{epic_num}} status</action>
  176. <action>If epic status is "backlog" → update to "in-progress"</action>
  177. <action>If epic status is "contexted" (legacy status) → update to "in-progress" (backward compatibility)</action>
  178. <action>If epic status is "in-progress" → no change needed</action>
  179. <check if="epic status is 'done'">
  180. <output>ERROR: Cannot create story in completed epic</output>
  181. <output>Epic {{epic_num}} is marked as 'done'. All stories are complete.</output>
  182. <output>If you need to add more work, either:</output>
  183. <output>1. Manually change epic status back to 'in-progress' in sprint-status.yaml</output>
  184. <output>2. Create a new epic for additional work</output>
  185. <action>HALT - Cannot proceed</action>
  186. </check>
  187. <check if="epic status is not one of: backlog, contexted, in-progress, done">
  188. <output>ERROR: Invalid epic status '{{epic_status}}'</output>
  189. <output>Epic {{epic_num}} has invalid status. Expected: backlog, in-progress, or done</output>
  190. <output>Please fix sprint-status.yaml manually or run sprint-planning to regenerate</output>
  191. <action>HALT - Cannot proceed</action>
  192. </check>
  193. <output>Epic {{epic_num}} status updated to in-progress</output>
  194. </check>
  195. <action>GOTO step 2a</action>
  196. </step>
  197. <step n="2" goal="Load and analyze core artifacts">
  198. <critical>🔬 EXHAUSTIVE ARTIFACT ANALYSIS - This is where you prevent future developer mistakes!</critical>
  199. <!-- Load all available content through discovery protocol -->
  200. <action>Read fully and follow `./discover-inputs.md` to load all input files</action>
  201. <note>Available content: {epics_content}, {prd_content}, {architecture_content}, {ux_content}, plus the project-context facts loaded during activation via `persistent_facts`.</note>
  202. <!-- Analyze epics file for story foundation -->
  203. <action>From {epics_content}, extract Epic {{epic_num}} complete context:</action> **EPIC ANALYSIS:** - Epic
  204. objectives and business value - ALL stories in this epic for cross-story context - Our specific story's requirements, user story
  205. statement, acceptance criteria - Technical requirements and constraints - Dependencies on other stories/epics - Source hints pointing to
  206. original documents <!-- Extract specific story requirements -->
  207. <action>Extract our story ({{epic_num}}-{{story_num}}) details:</action> **STORY FOUNDATION:** - User story statement
  208. (As a, I want, so that) - Detailed acceptance criteria (already BDD formatted) - Technical requirements specific to this story -
  209. Business context and value - Success criteria <!-- Previous story analysis for context continuity -->
  210. <check if="story_num > 1">
  211. <action>Find {{previous_story_num}}: scan {implementation_artifacts} for the story file in epic {{epic_num}} with the highest story number less than {{story_num}}</action>
  212. <action>Load previous story file: {implementation_artifacts}/{{epic_num}}-{{previous_story_num}}-*.md</action> **PREVIOUS STORY INTELLIGENCE:** -
  213. Dev notes and learnings from previous story - Review feedback and corrections needed - Files that were created/modified and their
  214. patterns - Testing approaches that worked/didn't work - Problems encountered and solutions found - Code patterns established <action>Extract
  215. all learnings that could impact current story implementation</action>
  216. </check>
  217. <!-- Git intelligence for previous work patterns -->
  218. <check
  219. if="previous story exists AND git repository detected">
  220. <action>Get last 5 commit titles to understand recent work patterns</action>
  221. <action>Analyze 1-5 most recent commits for relevance to current story:
  222. - Files created/modified
  223. - Code patterns and conventions used
  224. - Library dependencies added/changed
  225. - Architecture decisions implemented
  226. - Testing approaches used
  227. </action>
  228. <action>Extract actionable insights for current story implementation</action>
  229. </check>
  230. </step>
  231. <step n="3" goal="Architecture analysis for developer guardrails">
  232. <critical>🏗️ ARCHITECTURE INTELLIGENCE - Extract everything the developer MUST follow!</critical> **ARCHITECTURE DOCUMENT ANALYSIS:** <action>Systematically
  233. analyze architecture content for story-relevant requirements:</action>
  234. <!-- Load architecture - single file or sharded -->
  235. <check if="architecture file is single file">
  236. <action>Load complete {architecture_content}</action>
  237. </check>
  238. <check if="architecture is sharded to folder">
  239. <action>Load architecture index and scan all architecture files</action>
  240. </check> **CRITICAL ARCHITECTURE EXTRACTION:** <action>For
  241. each architecture section, determine if relevant to this story:</action> - **Technical Stack:** Languages, frameworks, libraries with
  242. versions - **Code Structure:** Folder organization, naming conventions, file patterns - **API Patterns:** Service structure, endpoint
  243. patterns, data contracts - **Database Schemas:** Tables, relationships, constraints relevant to story - **Security Requirements:**
  244. Authentication patterns, authorization rules - **Performance Requirements:** Caching strategies, optimization patterns - **Testing
  245. Standards:** Testing frameworks, coverage expectations, test patterns - **Deployment Patterns:** Environment configurations, build
  246. processes - **Integration Patterns:** External service integrations, data flows <action>Extract any story-specific requirements that the
  247. developer MUST follow</action>
  248. <action>Identify any architectural decisions that override previous patterns</action>
  249. <!-- Read existing code being modified — non-negotiable -->
  250. <critical>📂 READ FILES BEING MODIFIED — skipping this is the primary cause of implementation failures and review cycles</critical>
  251. <action>From the architecture directory structure, identify every file marked UPDATE (not NEW) that this story will touch</action>
  252. <action>Read each relevant UPDATE file completely. For each one, document in dev notes:
  253. - Current state: what it does today (state machine, API calls, data shapes, existing behaviors)
  254. - What this story changes: the specific sections or behaviors being modified
  255. - What must be preserved: existing interactions and behaviors the story must not break
  256. </action>
  257. <critical>A story implementation must leave the system working end-to-end — not just satisfy its stated ACs.
  258. If a behavior is required for the feature to work correctly in the existing system, it is a requirement
  259. whether or not it is explicitly written in the story. The dev agent owns this.</critical>
  260. </step>
  261. <step n="4" goal="Web research for latest technical specifics">
  262. <critical>🌐 ENSURE LATEST TECH KNOWLEDGE - Prevent outdated implementations!</critical> **WEB INTELLIGENCE:** <action>Identify specific
  263. technical areas that require latest version knowledge:</action>
  264. <!-- Check for libraries/frameworks mentioned in architecture -->
  265. <action>From architecture analysis, identify specific libraries, APIs, or
  266. frameworks</action>
  267. <action>For each critical technology, research latest stable version and key changes:
  268. - Latest API documentation and breaking changes
  269. - Security vulnerabilities or updates
  270. - Performance improvements or deprecations
  271. - Best practices for current version
  272. </action>
  273. **EXTERNAL CONTEXT INCLUSION:** <action>Include in story any critical latest information the developer needs:
  274. - Specific library versions and why chosen
  275. - API endpoints with parameters and authentication
  276. - Recent security patches or considerations
  277. - Performance optimization techniques
  278. - Migration considerations if upgrading
  279. </action>
  280. </step>
  281. <step n="5" goal="Create comprehensive story file">
  282. <critical>📝 CREATE ULTIMATE STORY FILE - The developer's master implementation guide!</critical>
  283. <action>Initialize from template.md:
  284. {default_output_file}</action>
  285. <template-output file="{default_output_file}">story_header</template-output>
  286. <!-- Story foundation from epics analysis -->
  287. <template-output
  288. file="{default_output_file}">story_requirements</template-output>
  289. <!-- Developer context section - MOST IMPORTANT PART -->
  290. <template-output file="{default_output_file}">
  291. developer_context_section</template-output> **DEV AGENT GUARDRAILS:** <template-output file="{default_output_file}">
  292. technical_requirements</template-output>
  293. <template-output file="{default_output_file}">architecture_compliance</template-output>
  294. <template-output
  295. file="{default_output_file}">library_framework_requirements</template-output>
  296. <template-output file="{default_output_file}">
  297. file_structure_requirements</template-output>
  298. <template-output file="{default_output_file}">testing_requirements</template-output>
  299. <!-- Previous story intelligence -->
  300. <check
  301. if="previous story learnings available">
  302. <template-output file="{default_output_file}">previous_story_intelligence</template-output>
  303. </check>
  304. <!-- Git intelligence -->
  305. <check
  306. if="git analysis completed">
  307. <template-output file="{default_output_file}">git_intelligence_summary</template-output>
  308. </check>
  309. <!-- Latest technical specifics -->
  310. <check if="web research completed">
  311. <template-output file="{default_output_file}">latest_tech_information</template-output>
  312. </check>
  313. <!-- Project context reference -->
  314. <template-output
  315. file="{default_output_file}">project_context_reference</template-output>
  316. <!-- Final status update -->
  317. <template-output file="{default_output_file}">
  318. story_completion_status</template-output>
  319. <!-- CRITICAL: Set status to ready-for-dev -->
  320. <action>Set story Status to: "ready-for-dev"</action>
  321. <action>Add completion note: "Ultimate
  322. context engine analysis completed - comprehensive developer guide created"</action>
  323. </step>
  324. <step n="6" goal="Update sprint status and finalize">
  325. <action>Validate the newly created story file {default_output_file} against `./checklist.md` and apply any required fixes before finalizing</action>
  326. <action>Save story document unconditionally</action>
  327. <!-- Update sprint status -->
  328. <check if="sprint status file exists">
  329. <action>Update {{sprint_status}}</action>
  330. <action>Load the FULL file and read all development_status entries</action>
  331. <action>Find development_status key matching {{story_key}}</action>
  332. <action>Verify current status is "backlog" (expected previous state)</action>
  333. <action>Update development_status[{{story_key}}] = "ready-for-dev"</action>
  334. <action>Update last_updated field to current date</action>
  335. <action>Save file, preserving ALL comments and structure including STATUS DEFINITIONS</action>
  336. </check>
  337. <action>Report completion</action>
  338. <output>**🎯 ULTIMATE BMad Method STORY CONTEXT CREATED, {user_name}!**
  339. **Story Details:**
  340. - Story ID: {{story_id}}
  341. - Story Key: {{story_key}}
  342. - File: {{story_file}}
  343. - Status: ready-for-dev
  344. **Next Steps:**
  345. 1. Review the comprehensive story in {{story_file}}
  346. 2. Run dev agents `dev-story` for optimized implementation
  347. 3. Run `code-review` when complete (auto-marks done)
  348. 4. Optional: If Test Architect module installed, run `/bmad:tea:automate` after `dev-story` to generate guardrail tests
  349. **The developer now has everything needed for flawless implementation!**
  350. </output>
  351. <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>
  352. </step>
  353. </workflow>