Skip to content
recovery logo

Recovery Skill

recovery

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

oimiragieo/agent-studio0installs43stars

SKILL.md

Full skill instructions

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> - Resuming workflows after context window exhaustion - Recovering from session interruptions - Reconstructing workflow state from artifacts and gate files - Identifying and continuing from last completed step - Preventing duplicate work during recovery </​capabilities> <instructions> <execution_process>

When to Use

  • Context window exhausted mid-workflow
  • Session interrupted or lost
  • Need to resume from last completed step
  • Workflow state needs reconstruction

Step 1: Identify Last Completed Step

  1. Check gate files for last successful validation:

    • Location: .claude/​context/​history/​gates/​{workflow_id}/
    • Find highest step number with validation_status: "pass"
    • This is the last successfully completed step
  2. Review reasoning files for progress:

    • Location: .claude/​context/​history/​reasoning/​{workflow_id}/
    • Read reasoning files up to last completed step
    • Extract context and decisions made
  3. Identify artifacts created:

    • Check artifact registry: .claude/​context/​artifacts/​registry-{workflow_id}.json
    • List all artifacts created up to last step
    • Verify artifact files exist

Step 2: Load Plan Documents

  1. Read plan document (stateless):

    • Load plan-{workflow_id}.json from artifact registry
    • Extract current workflow state
    • Identify completed vs pending tasks
  2. Load relevant phase plan (if multi-phase):

    • Check if project is multi-phase (exceeds phase_size_max_lines threshold)
    • Load active phase plan: plan-{workflow_id}-phase-{n}.json
    • Understand phase boundaries and dependencies
  3. Understand current state:

    • Map completed tasks to plan
    • Identify next steps
    • Check for dependencies

Step 3: Context Recovery

  1. Load artifacts from last completed step:

    • Read artifact registry
    • Load all artifacts with validation_status: "pass"
    • Verify artifact integrity
  2. Read reasoning files for context:

    • Load reasoning files from completed steps
    • Extract key decisions and context
    • Understand workflow progression
  3. Reconstruct workflow state:

    • Combine plan, artifacts, and reasoning
    • Create recovery state document
    • Validate state consistency

Step 4: Resume Execution

  1. Continue from next step:

    • Identify next step after last completed
    • Load step requirements from plan
    • Prepare inputs for next step
  2. Planner updates plan status (stateless):

    • Update plan-{workflow_id}.json with current status
    • Mark completed steps
    • Update progress tracking
  3. Orchestrator coordinates next agents:

    • Pass recovered artifacts to next step
    • Resume workflow execution
    • Monitor for additional interruptions

</​execution_process>

Failure Classification

When a task fails, classify the failure type:

Failure TypeIndicatorsRecovery Action
BROKEN_BUILDBuild errors, syntax errors, module not foundROLLBACK + fix
VERIFICATION_FAILEDTest failures, validation errors, assertion errorsRETRY with fix (max 3 attempts)
CIRCULAR_FIXSame error 3+ times, similar approaches repeatedSKIP or ESCALATE
CONTEXT_EXHAUSTEDToken limit reached, maximum length exceededCompress context, continue
UNKNOWNNo pattern matchRETRY 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:

  • Extract keywords from current approach (excluding stop words)
  • Compare with keywords from last 3 attempts
  • If Jaccard similarity > 30% for 2+ attempts, flag as circular

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 TypeMax AttemptsThen Action
VERIFICATION_FAILED3SKIP + ESCALATE
UNKNOWN2ESCALATE
BROKEN_BUILD1ROLLBACK (if good commit exists)
CIRCULAR_FIX0Immediately SKIP

References

See references/ for detailed patterns:

  • failure-types.md - Failure classification details and indicators
  • recovery-actions.md - Recovery action decision tree and execution
  • merge-strategies.md - File merge strategies for multi-agent scenarios

<best_practices>

Recovery Validation Checklist

  • Last completed step identified correctly
  • Plan document loaded and validated
  • All artifacts from completed steps available
  • Reasoning files reviewed for context
  • Workflow state reconstructed accurately
  • No duplicate work will be performed
  • Next step inputs prepared
  • Recovery logged in reasoning file

</​best_practices>

<error_handling>

Error Handling

  • Missing plan document: Request planner to recreate plan from requirements
  • Missing artifacts: Request artifact recreation from source agent
  • Corrupted artifacts: Request artifact recreation with validation
  • Incomplete reasoning: Use artifact registry and gate files to reconstruct state

