---
description: Fix issues with task creation and validation
argument-hint: "[issue description]"
agent: build
---

# Fast Fix: $ARGUMENTS

## Phase 0: Task Creation (MANDATORY)

### Create Bug Fix Task

!`backlog_task_create --title "Fix: $ARGUMENTS" --status "To Do" --priority high`
!`TASK_ID=$(backlog_task_list --search "Fix: $ARGUMENTS" --limit 1 | grep -o 'task-[0-9]*' | head -1)`
!`TASK_DIR="@backlog/tasks/$TASK_ID"`
!`mkdir -p "$TASK_DIR"`

### Generate 3 Mandatory Files

!`cp .opencode/memory/_templates/task-prd.md "$TASK_DIR/prd.md"`
!`cp .opencode/memory/_templates/task-spec.md "$TASK_DIR/spec.md"`
!`cp .opencode/memory/_templates/task-review.md "$TASK_DIR/review.md"`
!`sed -i "s/\[auto-generated\]/$TASK_ID/g" "$TASK_DIR/prd.md" "$TASK_DIR/spec.md" "$TASK_DIR/review.md"`

### Fill Bug Fix PRD

!`cat > "$TASK_DIR/prd.md" << EOF

# Bug Fix PRD

**Task ID:** $TASK_ID
**Created:** $(date '+%Y-%m-%d')

## Goal

Fix the issue: $ARGUMENTS

## Scope

**In-Scope:** Fix specific issue only
**Out-of-Scope:** General improvements, new features

## User Flow

1. User encounters issue: $ARGUMENTS
2. Fix is applied
3. Issue is resolved

## Success Criteria

- [ ] Issue $ARGUMENTS is resolved
- [ ] No regression in existing functionality
- [ ] Fix follows existing code patterns
- [ ] Basic testing passes

## Dependencies

- None (bug fix)
  EOF`

### Fill Bug Fix Spec

!`cat > "$TASK_DIR/spec.md" << EOF

# Bug Fix Spec

**Task ID:** $TASK_ID
**PRD:** $TASK_DIR/prd.md

## Architecture Plan

Minimal changes to fix issue without affecting existing architecture.

### Files to Modify:

- [To be identified during analysis]

## Constraints

### Naming Conventions:

- Follow existing patterns in modified files
- No new function names unless necessary

### Framework Requirements:

- Use existing error handling patterns
- No new dependencies
- Maintain backward compatibility

### Code Style:

- Match surrounding code style
- Add comments only if logic is complex

## Edge Cases

- Fix doesn't break related functionality
- Handle similar issues that might exist
- Performance impact is minimal

## Testing Notes

### Test Cases:

- Reproduce original issue
- Verify fix works
- Check for regressions

### Validation:

- Manual testing of fix
- Automated tests if available
- Code review for quality

### Rollback Plan:

- Git revert if fix causes issues
  EOF`

## Phase 1: Issue Analysis

### Analyze Issue

```
@build Analyze and fix issue for task $TASK_ID

ANTI-HALLUCINATION REQUIREMENTS:
1. Read $TASK_DIR/prd.md and $TASK_DIR/spec.md FIRST
2. Understand issue: $ARGUMENTS
3. Identify root cause using available tools
4. Propose minimal fix within scope
5. Verify fix doesn't break existing functionality
6. Follow constraints in spec
7. Complete $TASK_DIR/review.md after work
8. Mark PRD success criteria as completed

ISSUE SCOPE: Fix $ARGUMENTS only - no general improvements
```

### Analysis Tools:

- **Screenshots/Videos:** Use ai-multimodal skill to describe issues
- **Code Analysis:** Use finder to locate related code
- **Testing:** Use code-auditor to validate fix

## Phase 2: Fix Implementation

### Delegation Rules:

- **Primary:** build agent (70% of work)
- **Quality Gate:** code-auditor (testing + security + review)
- **Research:** oracle (complex debugging), docs (API lookup), finder (codebase search)

### Fix Validation:

- [ ] Issue resolved
- [ ] No regressions
- [ ] Follows existing patterns
- [ ] Tests pass

## Phase 3: Quality Assurance

### Code Review

```
session({ mode: "message", agent: "code-auditor", text: "Review fix for task $TASK_ID: $ARGUMENTS" })
```

### Testing Validation

- Manual testing of fix
- Automated test runs
- Regression testing

## Phase 4: Completion

### Task Completion

!`/complete-task $TASK_ID`

---

**ANTI-HALLUCINATION: Even bug fixes need task tracking and constraints**
