# Create Story - Workflow Instructions (Spec-compliant, non-interactive by default) ```xml The workflow execution engine is governed by: {project_root}/bmad/core/tasks/workflow.xml You MUST have already loaded and processed: {installed_path}/workflow.yaml Generate all documents in {document_output_language} This workflow creates or updates the next user story from epics/PRD and architecture context, saving to the configured stories directory and optionally invoking Story Context. DOCUMENT OUTPUT: Concise, technical, actionable story specifications. Use tables/lists for acceptance criteria and tasks. Resolve variables from config_source: story_dir (dev_story_location), output_folder, user_name, communication_language. If story_dir missing and {{non_interactive}} == false → ASK user to provide a stories directory and update variable. If {{non_interactive}} == true and missing, HALT with a clear message. Create {{story_dir}} if it does not exist Resolve installed component paths from workflow.yaml: template, instructions, validation Resolve recommended inputs if present: epics_file, prd_file, architecture_file If {{tech_spec_file}} empty: derive from {{tech_spec_glob_template}} with {{epic_num}} and search {{tech_spec_search_dir}} recursively. If multiple, pick most recent by modified time. Build a prioritized document set for this epic: 1) tech_spec_file (epic-scoped) 2) epics_file (acceptance criteria and breakdown) 3) prd_file (business requirements and constraints) 4) architecture_file (architecture constraints) 5) Architecture docs under docs/ and output_folder/: tech-stack.md, unified-project-structure.md, coding-standards.md, testing-strategy.md, backend-architecture.md, frontend-architecture.md, data-models.md, database-schema.md, rest-api-spec.md, external-apis.md (include if present) READ COMPLETE FILES for all items found in the prioritized set. Store content and paths for citation. Query sprint-status for next backlog story: action: get_next_story filter_status: backlog 📋 No backlog stories found in sprint-status.yaml All stories are either already drafted or completed. **Options:** 1. Run sprint-planning to refresh story tracking 2. Load PM agent and run correct-course to add more stories 3. Check if current sprint is complete HALT Parse {{result_story_key}} to extract epic_num, story_num, and story_title Example: "1-2-user-authentication" → epic_num=1, story_num=2, title="user-authentication" Set {{story_id}} = "{{epic_num}}.{{story_num}}" Verify story is enumerated in {{epics_file}}. If not found, HALT with message: "Story {{result_story_key}} not found in epics.md. Please load PM agent and run correct-course to sync epics, then rerun create-story." Check if story file already exists at expected path in {{story_dir}} â„šī¸ Story file already exists: {{story_file_path}} Will update existing story file rather than creating new one. Set update_mode = true From tech_spec_file (preferred) or epics_file: extract epic {{epic_num}} title/summary, acceptance criteria for the next story, and any component references. If not present, fall back to PRD sections mapping to this epic/story. From architecture and architecture docs: extract constraints, patterns, component boundaries, and testing guidance relevant to the extracted ACs. ONLY capture information that directly informs implementation of this story. Derive a clear user story statement (role, action, benefit) grounded strictly in the above sources. If ambiguous and {{non_interactive}} == false → ASK user to clarify. If {{non_interactive}} == true → generate the best grounded statement WITHOUT inventing domain facts. requirements_context_summary If a previous story exists, scan its "Dev Agent Record" for completion notes and known deviations; summarize any carry-overs relevant to this story. If unified-project-structure.md present: align expected file paths, module names, and component locations; note any potential conflicts. structure_alignment_summary Assemble acceptance criteria list from tech_spec or epics. If gaps exist, derive minimal, testable criteria from PRD verbatim phrasing (NO invention). Create tasks/subtasks directly mapped to ACs. Include explicit testing subtasks per testing-strategy and existing tests framework. Cite architecture/source documents for any technical mandates. acceptance_criteria tasks_subtasks Resolve output path: {default_output_file} using current {{epic_num}} and {{story_num}}. If targeting an existing story for update, use its path. Initialize from template.md if creating a new file; otherwise load existing file for edit. Compute a concise story_title from epic/story context; if missing, synthesize from PRD feature name and epic number. story_header story_body dev_notes_with_citations change_log Validate against checklist at {installed_path}/checklist.md using bmad/core/tasks/validate-workflow.xml Save document unconditionally (non-interactive default). In interactive mode, allow user confirmation. action: update_story_status story_key: {{result_story_key}} new_status: drafted validate: true âš ī¸ Could not update story status: {{result_error}} Story file was created successfully, but sprint-status.yaml was not updated. You may need to run sprint-planning to refresh tracking. If {{auto_run_context}} == true → Pass {{story_path}} = {default_output_file} Report created/updated story path **✅ Story Created Successfully, {user_name}!** **Story Details:** - Story ID: {{story_id}} - Story Key: {{result_story_key}} - File: {{story_file}} - Status: {{result_new_status}} (was {{result_old_status}}) **Next Steps:** 1. Review the drafted story in {{story_file}} 2. When satisfied, run `story-ready` to approve for development 3. Or edit the story file and re-run `create-story` to update ```