# Standard Workflow

Full pipeline for moderate complexity issues. Uses native Claude Tasks for phase tracking.

## Task Setup (Before Starting)

Create all phase tasks upfront with dependencies. See `references/task-orchestration.md`.

```
T1 = TaskCreate(subject="Scout codebase",        activeForm="Scouting codebase")
T2 = TaskCreate(subject="Diagnose root cause",    activeForm="Diagnosing root cause")
T3 = TaskCreate(subject="Implement fix",          activeForm="Implementing fix",    addBlockedBy=[T1, T2])
T4 = TaskCreate(subject="Verify + prevent",       activeForm="Verifying fix",       addBlockedBy=[T3])
T5 = TaskCreate(subject="Code review",            activeForm="Reviewing code",      addBlockedBy=[T4])
T6 = TaskCreate(subject="Finalize",               activeForm="Finalizing",          addBlockedBy=[T5])
```

## Steps

### Step 1: Scout Codebase
`TaskUpdate(T1, status="in_progress")`

**Mandatory skill chain:**
1. Activate `mk:scout` skill OR launch 2-3 parallel `Explore` subagents.
2. Map: affected files, module boundaries, dependencies, related tests, recent git changes.

**Pattern:** In SINGLE message, launch 2-3 Explore agents:
```
Task("Explore", "Find [area1] files related to issue", "Scout area1")
Task("Explore", "Find [area2] patterns/usage", "Scout area2")
Task("Explore", "Find [area3] tests/dependencies", "Scout area3")
```

See `references/parallel-exploration.md` for patterns.

`TaskUpdate(T1, status="completed")`
**Output:** `✓ Step 1: Scouted [N] areas - [M] files, [K] tests found`

### Step 2: Diagnose Root Cause
`TaskUpdate(T2, status="in_progress")`

**Mandatory skill chain:**
1. **Capture pre-fix state:** Record exact error messages, failing test output, stack traces.
2. Activate `mk:debug` skill. Use `debugger` subagent if needed.
3. Activate `mk:sequential-thinking` — form hypotheses through structured reasoning.
4. Spawn parallel `Explore` subagents to test hypotheses against codebase evidence.
5. If 2+ hypotheses fail → auto-activate `mk:problem-solving`.
6. Trace backward to root cause (not just symptom location).

See `references/diagnosis-protocol.md` for full methodology.

`TaskUpdate(T2, status="completed")`
**Output:** `✓ Step 2: Diagnosed - Root cause: [summary], Evidence: [brief], Scope: [N files]`

### Step 3: Implement Fix
`TaskUpdate(T3, status="in_progress")` — auto-unblocked when T1 + T2 complete.

Fix the ROOT CAUSE per diagnosis findings. Not symptoms.

- Apply `mk:problem-solving` skill if stuck
- Use `mk:sequential-thinking` for complex logic
- Minimal changes. Follow existing patterns.

`TaskUpdate(T3, status="completed")`
**Output:** `✓ Step 3: Implemented - [N] files changed`

### Step 4: Verify + Prevent
`TaskUpdate(T4, status="in_progress")`

**Mandatory skill chain:**
1. **Iron-law verify:** Re-run the EXACT commands from pre-fix state capture. Compare before/after.
2. **Regression test:** Add/update test(s) covering the fixed issue. Test MUST fail without fix, pass with fix.
3. **Side-effect sweep (HARD-GATE-NO-SIDE-EFFECTS):** Walk each dependent caller of changed functions from Step 1 blast-radius. Run tests in modules that share files/contracts. Confirm public contracts (signatures, schemas, APIs, env vars) unchanged. See SKILL.md HARD-GATE-NO-SIDE-EFFECTS.
4. **Defense-in-depth:** Apply prevention layers where applicable (see `references/prevention-gate.md`).
5. **Parallel verification:** Launch `Bash` agents:
```
Task("Bash", "Run typecheck", "Verify types")
Task("Bash", "Run lint", "Verify lint")
Task("Bash", "Run build", "Verify build")
Task("Bash", "Run tests", "Verify tests")
```

**On regression / side effect:** `AskUserQuestion` with 2-4 concrete options (revert / narrow scope / update dependents / accept). Never silently patch.

**If verification fails:** Loop back to Step 2 (re-diagnose). Max 3 attempts.

`TaskUpdate(T4, status="completed")`
**Output:** `✓ Step 4: Verified + Prevented - [before/after], [N] tests added, [M] guards`

### Step 5: Code Review
`TaskUpdate(T5, status="in_progress")`
Use `code-reviewer` subagent.

See `references/review-cycle.md` for mode-specific handling.

`TaskUpdate(T5, status="completed")`
**Output:** `✓ Step 5: Review [score]/10 - [status]`

### Step 6: Finalize
`TaskUpdate(T6, status="in_progress")`
- Report summary: root cause, changes, prevention measures, confidence score
- Activate `mk:project-management` for task sync-back and plan status updates
- Update docs if needed via `docs-manager`
- Ask to commit via `git-manager` subagent
- Run `/mk:journal`

`TaskUpdate(T6, status="completed")`
**Output:** `✓ Step 6: Complete - [action]`

## Skills/Subagents Activated

| Step | Skills/Subagents |
|------|------------------|
| 1 | `mk:scout` OR parallel `Explore` subagents |
| 2 | `mk:debug`, `mk:sequential-thinking`, `debugger` subagent, parallel `Explore`, (`mk:problem-solving` auto) |
| 3 | `mk:problem-solving` (if stuck), `mk:sequential-thinking` (complex logic) |
| 4 | `tester` subagent, parallel `Bash` verification |
| 5 | `code-reviewer` subagent |
| 6 | `mk:project-management`, `git-manager`, `docs-manager` subagents |

**Rules:** Don't skip steps. Validate before proceeding. One phase at a time.
**Frontend:** Use `mk:agent-browser`, `mk:chrome-profile`, Chrome MCP / `chrome-devtools-mcp`, or any relevant project-native browser tests to verify.
**Visual Assets:** Use `mk:ai-multimodal` for visual assets generation, analysis and verification.
