Detect, automatically recover from, report, and log errors to prevent silent data loss and ensure proper human intervention when needed.
---
name: error-recovery
version: 2.0.0
description: 4R error recovery framework. Recognize, Rescue, Report, Remember. Never lose work silently. Trigger on: 'error', 'failed', 'crash', 'something went wrong', 'retry'.
emoji: šØ
---
# Error Recovery šØ
4R framework. Never lose work silently.
## The 4 Rs
```
R1: RECOGNIZE ā Did something go wrong?
R2: RESCUE ā Can I recover automatically?
R3: REPORT ā Does the human need to know?
R4: REMEMBER ā What should I learn from this?
```
## R1: RECOGNIZE (Don't Ignore Errors)
**Error signals I must not ignore:**
```
ā” Command exit code ā 0
ā” Exception thrown
ā” Timeout exceeded
ā” Empty/unexpected output
ā” "error", "failed", "exception" in logs
ā” Behavior different from expected
```
**Anti-patterns:**
- ā Command failed, but I continue anyway
- ā Error logged, but not mentioned in my response
- ā "Probably fine" without verification
**What to do:**
1. Stop and acknowledge the error
2. Read the full error message
3. Check if it's recoverable or needs human input
## R2: RESCUE (Can I Fix It?)
**Automatic recovery strategies:**
| Error Type | Recovery Strategy |
|------------|-------------------|
| Network timeout | Retry with exponential backoff (max 3) |
| Rate limit | Wait and retry |
| Missing dependency | Install/suggest installation |
| Permission denied | Suggest elevated permissions or fix |
| File not found | Create or point to correct path |
| Invalid input | Sanitize or request correct input |
| API error | Check status, retry if transient |
**Retry protocol:**
```
Attempt 1: Immediate
Attempt 2: Wait 5 seconds
Attempt 3: Wait 15 seconds
If all fail ā Report to human
```
**When NOT to auto-retry:**
- Authentication errors (wrong credentials)
- Permission errors (needs human action)
- Data validation errors (needs correct input)
- Destructive operation failures (don't risk double-execution)
## R3: REPORT (Does Human Need to Know?)
**Always report when:**
- Auto-recovery failed after 3 attempts
- Error affects the final outcome
- Human action is required
- Something unexpected happened
**Report format:**
```
ā ļø Error encountered: [brief description]
What happened:
[What I was doing]
Error details:
[Full error message]
What I tried:
[Recovery attempts made]
Current state:
[What's broken / what's still working]
What I need:
[What human action is needed, if any]
```
**Example:**
```
ā ļø Error encountered: GitHub push failed
What happened:
Pushing to aptratcn/cognitive-debt-guard
Error details:
fatal: could not read Username for 'https://github.com'
What I tried:
1. Retried push (failed)
2. Checked git remote config
Current state:
- Commit is saved locally
- Not pushed to remote
What I need:
Git credentials not configured. Will try using token auth.
```
## R4: REMEMBER (Learn From Errors)
**After error recovery:**
```
ā” Did this error happen before?
ā If yes, what's the pattern?
ā Document the fix
ā” Could this happen again?
ā Add guard for this case
ā Update skill/workflow
ā” Is there a systemic issue?
ā Suggest process improvement
ā Update AGENTS.md if needed
```
**Error log:**
```
memory/errors/YYYY-MM-DD.md
## [Error Type] - [Timestamp]
**Context:** What I was doing
**Error:** Full error message
**Cause:** Root cause (if known)
**Fix:** How I resolved it
**Prevention:** How to avoid in future
```
## Quick Reference
```
ERROR ā STOP ā READ ERROR ā CAN I FIX?
ā
NO ā REPORT to human ā WAIT for action
YES ā FIX ā VERIFY ā CONTINUE
ā
Still broken? ā REPORT
```
## Trigger Phrases
- "error", "failed", "crash"
- "something went wrong", "exception"
- "retry", "try again"
- "ę„é", "失蓄", "é误"
## Integration
- **EVR Framework** ā Verify after recovery
- **Systematic Debugging** ā When root cause is unknown
- **Workflow Checkpoint** ā Save state before risky operations
## License
MIT
don't have the plugin yet? install it then click "run inline in claude" again.