---
description: Fix hard issues within task constraints
argument-hint: "[task-id]"
agent: build
---

# Hard Fix: $ARGUMENTS

## Phase 0: Task Validation (MANDATORY)

### Check Task Exists

Validate task in Backlog MCP:

```typescript
backlog_task_view({ id: "$ARGUMENTS" });
```

**If not found:** STOP. Create with `/task-with-spec "$ARGUMENTS"` first.

Then verify constraint files in `@backlog/tasks/$ARGUMENTS/`:

- [ ] prd.md with Goal, Scope, Success Criteria
- [ ] spec.md with Architecture, Constraints, Edge Cases

**If files missing:** STOP. Complete task setup first.

### Load Fix Constraints

Read from `@backlog/tasks/$ARGUMENTS/`:

- **prd.md Scope section** - What's in/out of scope
- **spec.md Constraints section** - Rules to follow
- **spec.md Edge Cases section** - Corner cases to handle

## Phase 1: Task-Bounded Issue Analysis

### Analyze Only Task-Related Issues

**Task Goal:** [From PRD goal section]
**Task Scope:** [From PRD scope section]
**Task Constraints:** [From spec constraints section]
**Task Edge Cases:** [From spec edge cases section]

### Issue Analysis (Task-Focused):

```
@build Analyze hard issues for task $ARGUMENTS

ANTI-HALLUCINATION FIX REQUIREMENTS:
1. Read @backlog/tasks/$ARGUMENTS/prd.md and spec.md FIRST
2. Analyze issues only within task scope
3. Debug only task-related problems
4. Fix only within task constraints
5. Handle all task edge cases from spec
6. Stop if any constraint violation detected
7. Complete @backlog/tasks/$ARGUMENTS/review.md after work
8. Mark task success criteria as completed

HARD FIX BOUNDARIES:
- Goal: [From PRD goal]
- Scope: [From PRD scope]
- Constraints: [From spec constraints]
- Edge Cases: [From spec edge cases]
- Success: [From PRD success criteria]

NO EXCEPTIONS: Even hard fixes must serve task constraints only
```

### Complex Issue Breakdown (Task-Aligned):

- **Sequential thinking**: Break down task-specific issues
- **Problem-solving**: Apply techniques to task constraints
- **Multi-agent coordination**: All agents serve task goal

## Phase 2: Task-Constraint Fix Planning

### Fix Plan Within Task Requirements

**Phase 1**: Task issue analysis
**Phase 2**: Task-constrained solution design
**Phase 3**: Task-bounded implementation
**Phase 4**: Task-specific validation

### Agent Delegation (Task-Focused):

- **Primary**: build agent (task implementation)
- **Complex planning**: plan agent (task architecture)
- **Research**: oracle (task debugging), librarian (task patterns)
- **Quality gate**: code-auditor (task compliance review)

## Phase 3: Task-Focused Implementation

### Fix Implementation Process:

```
@build Implement hard fix for task $ARGUMENTS

ANTI-HALLUCINATION IMPLEMENTATION:
1. Continuously validate against @backlog/tasks/$ARGUMENTS/prd.md
2. Follow all constraints from @backlog/tasks/$ARGUMENTS/spec.md
3. Handle all edge cases listed in task spec
4. Fix only issues within task scope
5. Use only allowed libraries from task constraints
6. Stop if any task boundary violation
7. Document all fixes in @backlog/tasks/$ARGUMENTS/review.md
8. Mark success criteria as completed

TASK CONSTRAINTS:
- Scope: [From PRD scope]
- Architecture: [From spec architecture]
- Edge Cases: [From spec edge cases]
- Framework: [From spec constraints]

NO EXCEPTIONS: Fixes must serve task requirements only
```

### Debugging Strategy (Task-Bounded):

- **Issue isolation**: Only task-related problems
- **Root cause**: Within task architecture
- **Solution**: Within task constraints
- **Validation**: Against task success criteria

## Phase 4: Task Fix Validation

### Multi-Agent Quality Assurance:

```
session({
  mode: "message",
  agent: "code-auditor",
  text: "Review hard fix for task $ARGUMENTS compliance with PRD+spec constraints"
})
```

### Validation Criteria:

- **Issue resolution**: Task problems fixed
- **Scope compliance**: No off-task changes
- **Constraint adherence**: All task constraints followed
- **Edge case handling**: All task edge cases addressed
- **Success criteria**: Task goals achieved

## Phase 5: Task Fix Documentation

### Update Task Review

After fixes complete, update `@backlog/tasks/$ARGUMENTS/review.md`:

**Add section:**

```markdown
## Hard Fix - [DATE]

### Task Context

**Goal**: [From prd.md]
**Issues**: [Task-specific problems identified]

### Fix Implementation

[Hard fixes applied within task constraints]

### Fix Compliance

- Issue resolution: [How fixes solve task problems]
- Scope compliance: [How fixes respect boundaries]
- Constraint adherence: [How fixes follow spec]

### Edge Cases Handled

[From task spec edge cases section]
```

### Complete Task

Run `/complete-task $ARGUMENTS` to validate and mark Done.

---

**ANTI-HALLUCINATION: Even hard fixes must serve task constraints, not general debugging**
