Capture current session context into an immutable snapshot for recovery and continuity.
Captures current session context into an immutable snapshot for recovery and continuity.
/plugin marketplace add foolishimp/ai_sdlc_method/plugin install aisdlc-methodology@aisdlcCapture current session context into an immutable snapshot for recovery and continuity.
<!-- Implements: REQ-TOOL-012.0.1.0 (Context Snapshot and Recovery) --> <!-- Implements: REQ-TOOL-002 (Developer Workspace) --> <!-- Implements: REQ-TOOL-003 (Workflow Commands) -->Usage: /aisdlc-snapshot-context
Instructions:
Check workspace exists:
.ai-workspace/ directory existsEnsure context_history directory exists:
.ai-workspace/context_history/ existsCheck template availability:
.ai-workspace/templates/CONTEXT_SNAPSHOT_TEMPLATE.mdRead active tasks:
.ai-workspace/tasks/active/ACTIVE_TASKS.mdParse tasks by status:
Create task tables:
Format for in_progress/pending:
- Task #{ID}: {TITLE} | REQ-{TAGS}
Format for blocked:
- Task #{ID}: {TITLE} | REQ-{TAGS} | Blocker: {REASON}
Extract work activities (from recent conversation, last 20-50 messages):
Identify decisions made:
Capture open questions:
Note blockers/issues:
Extract next steps:
Run git commands (if git available):
git branch --show-current # Current branch
git status # File changes
git log --oneline -n 5 # Recent commits
Parse git status output:
Handle git not available:
Get timestamp:
YYYY-MM-DD HH:MM:SSYYYY-MM-DD-HH-MM-SS (no spaces, no colons)Get project name:
.ai-workspace/config/workspace_config.ymlGet retention policy:
retention_days from workspace_config.ymlList existing snapshots:
.ai-workspace/context_history/snapshots/.ai-workspace/templates/CONTEXT_SNAPSHOT_TEMPLATE.mdReplace all template placeholders with gathered context:
| Variable | Source | Fallback |
|---|---|---|
{TIMESTAMP} | Current datetime | Required |
{YYYY-MM-DD} | Current date | Required |
{HH:MM:SS} | Current time | Required |
{HH-MM-SS} | Current time (filename-safe) | Required |
{SNAPSHOT_ID} | {YYYYMMDD}_{HHMM}_{label} | Required |
{PROJECT_NAME} | Workspace config or dir name | "Unknown Project" |
{GIT_BRANCH} | git branch --show-current | "(not in git repo)" |
{TOTAL_ACTIVE_COUNT} | Count of active tasks | 0 |
{IN_PROGRESS_COUNT} | Count of in-progress tasks | 0 |
{PENDING_COUNT} | Count of pending tasks | 0 |
{BLOCKED_COUNT} | Count of blocked tasks | 0 |
{IN_PROGRESS_TASKS_TABLE} | Formatted task list | "(None)" |
{PENDING_TASKS_TABLE} | Formatted task list | "(None)" |
{BLOCKED_TASKS_TABLE} | Formatted task list | "(None)" |
{CURRENT_WORK_DESCRIPTION} | From conversation analysis | "(No active work detected)" |
{RECENT_ACTIVITIES_LIST} | From conversation analysis | "(No recent activities)" |
{NEXT_STEPS_LIST} | From conversation analysis | "(No next steps defined)" |
{DECISIONS_LIST} | From conversation analysis | "(No decisions recorded)" |
{QUESTIONS_LIST} | From conversation analysis | "(No open questions)" |
{BLOCKERS_LIST} | From conversation analysis | "(No blockers)" |
{COMMAND_HISTORY} | Last 5-10 commands | "(No commands tracked)" |
{MODIFIED_FILES_LIST} | From git status | "(No modified files)" |
{STAGED_FILES_LIST} | From git status | "(No staged files)" |
{UNTRACKED_FILES_LIST} | From git status | "(No untracked files)" |
{GIT_STATUS_OUTPUT} | Full git status output | "(Git not available)" |
{PREVIOUS_SNAPSHOT_ID} | Previous snapshot filename | "None" |
{NEXT_SNAPSHOT_ID} | Always "None (latest)" | "None (latest)" |
{MESSAGE_COUNT} | Conversation message count | "Unknown" |
{SESSION_DURATION} | Estimated time | "Unknown" |
{COMMAND_COUNT} | Commands run this session | "Unknown" |
{FILES_MODIFIED_COUNT} | Count from git status | 0 |
{TESTS_RUN_SUMMARY} | From conversation | "None" |
{COMMIT_COUNT} | From git log | 0 |
{SOLUTION_NAME} | From design path | "unknown_solution" |
{RECENT_FINISHED_TASKS_LIST} | Last 3 from finished/ | "(None)" |
{RETENTION_DAYS} | From workspace config | 30 |
{WORK_SUMMARY} | Brief work summary | "continuing previous work" |
{OPEN_QUESTIONS_SUMMARY} | Summary of questions | "No open questions." |
For each section, if data is not available:
Generate filename (follows finished task convention):
{YYYYMMDD}_{HHMM}_{label}.md20251216_1430_implementing_auth_service.mdcontext_snapshot as defaultWrite to context_history directory:
.ai-workspace/context_history/{filename}Set file permissions (if platform supports):
If .ai-workspace/context_history/.snapshot_index.yml exists:
- id: snapshot-2025-12-16-14-30-45
timestamp: 2025-12-16T14:30:45Z
tasks_count: 5
files_changed: 8
prev: snapshot-2025-12-15-10-30-00
archived: false
next field╔══════════════════════════════════════════════════════════════╗
║ Context Snapshot Created Successfully ║
╚══════════════════════════════════════════════════════════════╝
📸 Snapshot: {SNAPSHOT_ID}
📁 Location: .ai-workspace/context_history/{filename}
📊 Snapshot Contents:
✓ Active Tasks: {TOTAL_ACTIVE_COUNT} ({IN_PROGRESS_COUNT} in-progress, {PENDING_COUNT} pending{, BLOCKED_COUNT blocked})
✓ File Changes: {FILES_MODIFIED_COUNT} modified, {STAGED_COUNT} staged
✓ Conversation Markers: {DECISIONS_COUNT} decisions, {QUESTIONS_COUNT} open questions
✓ Recovery Guidance: Included
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
💡 To restore this context later:
1. Read the snapshot:
cat .ai-workspace/context_history/{filename}
2. Tell Claude:
"Restore context from {SNAPSHOT_ID}"
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
📋 Total Snapshots: {TOTAL_SNAPSHOTS} active, {ARCHIVED_COUNT} archived
If snapshot creation fails at any point:
❌ Error: Failed to create context snapshot
Reason: {error_message}
Troubleshooting:
1. Check workspace is initialized: /aisdlc-init
2. Verify write permissions in .ai-workspace/context_history/
3. Check disk space available
For help: /aisdlc-help
After successful snapshot creation:
Count snapshots in active directory:
Check snapshot ages:
Archive old snapshots (if configured):
.ai-workspace/context_history/archive/{YYYY-MM}/| Error Condition | Message | Action |
|---|---|---|
| Workspace not initialized | "❌ Error: Workspace not initialized. Run /aisdlc-init first." | Exit |
| Cannot create directory | "❌ Error: Cannot create context_history directory: {reason}" | Exit |
| Cannot write snapshot | "❌ Error: Cannot write snapshot: {reason}" | Exit |
| Template missing | "⚠️ Warning: Template not found, using built-in template" | Continue |
| Git not available | "⚠️ Warning: Git not available, skipping file change detection" | Continue |
| ACTIVE_TASKS.md missing | "⚠️ Warning: ACTIVE_TASKS.md not found, snapshot will have no task data" | Continue |
Recommended Workflow:
/aisdlc-checkpoint-tasks (updates task status, creates finished docs)/aisdlc-snapshot-context (captures full session context)Complementary Purposes:
/aisdlc-checkpoint-tasks - Updates ACTIVE_TASKS.md, moves completed tasks to finished//aisdlc-snapshot-context - Captures broader context (conversation, decisions, questions)Data Flow:
/aisdlc-checkpoint-tasks
↓ (updates)
ACTIVE_TASKS.md
↓ (reads)
/aisdlc-snapshot-context
↓ (creates)
{YYYYMMDD}_{HHMM}_{label}.md (includes task status from ACTIVE_TASKS.md)
User: /aisdlc-snapshot-context
Output:
╔══════════════════════════════════════════════════════════════╗
║ Context Snapshot Created Successfully ║
╚══════════════════════════════════════════════════════════════╝
📸 Snapshot: 20251216_1430_implementing_auth_service
📁 Location: .ai-workspace/context_history/20251216_1430_implementing_auth_service.md
📊 Snapshot Contents:
✓ Active Tasks: 3 (2 in-progress, 1 pending)
✓ File Changes: 5 modified, 1 staged
✓ Conversation Markers: 2 decisions, 1 open question
✓ Recovery Guidance: Included
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
💡 To restore this context later:
1. Read the snapshot:
cat .ai-workspace/context_history/20251216_1430_implementing_auth_service.md
2. Tell Claude:
"Restore context from 20251216_1430_implementing_auth_service"
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
📋 Total Snapshots: 8
User: "Restore context from 20251216_1430_implementing_auth_service"
Claude Process:
.ai-workspace/context_history/20251216_1430_implementing_auth_service.mdOutput:
✅ Context restored from 20251216_1430_implementing_auth_service
📋 Session Summary (from snapshot):
- Date: 2025-12-16 14:30
- Branch: feature/auth-service
- Tasks: 3 active (2 in-progress, 1 pending)
🎯 You were working on:
- Task #42: Implement user authentication (REQ-F-AUTH-001)
- Status: In Progress
- Recent: Fixed failing tests in auth_service_test.py
💬 Open Questions (from snapshot):
1. Should we add rate limiting now or in next sprint?
📁 Uncommitted Work:
- src/auth/auth_service.py (modified)
- tests/auth/test_auth_service.py (modified)
🔄 Next Steps (from snapshot):
1. Complete refactoring of error handling
2. Add integration tests for login flow
Ready to continue? I can help with the next steps or answer the open question.
/aisdlc-checkpoint-tasks - use both for complete session saveRecommended Usage: