Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 

Repository files navigation

ClaudeCode Terminal History Recovery

Tool to replay file changes from a Claude Code session so you can selectively restore progress when Claude overwrites or corrupts your work. The provided history_recovery.py script parses an exported terminal transcript and lets you apply the recorded actions to a project directory.

Screenshot of the GUI

Action types

The transcript uses bullet markers such as ⏺ Write(path) or ⏺ Read(path). After parsing, each marker shows up in the action list:

  • Read – recreates the file exactly as it existed when Claude read it. Use these to build the initial state of files. If the file does not yet exist it will be created.
  • Write – applies the diff produced when Claude wrote to a file. Apply these after the corresponding Read to step through Claude's edits.
  • Update – multi-hunk patches produced by Claude's incremental updates.
  • Notes – lines beginning with > are your own prompts. They appear in the list but perform no file operations, letting you stop replaying right before a particular prompt.

Replay only the actions you want to recover code up to the point before Claude introduced mistakes.

Requirements

  • Tested using ClaudeCode v1.0.81 (August 2025) on macOS
  • Python 3.9+ with Tkinter (bundled with the standard Python installers on macOS, Windows and most Linux distributions).

Exporting history

  1. In the Claude Code terminal press Ctrl + R to expand all dialog.
  2. Choose Shell → Export Text As to save a .txt file or copy the text to your clipboard.

Example snippet of the expected format:

╭─────────────────────────────╮
│ ✻ Welcome to Claude Code!   │
│ cwd: /path/to/project       │
╰─────────────────────────────╯

⏺ Write(file_path: "hello.txt")
  ⎿ Hello from Claude

The script looks for bullet lines beginning with (Write, Read or Update) followed by indented content.

Usage

  1. Run python history_recovery.py (or python3 history_recovery.py).
  2. Click Set Root… to choose a directory where recovered files will be written.
    • Do not select your active project unless it is backed up.
  3. Paste the exported history into the top text box or use Open to load a saved transcript.
  4. Press Parse to populate the action list.
  5. Select each action and click Apply to replay it or Skip to ignore. Apply actions in order until just before Claude's bad change, using the Notes entries as prompts for where to stop.
  6. The log pane records results; Save Log… is optional.

The application runs entirely offline and only modifies files in the chosen root directory.

Known issues

  1. If Claude did not read an entire file, the transcript will not contain the full content and this app cannot recreate it. Add any missing originals to the root directory manually.
  2. If the terminal output format changes, parsing may fail.
  3. Tested only with macOS transcripts. Linux/WSL or future versions of Claude Code may behave differently.

Safety

Avoid pointing the tool at a directory containing important work. Replaying actions overwrites files in the selected root; ensure you have backups or are using version control.

About

Use exported macOS terminal history to restore files modified by Claude Code

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages