Recovery

From oimiragieo/agent-studio · View interactive version

Recovery is an AI agent skill from the GitHub repository oimiragieo/agent-studio. Workflow recovery protocol for resuming workflows after context loss, session interruption, or errors. Handles state reconstruction, artifact recovery, and seamless workflow continuation.

How to use this skill

Skill file

Recovery Skill

<identity>

Recovery Skill - Workflow recovery protocol for resuming workflows after context loss, session interruption, or errors. Handles state reconstruction, artifact recovery, and seamless workflow continuation.

</identity>

<capabilities>

</capabilities>

<instructions>

<execution_process>

When to Use

Step 1: Identify Last Completed Step

  1. Check gate files for last successful validation:
  1. Review reasoning files for progress:
  1. Identify artifacts created:

Step 2: Load Plan Documents

  1. Read plan document (stateless):
  1. Load relevant phase plan (if multi-phase):
  1. Understand current state:

Step 3: Context Recovery

  1. Load artifacts from last completed step:
  1. Read reasoning files for context:
  1. Reconstruct workflow state:

Step 4: Resume Execution

  1. Continue from next step:
  1. Planner updates plan status (stateless):
  1. Orchestrator coordinates next agents:

</execution_process>

Failure Classification

When a task fails, classify the failure type:

| Failure Type | Indicators | Recovery Action |

| ------------------- | -------------------------------------------------- | ------------------------------- |

| BROKEN_BUILD | Build errors, syntax errors, module not found | ROLLBACK + fix |

| VERIFICATION_FAILED | Test failures, validation errors, assertion errors | RETRY with fix (max 3 attempts) |

| CIRCULAR_FIX | Same error 3+ times, similar approaches repeated | SKIP or ESCALATE |

| CONTEXT_EXHAUSTED | Token limit reached, maximum length exceeded | Compress context, continue |

| UNKNOWN | No pattern match | RETRY once, then ESCALATE |

Circular Fix Detection

Iron Law: If the same approach has been tried 3+ times without success, STOP.

When circular fix is detected:

  1. Stop the current approach immediately
  2. Document what was tried (approaches, errors, files)
  3. Try fundamentally different approach (different library, different pattern, simpler implementation)
  4. If still failing, ESCALATE to human intervention

Detection Algorithm:

Example:

Attempt 1: "Using async await for fetch"
Attempt 2: "Using async/await with try-catch"
Attempt 3: "Trying async await pattern again"
=> CIRCULAR FIX DETECTED - Stop and try callback pattern instead

Attempt Count Thresholds

| Failure Type | Max Attempts | Then Action |

| ------------------- | ------------ | -------------------------------- |

| VERIFICATION_FAILED | 3 | SKIP + ESCALATE |

| UNKNOWN | 2 | ESCALATE |

| BROKEN_BUILD | 1 | ROLLBACK (if good commit exists) |

| CIRCULAR_FIX | 0 | Immediately SKIP |

References

See references/ for detailed patterns:

<best_practices>

Recovery Validation Checklist

</best_practices>

<error_handling>

Error Handling

</error_handling>

</instructions>

<examples>

<usage_example>

Recovery after context loss:

# 1. Check gate files for last completed step
ls .claude/context/history/gates/{workflow_id}/

# 2. Load plan document
cat .claude/context/artifacts/plan-{workflow_id}.json

# 3. Review reasoning files
cat .claude/context/history/reasoning/{workflow_id}/*.json

# 4. Resume from next step

</usage_example>

<usage_example>

Natural language invocation:

"Resume the workflow from where we left off"
"Recover the workflow state and continue"
"What was the last completed step?"

</usage_example>

</examples>

Related

Memory Protocol (MANDATORY)

Before starting:

cat .claude/context/memory/learnings.md

After completing:

ASSUME INTERRUPTION: Your context may reset. If it's not in memory, it didn't happen.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.