</​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

  • Planner Agent: .claude/​agents/​core/​planner.md
  • Memory files: .claude/​context/​memory/

Memory Protocol (MANDATORY)

Before starting:

cat .claude/​context/​memory/​learnings.md

After completing:

  • New pattern -> .claude/​context/​memory/​learnings.md
  • Issue found -> .claude/​context/​memory/​issues.md
  • Decision made -> .claude/​context/​memory/​decisions.md

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

More skills from oimiragieo

cloud-devops-expert logo
oimiragieo/agent-studio

cloud-devops-expert

Cloud and DevOps expert including AWS, GCP, Azure, and Terraform

43 0
View
xlsx logo
oimiragieo/agent-studio

xlsx

Spreadsheet toolkit (.xlsx/.csv). Create/edit with formulas/formatting, analyze data, visualization, recalculate formulas, for spreadsheet processing and analysis.

43 0
View
project-analyzer logo
oimiragieo/agent-studio

project-analyzer

Automated brownfield codebase analysis with weighted keyword scoring, three-stream analysis, and design pattern recognition. Detects project type, frameworks, dependencies, architecture patterns, and generates comprehensive project profile.

43 0
View
readme logo
oimiragieo/agent-studio

readme

Use when creating, updating, or generating README and documentation files for projects and libraries

43 0
View
scientific-writing logo
oimiragieo/agent-studio

scientific-writing

Core skill for the deep research and writing tool. Write scientific manuscripts in full paragraphs (never bullet points). Use two-stage process with (1) section outlines with key points using research-lookup then (2) convert to flowing prose. IMRAD structure, citations (APA/AMA/Vancouver), figure...

43 0
View
android-expert logo
oimiragieo/agent-studio

android-expert

Comprehensive Android development expert covering Jetpack Compose, Kotlin coroutines/Flow, Architecture Components, Hilt DI, Navigation, testing, performance, Material Design 3, and modern Android patterns (MVI, Clean Architecture).

43 0
View
biorxiv-database logo
oimiragieo/agent-studio

biorxiv-database

Efficient database search tool for bioRxiv preprint server. Use this skill when searching for life sciences preprints by keywords, authors, date ranges, or categories, retrieving paper metadata, downloading PDFs, or conducting literature reviews.

43 0
View
omega-gemini-cli logo
oimiragieo/agent-studio

omega-gemini-cli

Use when the user wants to use Google Gemini for analysis, large files or codebases, sandbox execution, or brainstorming. Uses headless Gemini CLI scripts (no MCP). Triggers on "use Gemini", "analyze with Gemini", "large file", "sandbox", "brainstorm with Gemini".

43 0
View
gtars logo
oimiragieo/agent-studio

gtars

High-performance toolkit for genomic interval analysis in Rust with Python bindings. Use when working with genomic regions, BED files, coverage tracks, overlap detection, tokenization for ML models, or fragment analysis in computational genomics and machine learning applications.

43 0
View
service-class-conventions logo
oimiragieo/agent-studio

service-class-conventions

Defines the structure and implementation of service classes, enforcing the use of interfaces, ServiceImpl classes, DTOs for data transfer, and transactional management.

43 0
View
diffdock logo
oimiragieo/agent-studio

diffdock

Diffusion-based molecular docking. Predict protein-ligand binding poses from PDB/SMILES, confidence scores, virtual screening, for structure-based drug design. Not for affinity prediction.

43 0
View
skill-discovery logo
oimiragieo/agent-studio

skill-discovery

How agents discover and use skills. Use to understand skill invocation protocol.

43 0
View

Popular AI tools

Kaiber logo
Video

Kaiber

Generate, edit, and beat-sync AI video with leading models in one workspace.

Paid
View
Vimcal logo
Productivity

Vimcal

The world's fastest calendar for remote work

Free
View

Transform Your Design with AI Designer by ImgCreator.ai

Freemium
View
Akool AI logo
Content & writing

Akool AI

Revolutionizing Video Production with AI-Powered Creativity

Paid
View

Extend an image past the frame and let AI fill the new aspect ratio.

Freemium
View
StarByFace logo
Security

StarByFace

Discover your celebrity doppelgänger with StarByFace!

Free
View
C

ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.

Freemium
View
Opus Clip logo
Coding & apps

Opus Clip

Opus.ai: Revolutionize Your Web Experience

Free
View