| name | error-handling |
| description | Handle failures during spec2cloud execution. Covers sub-agent failures, stuck loops, corrupted state, and test infrastructure failures. Use when encountering errors, retrying failed tasks, or recovering from corrupted state. |
Error Handling
Sub-Agent Failure
If a sub-agent fails (crashes, produces invalid output, tests don't pass):
- Log the failure in
audit.log with the error details
- Retry the same task — the sub-agent gets another attempt
- On retry, include the previous error as context so the sub-agent can adjust
- There is no retry limit — loops run indefinitely
Stuck in a Loop
If you detect you're making no progress (same test failing repeatedly, same error recurring):
- Keep going. Do not stop autonomously.
- The human is watching. Human Ctrl+C is the escape hatch.
- Try different approaches on each iteration — don't repeat the exact same fix
- Log every attempt so the human can diagnose the pattern
Corrupted or Missing State
If state.json is corrupted or contains invalid data:
- Log the corruption in
audit.log
- Re-assess the project state from the repo itself:
- Check which spec files exist (
specs/prd.md, specs/frd-*.md, specs/features/*.feature)
- Check which tests exist and whether they pass
- Check which code exists
- Check deployment status
- Reconstruct
state.json from the observed repo state
- Continue from the determined phase
Test Infrastructure Failures
If tests fail to compile or the test runner itself fails (not test assertion failures):
- Log the infrastructure failure
- Attempt to fix the test infrastructure (missing dependencies, config issues)
- Re-run tests
- If the test infrastructure cannot be fixed, log the blocker and continue attempting