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.
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
Readto 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.
- 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).
- In the Claude Code terminal press
Ctrl + Rto expand all dialog. - Choose Shell → Export Text As to save a
.txtfile 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.
- Run
python history_recovery.py(orpython3 history_recovery.py). - Click Set Root… to choose a directory where recovered files will be
written.
- Do not select your active project unless it is backed up.
- Paste the exported history into the top text box or use Open to load a saved transcript.
- Press Parse to populate the action list.
- 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
Notesentries as prompts for where to stop. - The log pane records results;
Save Log…is optional.
The application runs entirely offline and only modifies files in the chosen root directory.
- 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.
- If the terminal output format changes, parsing may fail.
- Tested only with macOS transcripts. Linux/WSL or future versions of Claude Code may behave differently.
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.
