recovery
Workflow recovery protocol for resuming workflows after context loss, session interruption, or errors. Handles state reconstruction, artifact recovery, and seamless workflow continuation.
When & Why to Use This Skill
The Recovery skill is a specialized workflow protocol designed to mitigate the impact of context loss, session interruptions, and execution errors in AI agent operations. It facilitates seamless state reconstruction by systematically identifying the last completed steps, loading plan documents, and recovering artifacts and reasoning logs. By ensuring that complex, multi-phase tasks can resume precisely where they left off, this skill significantly enhances the reliability, persistence, and efficiency of long-running agentic workflows.
Use Cases
- Context Window Management: Resuming long-running development or research tasks after reaching context limits by reconstructing the project state from historical reasoning and gate files.
- Session Continuity: Automatically recovering complex multi-phase workflows after session timeouts, browser crashes, or network interruptions to prevent data loss.
- Error Resilience: Reconstructing workflow states after specific tool failures or execution errors, allowing the agent to identify the last 'safe' state and continue without redundant work.
- State Synchronization: Leveraging artifact registries and plan documents to ensure all generated outputs are validated and aligned before proceeding with the next stage of a project.
| name | recovery |
|---|---|
| description | Workflow recovery protocol for resuming workflows after context loss, session interruption, or errors. Handles state reconstruction, artifact recovery, and seamless workflow continuation. |
| version | 1.0.0 |
| allowed-tools | read, grep, glob, search |
Recovery Skill
Workflow recovery protocol for resuming workflows after context loss, session interruption, or errors.
When to Use
- Context window exhausted mid-workflow
- Session interrupted or lost
- Need to resume from last completed step
- Workflow state needs reconstruction
Instructions
Step 1: Identify Last Completed Step
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
- Location:
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
- Location:
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
- Check artifact registry:
Step 2: Load Plan Documents
Read plan document (stateless):
- Load
plan-{workflow_id}.jsonfrom artifact registry - Extract current workflow state
- Identify completed vs pending tasks
- Load
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
Understand current state:
- Map completed tasks to plan
- Identify next steps
- Check for dependencies
Step 3: Context Recovery
Load artifacts from last completed step:
- Read artifact registry
- Load all artifacts with validation_status: "pass"
- Verify artifact integrity
Read reasoning files for context:
- Load reasoning files from completed steps
- Extract key decisions and context
- Understand workflow progression
Reconstruct workflow state:
- Combine plan, artifacts, and reasoning
- Create recovery state document
- Validate state consistency
Step 4: Resume Execution
Continue from next step:
- Identify next step after last completed
- Load step requirements from plan
- Prepare inputs for next step
Planner updates plan status (stateless):
- Update plan-{workflow_id}.json with current status
- Mark completed steps
- Update progress tracking
Orchestrator coordinates next agents:
- Pass recovered artifacts to next step
- Resume workflow execution
- Monitor for additional interruptions
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
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
Related Documentation
- Planner Agent - Stateless Behavior Rule
- Orchestrator Agent - Context Recovery
- CUJ-027 - Workflow Recovery After Context Loss