Files
SuperClaude/.claude/commands/shared/session-recovery.yml
NomenAK 23a103d5dc refactor: Standardize @include reference system across all command files
- Fix @include references to use underscore format (Universal_Legend, Standard_Messages_Templates)
- Add missing ultracompressed.yml shared pattern file
- Update broken reference paths in all 18 command files
- Ensure consistent template naming across command system
- Optimize command file structure with standardized includes

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-06-25 00:21:27 +02:00

215 lines
6.5 KiB
YAML

# session-recovery.yml - Session Recovery & Context Preservation
## Startup Detection
```yaml
scan_on_startup:
locations:
- ./claudedocs/tasks/in-progress/*.md
- ./claudedocs/tasks/pending/*.md (overdue)
parse_tasks:
- extract metadata
- check git branch status
- identify next steps
- restore context variables
recovery_prompt:
found_tasks: "Found {count} active tasks. Resume work?"
no_tasks: "No active tasks found. Ready for new work."
overdue: "Task {id} overdue. Continue or reschedule?"
```
## Context Preservation
```yaml
session_state:
file_paths: currently modified files
variables: important data & settings
decisions: architectural choices made
blockers: issues & solutions attempted
auto_save_triggers:
- major code changes
- before risky operations
- session timeout warnings
- manual /task:pause
context_format:
```yaml
session_state:
current_files: [path1, path2]
key_variables:
api_endpoint: "https://api.example.com"
database_name: "myapp_prod"
decisions:
- "Used React over Vue for better team familiarity"
- "Chose PostgreSQL for ACID compliance"
blockers:
- issue: "CORS error on API calls"
attempted: ["added headers", "proxy setup"]
solution: "needed server-side CORS config"
```
```
## Hybrid Recovery Process
```yaml
step_1_identify:
- scan ./claudedocs/tasks/in-progress/
- parse task metadata
- check git branch status
- validate file existence
- restore previous TodoWrite state
step_2_restore_both_systems:
task_context:
- load session context
- summarize previous work
- identify blocking issues
todo_context:
- regenerate TodoWrite from task breakdown
- identify last completed todo
- set current focus todo
- preserve todo progress
step_3_seamless_resume:
no_prompts: true
auto_continue: true
template: |
Resuming {task_title} - working on: {current_todo}
Progress: {completed_todos}/{total_todos} todos, {task_progress}% complete
hybrid_state_restoration:
both_systems_sync:
- task provides persistence
- todos provide immediate focus
- progress tracked in both
- no duplication of effort
```
## Git Integration
```yaml
branch_tracking:
- verify branch exists
- check for uncommitted changes
- identify merge conflicts
- track remote status
checkpoint_restoration:
- list available checkpoints
- show diff since last checkpoint
- offer rollback options
- suggest merge strategies
```
## Session Break Handling
```yaml
graceful_pause:
auto_triggers:
- context very high usage
- long inactivity
- error thresholds
pause_actions:
- save current context
- create git checkpoint
- update progress status
- log session summary
resume_preparation:
- validate environment
- check dependencies
- restore file states
- prepare tools
```
## Multi-Task Management
```yaml
concurrent_tasks:
max_active: 3
priority_rules:
- high priority blocks others
- related tasks can be parallel
- different areas can overlap
task_switching:
- auto-save current context
- create checkpoint
- switch git branch
- restore new context
conflict_resolution:
- file modification conflicts
- git merge requirements
- dependency overlaps
- resource constraints
```
## Recovery Patterns
```yaml
Recovery_Patterns:
Session_Detection:
Startup_Scan:
Locations: [".claudedocs/tasks/in-progress/", ".claudedocs/tasks/pending/"]
Parse_Metadata: "Extract task ID, title, status, branch, progress"
Git_Validation: "Check branch exists, clean working tree, remote sync"
Context_Restoration: "Load session state, key variables, decisions"
Recovery_Decision_Matrix:
Active_Tasks_Found: "Auto-resume most recent or highest priority"
Multiple_Tasks: "Present selection menu with progress summary"
Stale_Tasks: "Tasks >7 days old require confirmation"
Corrupted_State: "Fallback to manual recovery prompts"
Context_Recovery:
State_Reconstruction:
File_Context: "Restore working file list and modification tracking"
Variable_Context: "Reload important session variables and configurations"
Decision_Context: "Restore architectural and implementation decisions"
Progress_Context: "Rebuild todo list from task breakdown and current phase"
Integrity_Validation:
File_Existence: "Verify all referenced files still exist"
Git_Consistency: "Check branch state matches task expectations"
Dependency_Check: "Validate required tools and services available"
Context_Completeness: "Ensure all critical context elements present"
Automatic_Recovery:
Seamless_Resume:
No_User_Prompts: "Silent recovery for single active task"
Progress_Display: "Show task progress and current focus"
Context_Summary: "Brief summary of previous work and decisions"
Immediate_Action: "Continue with next logical step"
Smart_Restoration:
Todo_Regeneration: "Rebuild TodoWrite from task state and progress"
Priority_Reordering: "Adjust todo priorities based on new context"
Blocker_Detection: "Identify and surface any previous blockers"
Next_Step_Identification: "Determine optimal next action"
Error_Recovery:
Partial_State_Recovery:
Task_Only: "Task file exists but todos missing - regenerate todos"
Todos_Only: "Todos exist but task missing - continue with warning"
Corrupted_Task: "Parse what's possible, prompt for missing info"
Git_Mismatch: "Task branch doesn't exist - offer branch creation"
Fallback_Strategies:
Manual_Recovery: "Present recovery options to user"
Fresh_Start: "Option to abandon recovery and start fresh"
Partial_Import: "Import what's recoverable, start new for rest"
Checkpoint_Rollback: "Restore from last known good checkpoint"
Recovery_Communication:
Status_Messages:
Starting_Recovery: "🔄 Detecting previous session state..."
Task_Found: "📋 Found active task: {title} ({progress}% complete)"
Context_Restored: "✅ Session context restored - continuing work"
Recovery_Failed: "⚠ Could not fully restore context - manual recovery needed"
Progress_Indicators:
Task_Progress: "{completed_todos}/{total_todos} steps completed"
Time_Estimates: "~{estimated_remaining} remaining"
Current_Focus: "Working on: {current_todo_description}"
Recent_Activity: "Last worked on {time_ago}"
```