# Implement Workflow (Bug Fix or Feature) ```xml This workflow loads bug/feature context, implements the code, and updates tracking in both bugs.yaml and bugs.md Communicate in {communication_language} with {user_name} Auto-detects type from ID format: bug-NNN = bug fix, feature-NNN = feature implementation Which bug or feature should I implement? (e.g., bug-026 or feature-021) Extract item ID from user input Detect type from ID format: - "bug-NNN" -> type = "bug", action_verb = "fix", past_verb = "Fixed" - "feature-NNN" -> type = "feature", action_verb = "implement", past_verb = "Implemented" Invalid ID format. Use bug-NNN (e.g., bug-026) or feature-NNN (e.g., feature-021) HALT Search for {item_id} in {bugs_yaml} using grep with 50+ lines of context after the match (do NOT read entire file - it exceeds token limits) Entry will be in bugs section, grep will capture all fields Entry will be in feature_requests section, grep will capture all fields {item_id} not found in bugs.yaml. Please verify the ID or run bug-tracking workflow first. HALT Extract and store metadata: - title: Title/summary - description: Full description - severity/priority: Importance level - complexity: trivial | small | medium | complex - effort_estimate: Estimated hours - affected_platform: all | ios | android (bugs only) - related_story/related_epic: Related items if applicable - doc_impact: Documentation impact flags (prd, architecture, ux) and notes - notes: Triage notes including planned approach, files to check, implementation strategy **BACKLOG ITEM - NOT READY FOR IMPLEMENTATION** **{item_id}: {title}** This item has `recommended_workflow: backlog` which means it's deferred and not scheduled for implementation. **To implement this item, first promote it to the sprint:** 1. Run `*sprint-planning` and select this item for promotion 2. Or manually update bugs.yaml: change `recommended_workflow` to `direct-fix`, `tech-spec`, or `correct-course` **Current Status:** {status} **Priority:** {priority} **Complexity:** {complexity} HALT **DEFERRED ITEM - NOT READY FOR IMPLEMENTATION** **{item_id}: {title}** This item is deferred (marked for future release, not current MVP). **To implement this item:** 1. Update bugs.yaml: change `status` from `deferred` to `backlog` 2. Run `*sprint-planning` to promote to current sprint **Notes:** {notes} HALT **BLOCKED ITEM - CANNOT IMPLEMENT** **{item_id}: {title}** This item is blocked and requires clarification before implementation. **Blocking reason:** {notes} **To unblock:** 1. Resolve the blocking issue 2. Update bugs.yaml: change `status` from `blocked` to `backlog` 3. Run `/triage {item_id}` to re-evaluate HALT Check doc_impact fields from bugs.yaml entry **DOCUMENTATION IMPACT DETECTED** **{item_id}: {title}** This {type} requires documentation updates BEFORE implementation: {if doc_impact.prd:} - **PRD Impact:** Updates needed to product requirements -> Route to PM Agent for PRD updates {end if} {if doc_impact.architecture:} - **Architecture Impact:** Updates needed to architecture docs -> Route to Architect Agent for architecture updates {end if} {if doc_impact.ux:} - **UX Impact:** Updates needed to UX specifications -> Route to UX Designer Agent for UX spec updates {end if} **Details:** {doc_impact.notes} **Options:** 1. **update-docs-first** - Route to agents for documentation updates before implementation (recommended) 2. **proceed-anyway** - Skip documentation updates and implement directly (not recommended) 3. **cancel** - Return to review How should we proceed? Routing to documentation update workflow... **Documentation Update Sequence:** 1. **PRD Update** - Invoking PM Agent... Prepare PRD update context: - Source item: {item_id} - Change description: {description} - Specific PRD sections: {doc_impact.notes PRD sections} Review and update PRD for {item_id}: {title} Change context: {description} Documentation notes: {doc_impact.notes} Please update the relevant PRD sections to reflect this change. After updates: 1. Summarize what was changed 2. Return to the implement workflow by running: /implement {item_id} IMPORTANT: You MUST return to /implement {item_id} after completing the PRD updates so the actual code implementation can proceed. 2. **Architecture Update** - Invoking Architect Agent... Prepare architecture update context: - Source item: {item_id} - Change description: {description} - Specific architecture sections: {doc_impact.notes architecture sections} Review and update Architecture documentation for {item_id}: {title} Change context: {description} Documentation notes: {doc_impact.notes} Please update the relevant architecture sections (data model, APIs, security, etc.) to reflect this change. After updates: 1. Summarize what was changed 2. Return to the implement workflow by running: /implement {item_id} IMPORTANT: You MUST return to /implement {item_id} after completing the architecture updates so the actual code implementation can proceed. 3. **UX Spec Update** - Invoking UX Designer Agent... Prepare UX update context: - Source item: {item_id} - Change description: {description} - Specific UX sections: {doc_impact.notes UX sections} Review and update UX specification for {item_id}: {title} Change context: {description} Documentation notes: {doc_impact.notes} Please update the relevant UX spec sections (screens, flows, components, etc.) to reflect this change. After updates: 1. Summarize what was changed 2. Return to the implement workflow by running: /implement {item_id} IMPORTANT: You MUST return to /implement {item_id} after completing the UX updates so the actual code implementation can proceed. **Documentation updates complete.** Proceeding with implementation... Continue to step 3 Cancelled. {item_id} remains in current state. HALT Proceeding without documentation updates. Remember to update docs after implementation. Continue to step 3 Check recommended_workflow field from bugs.yaml **AUTO-ROUTING TO CORRECT-COURSE** **{item_id}: {title}** **Priority:** {severity_or_priority} | **Complexity:** {complexity} This {type} has `recommended_workflow: correct-course` which requires impact analysis and story creation before implementation. Invoking correct-course workflow via SM agent... Invoke the correct-course workflow skill with item context {item_id}: {title} - {description} Priority: {severity_or_priority} Complexity: {complexity} Doc Impact: {doc_impact summary} Notes: {notes} HALT - Correct Course workflow will handle story/epic creation **AUTO-ROUTING TO TECH-SPEC** **{item_id}: {title}** This {type} has `recommended_workflow: tech-spec`. Invoking tech-spec workflow... {item_id}: {title} - {description} HALT - Tech-spec workflow will create implementation spec **DIRECT IMPLEMENTATION** This {type} is routed for direct implementation. Proceeding... Continue to step 4 Evaluate the workflow routing matrix based on severity and complexity: **Routing Matrix:** - critical + any -> correct-course - high/medium + medium/complex -> correct-course - high + trivial -> direct-fix - high/medium + small -> tech-spec - medium + trivial -> direct-fix - low + trivial -> direct-fix - low + small+ -> backlog Apply matrix to determine routing and continue accordingly **{item_id}: {title}** **Type:** {type} | **Severity/Priority:** {severity_or_priority} | **Complexity:** {complexity} | **Effort:** ~{effort_estimate}h **Description:** {description} **Planned Approach (from triage notes):** {notes} **Related:** {related_story} / {related_epic} Ready to {action_verb} this {type}? (yes/no/clarify) What additional context do you need? Gather clarification, update mental model Cancelled. {item_id} remains in current state. HALT Based on the notes/planned approach, identify files to modify or create Read each affected file to understand current implementation Implement following the planned approach: - Make minimal, targeted changes - Follow existing code patterns and style - Add comments only where logic is non-obvious - Do not over-engineer or add unrelated improvements - Do not add extra features or "nice to haves" For each file modified/created, track: - File path - What was changed/added - How it addresses the bug/feature Create new files following project conventions Add appropriate imports/exports The triage notes don't provide a clear approach. Based on my analysis, I suggest: {proposed_approach} Should I proceed with this approach? Run TypeScript compilation check: npm run check Fix compilation errors Re-run compilation check Compilation check passed. Search for {item_id} in both bugs.yaml and bugs.md using grep to check current status SYNC WARNING: {item_id} status mismatch detected - bugs.yaml: {yaml_status} - bugs.md: {md_status} Proceeding will update both files to "{new_status}". Update entry in bugs.yaml: - status: "fixed" - fixed_date: {date} (YYYY-MM-DD format) - status: "implemented" - implemented_date: {date} (YYYY-MM-DD format) - assigned_to: "dev-agent" - files_modified: {list of files changed/created during implementation} - Append to notes: "{past_verb} ({date}): {summary of changes made}" Write updated bugs.yaml Search for {item_id} in {bugs_md} using grep with surrounding context to locate the entry **8a. Remove from tracked section (if present)** Search for "{item_id}:" in "# Tracked Bugs" section Search for "{item_id}:" in "# Tracked Feature Requests" section If found, remove the entire entry (including any indented sub-items) **8b. Add to completed section (INSERT AT TOP - newest first)** Locate "# Fixed Bugs" section in bugs.md If section not found, create it INSERT AT TOP of section (immediately after "# Fixed Bugs" header): [IMPLEMENTED] {item_id}: {title} - {brief_description}. [Severity: {severity}, Platform: {platform}, Fixed: {date}, Verified: pending] - Fix: {description of what was fixed} - File(s): {list of modified files} Locate "# Implemented Features" section in bugs.md If section not found, create it before "# Fixed Bugs" INSERT AT TOP of section (immediately after "# Implemented Features" header): [IMPLEMENTED] {item_id}: {title} - {brief_description}. [Implemented: {date}, Platform: {platform}, Verified: pending] - Files: {list of modified/created files} - Features: {bullet list of what was implemented} Write updated bugs.md Search for {item_id} in both bugs.yaml and bugs.md using grep to validate updates Confirm {item_id} shows status "fixed"/"implemented" in bugs.yaml Confirm {item_id} has [IMPLEMENTED] tag in bugs.md SYNC ERROR: Files may be out of sync. Please verify manually: - bugs.yaml: Expected status "fixed"/"implemented" - bugs.md: Expected [IMPLEMENTED] tag in appropriate section **{item_id} {past_verb.upper()}** **Changes Made:** {for each modified file:} - {file_path}: {what was changed} {end for} **Updated Tracking:** - bugs.yaml: status -> "{status}", {date_field} -> {date}, files_modified updated - bugs.md: Moved to "{target_section}" with [IMPLEMENTED] tag **Verification Status:** pending **Next Steps:** 1. Test manually 2. Run `/verify {item_id}` after verification to close ``` ## Usage ``` /implement bug-026 /implement feature-021 ``` ## Key Principles 1. **Auto-detect Type** - ID format determines bug vs feature handling 2. **Context First** - Always read and present details before implementing 3. **Confirm Approach** - Validate planned approach with user before coding 4. **Minimal Changes** - Only implement what's needed, no scope creep 5. **Dual Tracking** - ALWAYS update both bugs.yaml AND bugs.md 6. **[IMPLEMENTED] Tag** - Indicates complete but awaiting verification --- ## Reference: Bug Tracking Definitions ### Severity Levels | Level | Description | Action | |-------|-------------|--------| | **critical** | Blocks core functionality, prevents app use, or causes data loss (crashes, auth broken, data corruption) | Fix immediately, may require hotfix | | **high** | Major feature broken, significant UX degradation, workaround exists but painful (platform-specific failure, 5+ sec delays, accessibility blocker) | Fix in current/next sprint | | **medium** | Feature partially broken, UX degraded but usable (minor feature broken, unclear errors, 1-3 sec delays) | Fix when capacity allows | | **low** | Minor issue, cosmetic, edge case (typos, spacing, visual glitches) | Fix opportunistically or defer | ### Complexity Levels | Level | Description | Effort | |-------|-------------|--------| | **trivial** | Obvious fix, single line change, no investigation needed (typo, missing semicolon, wrong color) | < 30 minutes | | **small** | Single file/component, clear root cause, solution known (missing validation, incorrect prop, logic error) | 30 min - 2 hours | | **medium** | Multiple files affected OR investigation required (spans 2-3 components, debugging needed, integration issue) | 2-8 hours | | **complex** | Architectural issue, affects multiple stories, requires design changes (race conditions, refactoring, profiling) | 8+ hours (1-2 days) | ### Workflow Routing Matrix | Severity | Complexity | Workflow | Rationale | |----------|------------|----------|-----------| | critical | any | correct-course -> urgent | Need impact analysis even if small fix | | high | trivial | direct-fix (urgent) | Fast path for obvious important fix | | high | small | tech-spec (urgent) | Fast path with minimal overhead | | high | medium+ | correct-course -> story | Need proper analysis + testing | | medium | trivial | direct-fix | Too small for workflow overhead | | medium | small | tech-spec | Isolated fix needs spec | | medium | medium+ | correct-course -> story | Multi-file change needs story | | low | trivial | direct-fix (defer) | Fix opportunistically | | low | small+ | backlog (defer) | Document but don't schedule yet | ### Status Flow ``` reported -> triaged -> routed -> in-progress -> fixed -> verified -> closed ``` | Status | Description | |--------|-------------| | **reported** | Bug logged in bugs.md, not yet analyzed | | **triaged** | PM analyzed, assigned severity/complexity/workflow | | **routed** | Workflow determined, story/tech-spec created | | **in-progress** | Developer actively working on fix | | **fixed** | Code changed, tests passing, ready for verification | | **verified** | Bug confirmed fixed by reporter or QA | | **closed** | Bug resolved and verified, no further action | ### Metadata Fields | Field | Description | |-------|-------------| | id | Unique identifier (bug-NNN or feature-NNN) | | title | Short description (< 80 chars) | | description | Detailed explanation | | severity | critical \| high \| medium \| low | | complexity | trivial \| small \| medium \| complex | | status | Current workflow state | | recommended_workflow | direct-fix \| tech-spec \| correct-course \| backlog | | effort_estimate | Hours (based on complexity) | | reported_by / reported_date | Who found it and when | | triaged_by / triaged_date | Who triaged and when | | fixed_date / verified_date | Implementation and verification dates | | related_story / related_epic | Context links | | affected_platform | all \| ios \| android | | doc_impact | Documentation impact: prd, architecture, ux flags + notes | | notes | Investigation notes, decisions, implementation details |