Skip to main content

claude-rewind

Reopen a Claude Code session at any earlier prompt, including prompts from before a compaction.

When a long Claude Code session compacts, claude --resume and the rewind menu (Esc Esc) only reach back to the last compaction. Everything before it is still in the session file on disk, but Claude Code gives you no way back to it (anthropics/claude-code#27242).

claude-rewind lists every prompt you typed in a session, across all of its compactions, and creates a new session that ends just before the prompt you pick. Then it opens that session in Claude Code. The original session is never modified.

Install

Needs Python 3.9 or newer and fzf.

uv tool install claude-rewind
# or
pipx install claude-rewind

Usage

claude-rewind                   # pick a session, then a prompt
claude-rewind <session-id>      # pick a prompt in this session (an ID or a .jsonl path)
claude-rewind --name "My title" # title for the new session
claude-rewind --no-launch       # create the session and print how to open it

Both lists show the newest entries first; type to search. Each prompt row shows when you sent it and the context size Claude Code reported at that point.

The new session is titled after the original with (rewind) appended, unless you pass --name. It is saved right away and appears in claude --resume like any other session.

Sessions are read from ~/.claude/projects, or $CLAUDE_CONFIG_DIR/projects when that variable is set.

How it works

The copy follows fork_session in Anthropic's Agent SDK. It keeps the main conversation up to the parent of the prompt you picked, gives every entry a new ID and the new session ID, and writes <new-id>.jsonl next to the original. Cutting at the prompt's parent leaves out branches you abandoned with an earlier rewind. The file is streamed, so a 300 MB session takes about a second.

Limitations

  • Claude Code opens any session at its most recent compaction. If the prompt you pick comes after one or more compactions, the new session opens at the last of those, with the earlier part shown as its summary.
  • If the context size at the point you pick is close to your auto-compact limit, Claude Code compacts again soon after you continue.
  • Code checkpoints are not copied, so /rewind in the new session restores the conversation but not files from before the copy.
  • Session files are an internal Claude Code format that can change between releases. Tested with Claude Code 2.1.310 on Linux.

License

MIT

Metadata

Release files for claude-rewind 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for claude-rewind 0.1.0
File Size Uploaded Provenance Actions
claude_rewind-0.1.0.tar.gz 10.1 kB With provenance Details for claude_rewind-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for claude-rewind 0.1.0
File Interpreter ABI Platform Actions
claude_rewind-0.1.0-py3-none-any.whl Python 3 none any Details for claude_rewind-0.1.0-py3-none-any.whl

Total release size: 18.9 kB

Release files / claude_rewind-0.1.0.tar.gz

Download URL claude_rewind-0.1.0.tar.gz
Size 10.1 kB
Tags Source
SHA-256 checksum
How to use checksums
b88a542904f8a0c3b6907c18ae65fa5ff6d07cbbf4b3098819da1f288cba03d6
BLAKE2b-256 checksum
How to use checksums
af8efb1041281eb9215bd51bf31142a0f4872301c4a3e00f01fff04f5a103b39
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 26, 2026.

Transparency log

Release files / claude_rewind-0.1.0-py3-none-any.whl

Download URL claude_rewind-0.1.0-py3-none-any.whl
Size 8.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8eabbf75f1f49fac90414534d169fe1ed94495528a45eb3bac86e42bb9261685
BLAKE2b-256 checksum
How to use checksums
0704f66c557a3335f3aac3d9d2d1acffd722057c124ee54bcdd2caa29a190d6a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 26, 2026.

Transparency log

Security for claude-rewind 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for claude_rewind-0.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 26, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page