ai newsFr., 30. Okt.
EilmeldungSearch all your past Claude Code sessions with MemPalace

Stop correcting Claude in prose, rewind the session instead

When Claude makes a change you did not want, the reflex is to type a correction. “You shouldn’t have touched that file, undo it.” That message goes into the context window. Claude’s apology goes into the context window. The re-edit goes into the context window. And the bad version of the file is st

dev.toFreitag 19:57 · 30.10.3 Min. Lesezeit
Bild: dev.to

Posted on Oct 30 • Originally published at Medium

When Claude makes a change you did not want, the reflex is to type a correction. “You shouldn’t have touched that file, undo it.” That message goes into the context window. Claude’s apology goes into the context window. The re-edit goes into the context window. And the bad version of the file is still sitting in the history, shaping everything that comes after. You paid tokens to make the session worse.

There is a command for exactly this. /rewind moves the session back to an earlier prompt and restores the files Claude edited along the way, so nothing about the mistake survives in the transcript.

Type /rewind, or press Esc twice while the prompt input is empty, and you get a menu listing every prompt you sent in the session. Pick one and you are offered five actions:

The two code options only show up when that checkpoint has tracked file changes to revert. And if the prompt input has text in it, the first Esc clears the text instead of opening the menu. Press Up afterwards to pull it back out of input history.

This is the part to internalize before you rely on it. Claude Code snapshots the file edits Claude makes through its own edit tools. That is the entire scope.

Edit / Write by Claude tracked, /rewind restores it Bash: rm, mv, cp not tracked Your own edits in the editor not tracked Background subagents not tracked Symlinks and hard links skipped on restore Enter fullscreen mode Exit fullscreen mode The Bash exception is the one that bites. If Claude ran rm old_config.yml as a shell command, /rewind will not bring that file back. Same for mv and cp. Edits from a concurrent session are invisible too, and so are changes made by a background subagent. Foreground forked skills, the ones declared with context: fork and background: false, are the single subagent case that does get restored.

Two more edges. A message you queue while Claude is still working joins the running turn and never gets its own checkpoint, so it will not appear in the menu at all. And restore skips symlinked and hard-linked paths, which is how dotfile managers and pnpm stores end up with “Restored the code, but skipped N files”.

/debug # then read ~/.claude/debug/<session-id>.txt to see which paths were skipped and why Enter fullscreen mode Exit fullscreen mode None of this touches git. Checkpointing is session-level recovery, not version history.

A checkpoint is created on every prompt that starts a turn. Claude Code keeps file snapshots for the 100 most recent checkpoints in a session, and a session’s snapshots are swept roughly 30 days after it last saved one. That window is cleanupPeriodDays in settings.json.

{ "cleanupPeriodDays": 90, "fileCheckpointingEnabled": true } Enter fullscreen mode Exit fullscreen mode Rewinding to a checkpoint whose snapshots were already swept fails with No files were restored. If you keep long-lived sessions around, raise the number before you need it, not after.

Checkpoints are saved with the conversation, so resuming a session days later still gives you the full rewind menu. If you ran /clear earlier in the same process, the menu puts a /resume <session-id> (previous session) entry at the top so you can rewind past the clear. That entry needs v2.1.191 or later.

To turn file snapshots off entirely, set fileCheckpointingEnabled to false, or export CLAUDE_CODE_DISABLE_CHECKPOINTS with any non-empty value.

These get mixed up constantly. Only one of them writes to your working tree.

So when a change goes wrong, /compact does nothing for you, and /clear throws the good context away along with the bad. Rewind is the surgical one.

Quelle: dev.to (dev.to). Original öffnen