Files
claudetools/.claude/memory/feedback_session_recovery.md
Mike Swanson eed3ece2c7 feat: session recovery toolset (orphan detector + /recover)
Reconstructs session logs from Claude Code transcripts when a session
crashes or is closed before /save. Two entry points:

- /recover <uuid|latest> : manual, Claude-reviewed reconstruction
- detect_orphaned_sessions.py : scheduled scan that auto-builds logs for
  substantive, unsaved, not-yet-recovered transcripts (banner-marked
  RECOVERED-UNVERIFIED), commits them, and posts a #bot-alerts FYI.

recover_session.py is the shared engine: Python extracts the verbatim
command/config/reference timeline; Ollama drafts prose-only narrative.
Machine-local ledger (.claude/state/) prevents reprocessing. Reviewed:
git add scoped to own files, ledger written only after successful push,
per-uuid idempotency, --max cap for unattended runs.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-01 18:33:07 -07:00

1.9 KiB

name, description, type
name description type
Unsaved sessions are recoverable from transcripts Claude Code transcripts let you rebuild a session log after a crash/close-before-save; a detector auto-recovers orphans and /recover does it manually feedback

Claude Code writes every session live to a transcript JSONL at ~/.claude/projects/<slug>/<uuid>.jsonl (slug = the claudetools repo root with /, \, and : each replaced by -; computed from claudetools_root in identity.json). A session closed or crashed before /save is NOT lost — the work is fully recorded in that transcript and can be distilled back into a normal session log.

Toolset (.claude/RECOVERY.md):

  • .claude/scripts/recover_session.py — engine. --uuid/--latest/--path with --print/--auto/--json.
  • .claude/scripts/detect_orphaned_sessions.py — scans idle transcripts, auto-recovers orphans (substantive AND not saved), commits + pushes, FYIs #bot-alerts. --dry-run to scan only. Ledger at .claude/state/recovered-sessions.json (machine-local).
  • /recover <uuid> — manual reviewed path; Claude corrects the draft before writing.
  • .claude/scripts/register-orphan-detector.ps1 — registers the scheduled task (Windows).

Accuracy split: Ollama drafts ONLY prose (summary/decisions/problems/pending); Python extracts commands, file paths, IPs, SHAs, tickets verbatim. Auto-recovered logs carry a [RECOVERED -- UNVERIFIED] banner until a human reviews them.

Why: Mike wanted to never lose work to a crashed/unclosed session again. Manual /save is the only thing that wrote logs before; the transcript is a complete fallback record.

How to apply: If a user says a session crashed or work was lost, run py .claude/scripts/detect_orphaned_sessions.py --dry-run to find candidate orphans, then /recover <uuid> to reconstruct and review a clean log. Don't assume work is gone — check the transcripts first.