Checkpointing Claude Code Changes Before Risky Refactors
A practical walkthrough of Claude Code checkpointing: how automatic checkpoints capture code before each edit, how to rewind and summarize with /rewind, the difference between restore and summarize, and the limitations you must know before a risky refactor.
Checkpoints only track files edited through Claude's file-editing tools; changes made by bash commands (rm, mv, cp) are NOT tracked and cannot be undone via rewind., External or concurrent-session edits are generally not captured unless they touch the same files; do not rely on checkpoints for those., Checkpoints are session-level local undo, not version control; commit to Git before and after risky work for permanent history.
Privacy notes
Checkpoints and session state are stored locally and cleaned up with the session after 30 days by default., Restoring or summarizing changes session state locally; it does not transmit anything beyond the normal model requests., Summaries are AI-generated from your conversation; the original messages remain in the local transcript.
Author
JPette1783
Submitted by
JPette1783
Claim status
unclaimed
Last verified
2026-06-05
Decision playbook
Review trust signals before you adopt
Signals are present but mixed. Use the checklist below to confirm the source and operational safety for your environment.
Compare context
Selected
0
Current score
63
Baseline
—
Delta
No baseline selected
No major trust-signal divergence detected in the current selection.
Source and provenance checks
Needs review
Confirm ownership and provenance before trusting install instructions.
Source link availableRequired
Open the canonical repository and verify ownership.
Done
Source provenance statusRequired
Marked as source-backed.
Done
Metadata reviewed
No reviewed flag detected in metadata.
Pending
Safety and privacy checks
Complete
Validate risk disclosures before installation or API wiring.
Safety notes presentRequired
Review the listed safety guidance before running commands.
Done
Privacy notes presentRequired
Review data handling notes before connecting accounts or secrets.
Done
Trust level risk gateRequired
Trust level does not block evaluation.
Done
Package and install checks
Needs review
Check package metadata and artifact integrity signals.
Install payload available
Install or copy payload is available for review.
Done
Package verification flag
No package verification flag provided.
Pending
Checksum metadata
No checksum provided for downloaded artifact.
Pending
Compare-driven decision checks
Needs review
Use compare context to validate trade-offs before adoption.
Compare tray has multiple entries
Add at least one more entry to compare trust differences.
3 safety and 3 privacy notes across 3 risk areas. Review closely: credentials & tokens.
3 areas
SafetyLocal filesCheckpoints only track files edited through Claude's file-editing tools; changes made by bash commands (rm, mv, cp) are NOT tracked and cannot be undone via rewind.
SafetyCredentials & tokensExternal or concurrent-session edits are generally not captured unless they touch the same files; do not rely on checkpoints for those.
SafetyCredentials & tokensCheckpoints are session-level local undo, not version control; commit to Git before and after risky work for permanent history.
PrivacyCredentials & tokensCheckpoints and session state are stored locally and cleaned up with the session after 30 days by default.
PrivacyCredentials & tokensRestoring or summarizing changes session state locally; it does not transmit anything beyond the normal model requests.
PrivacyExecution & processesSummaries are AI-generated from your conversation; the original messages remain in the local transcript.
Safety notes
Checkpoints only track files edited through Claude's file-editing tools; changes made by bash commands (rm, mv, cp) are NOT tracked and cannot be undone via rewind.
External or concurrent-session edits are generally not captured unless they touch the same files; do not rely on checkpoints for those.
Checkpoints are session-level local undo, not version control; commit to Git before and after risky work for permanent history.
Privacy notes
Checkpoints and session state are stored locally and cleaned up with the session after 30 days by default.
Restoring or summarizing changes session state locally; it does not transmit anything beyond the normal model requests.
Summaries are AI-generated from your conversation; the original messages remain in the local transcript.
Prerequisites
Claude Code installed and a session where Claude makes edits with its file-editing tools.
A working understanding that checkpoints complement, not replace, Git.
Optional: configured cleanupPeriodDays if you want to change the 30-day retention.
Schema details
Install type
copy
Troubleshooting
No
Full copyable content
## Overview
Claude Code automatically tracks the file edits Claude makes, so you can rewind
to an earlier state if a change goes wrong. That safety net is what makes
ambitious, wide-scale refactors less risky, as long as you understand exactly
what checkpoints do and do not cover.
## How checkpoints work
- Every user prompt creates a new checkpoint capturing code state before edits.
- Checkpoints persist across sessions, so you can access them in a resumed
conversation.
- They are cleaned up with the session after 30 days by default.
## Rewind and summarize
Open the rewind menu, which lists each prompt you sent, then choose an action:
```bash
# Open the rewind menu (either works)
/rewind
# …or press Esc twice when the prompt input is empty
# Prefer a separate branch over rewinding the current session:
claude --continue --fork-session
```
Each menu action affects code, conversation, or both differently:
| Action | Reverts code | Reverts conversation | Use when |
| --- | --- | --- | --- |
| Restore code and conversation | Yes | Yes | A change went wrong and you want a clean slate at that prompt |
| Restore conversation | No | Yes | The code is fine but the discussion went off track |
| Restore code | Yes | No | Keep the discussion, undo only the file changes |
| Summarize from here | No | Compresses forward | Free context while keeping earlier history intact |
| Summarize up to here | No | Compresses earlier | Free context while keeping recent messages in full |
Restore options revert state; summarize options only compress conversation. In
both summarize cases the original messages stay in the transcript.
## A safe refactor workflow
1. Commit your current work to Git so you have permanent history.
2. Start the refactor with Claude in a session.
3. If it goes off track, run `/rewind` and **Restore code** to the prompt before
the bad change.
4. Re-prompt with a corrected approach.
5. When the refactor is good, commit again.
## Limitations to know
- **Bash changes are not tracked**: files modified by `rm`, `mv`, `cp`, or other
shell commands cannot be undone through rewind. Only direct file edits are
tracked.
- **External changes are not tracked**: manual edits or edits from other
concurrent sessions are usually not captured.
- **Not a Git replacement**: treat checkpoints as local undo and Git as permanent
history and collaboration.
## When to branch instead
If you want to try a different approach while preserving the original session
intact, fork the session (`claude --continue --fork-session`) rather than
rewinding. Rewinding changes the current session; forking keeps both.
## Source
- Checkpointing: https://code.claude.com/docs/en/checkpointing
About this resource
Overview
Claude Code automatically tracks the file edits Claude makes, so you can rewind
to an earlier state if a change goes wrong. That safety net is what makes
ambitious, wide-scale refactors less risky, as long as you understand exactly
what checkpoints do and do not cover.
How checkpoints work
Every user prompt creates a new checkpoint capturing code state before edits.
Checkpoints persist across sessions, so you can access them in a resumed
conversation.
They are cleaned up with the session after 30 days by default.
Rewind and summarize
Open the rewind menu, which lists each prompt you sent, then choose an action:
# Open the rewind menu (either works)
/rewind
# …or press Esc twice when the prompt input is empty
# Prefer a separate branch over rewinding the current session:
claude --continue --fork-session
Each menu action affects code, conversation, or both differently:
Action
Reverts code
Reverts conversation
Use when
Restore code and conversation
Yes
Yes
A change went wrong and you want a clean slate at that prompt
Restore conversation
No
Yes
The code is fine but the discussion went off track
Restore code
Yes
No
Keep the discussion, undo only the file changes
Summarize from here
No
Compresses forward
Free context while keeping earlier history intact
Summarize up to here
No
Compresses earlier
Free context while keeping recent messages in full
Restore options revert state; summarize options only compress conversation. In
both summarize cases the original messages stay in the transcript.
A safe refactor workflow
Commit your current work to Git so you have permanent history.
Start the refactor with Claude in a session.
If it goes off track, run /rewind and Restore code to the prompt before
the bad change.
Re-prompt with a corrected approach.
When the refactor is good, commit again.
Limitations to know
Bash changes are not tracked: files modified by rm, mv, cp, or other
shell commands cannot be undone through rewind. Only direct file edits are
tracked.
External changes are not tracked: manual edits or edits from other
concurrent sessions are usually not captured.
Not a Git replacement: treat checkpoints as local undo and Git as permanent
history and collaboration.
When to branch instead
If you want to try a different approach while preserving the original session
intact, fork the session (claude --continue --fork-session) rather than
rewinding. Rewinding changes the current session; forking keeps both.
Show that Checkpointing Claude Code Changes Before Risky Refactors is listed on HeyClaude. Paste this Markdown into your README — it renders the badge and links back to this page.
[](https://heyclau.de/entry/guides/checkpointing-claude-code-changes-before-risky-refactors)
How it compares
Checkpointing Claude Code Changes Before Risky Refactors side by side with 2 alternatives on trust, install, platform support, and disclosed safety notes — all from reviewed registry metadata.
1 trust signal differ across this comparison (Submitter).
A practical walkthrough of Claude Code checkpointing: how automatic checkpoints capture code before each edit, how to rewind and summarize with /rewind, the difference between restore and summarize, and the limitations you must know before a risky refactor.
A repeatable explore-plan-implement-verify workflow for large code migrations and refactors with Claude Code, using plan mode, /rewind checkpoints, subagents, and claude -p fan-out for batch file changes.
Source-backed checklist for reviewing Claude Code MCP client configuration before a team rollout, covering scopes, transports, commands, secrets, allowlists, denylists, approvals, and rollback.
✓Checkpoints only track files edited through Claude's file-editing tools; changes made by bash commands (rm, mv, cp) are NOT tracked and cannot be undone via rewind.
External or concurrent-session edits are generally not captured unless they touch the same files; do not rely on checkpoints for those.
Checkpoints are session-level local undo, not version control; commit to Git before and after risky work for permanent history.
✓The claude -p fan-out loop runs Claude non-interactively across many files. Scope it with --allowedTools (for example "Edit,Bash(git commit *)") so unattended runs cannot perform actions you did not intend, and test on 2-3 files before running at scale.
Checkpoints only track Claude's direct file edits, not changes made by bash commands (rm, mv, cp) or other processes, so commit to git before a large migration.
✓Local stdio MCP servers execute commands with the user's privileges, so review the exact command, arguments, package runner, file paths, and network behavior before sharing a config.
Remote MCP servers can expose model-controlled tools for production systems; require least-privilege scopes, explicit approval for write tools, and a rollback path before team rollout.
Do not rely on server names alone for enforcement because names are user-assigned labels; use command or URL allowlist entries when policy must control what actually runs.
Privacy notes
✓Checkpoints and session state are stored locally and cleaned up with the session after 30 days by default.
Restoring or summarizing changes session state locally; it does not transmit anything beyond the normal model requests.
Summaries are AI-generated from your conversation; the original messages remain in the local transcript.
✓Claude Code sends the files it reads and command output to the model as context. Avoid piping secrets or credentials into prompts, and exclude sensitive paths from migration runs.
✓MCP client configuration can reveal server URLs, internal hostnames, command paths, environment-variable names, header names, OAuth client IDs, and tool availability.
Do not store API keys, bearer tokens, client secrets, tenant IDs, or personal credentials in shared `.mcp.json`, managed-mcp.json, PR bodies, issue comments, logs, or screenshots.
Tool arguments, tool results, resources, prompts, logs, traces, and OAuth metadata can expose private repositories, tickets, databases, user identities, and workspace data.
Prerequisites
Claude Code installed and a session where Claude makes edits with its file-editing tools.
A working understanding that checkpoints complement, not replace, Git.
Optional: configured cleanupPeriodDays if you want to change the 30-day retention.
— none listed
A draft `.mcp.json`, `~/.claude.json` entry, plugin-provided MCP server, claude.ai connector plan, or managed-mcp.json deployment to review.
The server documentation, package or repository source, expected transport, command or URL, environment variables, headers, OAuth behavior, and tool list.
A test machine or disposable Claude Code profile where the configuration can be loaded with non-production data.
A named owner who can approve the rollout, publish the final configuration, and revoke credentials or block servers if the rollout fails.