# 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"
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
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
HALT
HALT
HALT
Check doc_impact fields from bugs.yaml entry
How should we proceed?
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.
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.
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.
Continue to step 3
HALT
Continue to step 3
Check recommended_workflow field from bugs.yaml
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
{item_id}: {title} - {description}
HALT - Tech-spec workflow will create implementation spec
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
Ready to {action_verb} this {type}? (yes/no/clarify)
What additional context do you need?
Gather clarification, update mental model
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
Search for {item_id} in both bugs.yaml and bugs.md using grep to check current 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
```
## 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 |