Recover from a failed or blocked task
task-state/ for tasks with state: "failed" or state: "blocked"notes field (contains failure details)docs/modules/<feature>/SPEC.<feature>.mdfailed or blocked task exists → abort: "No task needs recovery."Read the notes error information and classify the failure:
| Type |
|---|
| Identifying characteristics |
|---|
| A. Test assertion failure | Test case expected/received mismatch |
| B. Compile / type error | TypeScript error, missing import |
| C. Runtime error | Uncaught exception, null reference, DB connection issue |
| D. Logic defect | Tests pass but acceptance criteria not met |
| E. Environment / dependency issue | Missing package, unconfigured env var, service unavailable |
| F. SPEC ambiguity | Unclear requirements led to wrong implementation direction |
🔍 Root cause analysis: [task-NN] <title>
Failure type: <A–F>
Root cause:
<specific details: which line / test / config caused the failure>
Blast radius:
<this task only / affects other modules>
Provide a concrete plan based on failure type:
A. Test assertion failure → Locate the assertion gap, check whether implementation logic matches the expectation, fix implementation (not the test)
B. Compile / type error → Locate the error file and line, fix the type definition or import path
C. Runtime error → Locate the throw site, add null checks or error boundaries, verify data initialisation
D. Logic defect → Re-read SPEC acceptance criteria, compare with implementation, correct the business logic
E. Environment / dependency issue → List the steps the user needs to take (install package, configure env var), wait for completion before continuing
F. SPEC ambiguity → List the ambiguous points, ask the user, update SPEC based on the answer, then re-implement
Confirm with the user: "Proceed with the above plan? (y/n/suggest alternative)"
Apply the fix, then re-run tests.
On successful recovery:
{
"state": "in_progress",
"updatedAt": "<current ISO timestamp>",
"notes": "<summary of recovery actions taken>"
}
Inform the user: "Task recovered. Re-run /implement-task to finish, or run /verify-task to re-verify."
| Situation | Action |
|---|---|
| Still failing after 2 recovery rounds | Output full diagnostic report, keep state as failed, note that manual intervention is needed |
| Recovery requires changing the SPEC | Propose the SPEC change, wait for user confirmation, update the SPEC file, then resume |
blocked task waiting on an external dependency | Explain the blocker, suggest the user resolve the dependency and re-run this command |
failed to in_progress