restore — Claude Code command: what it does, how to install
restore rolls project files back to a previously saved checkpoint. Useful when recent experimental edits break your build and you need a working state.
MIT ★ 763 updated 2026-03-31
.claude/commands/restore.mdWhat restore does
The command inspects your Git stash list for entries created with /checkpoint. It accepts either latest or a specific stash index number to target the right snapshot.
Dirty working trees will not cause lost work. If uncommitted changes exist, the command captures them into a timestamped backup stash before touching files.
Checkpoints remain reusable after restoration because the command executes git stash apply rather than git stash pop. It relies on standard git, grep, and head utilities available in your shell.
What it helps with
- Revert workspace files to the latest checkpoint
- Switch back to a specific checkpoint by index number
- Back up dirty uncommitted work before restoring older code
Example prompts for the agent
- /restore
- /restore latest
- /restore 2
How to install restore
Manually: put the files in place
.claude/commands/restore.mdCall it with /restore. For all projects use ~/.claude/commands/
Manually: put the files in place
~/.codex/prompts/restore.mdCall it with /prompts:restore. Codex marks this format deprecated in favour of skills
Manually: put the files in place
.github/prompts/restore.prompt.mdManually: put the files in place
.gemini/commands/restore.tomlGemini stores commands as TOML: the prompt text goes into the prompt field
Questions about restore
How to install restore in Claude Code?
Add the command definition file to .claude/commands/restore.md. Claude Code will automatically recognise the /restore slash command.
What does the restore command do?
It finds Git stash items tagged with claude-checkpoint and applies the chosen snapshot to your workspace.
Does restoring delete the checkpoint?
No, it uses git stash apply instead of popping the stash. Your saved checkpoint remains in Git stash history for future rollbacks.
Source text
restore.md · MIT
---
description: Restore project to a previous checkpoint
category: workflow
allowed-tools: Bash(git stash:*), Bash(git status:*), Bash(git reset:*), Bash(grep:*), Bash(head:*)
argument-hint: "<checkpoint-number|latest>"
---
## Restore to checkpoint
Restore your project files to a previous checkpoint created with /checkpoint.
## Available checkpoints
!`git stash list | grep "claude-checkpoint" | head -10`
## Current status
!`git status --short`
## Task
Restore the project to a previous checkpoint. Based on $ARGUMENTS:
1. Parse the argument:
- If empty or "latest": Find the most recent claude-checkpoint stash
- If a number (e.g. "2"): Use stash@{2} if it's a claude-checkpoint
- Otherwise: Show error and list available checkpoints
2. Check for uncommitted changes with `git status --porcelain`. If any exist:
- Create a temporary backup stash: `git stash push -m "claude-restore-backup: $(date +%Y-%m-%d_%H:%M:%S)"`
- Note the stash reference for potential recovery
3. Apply the checkpoint:
- Use `git stash apply stash@{n}` (not pop, to preserve the checkpoint)
- If there's a conflict due to uncommitted changes that were stashed, handle gracefully
4. Show what was restored:
- Display which checkpoint was applied
- If uncommitted changes were backed up, inform user how to recover them
Example outputs:
- For `/restore`: "Restored to checkpoint: before major refactor (stash@{0})"
- For `/restore 3`: "Restored to checkpoint: working OAuth implementation (stash@{3})"
- With uncommitted changes: "Backed up current changes to stash@{0}. Restored to checkpoint: before major refactor (stash@{1})"
© carlrannaberg · MIT · carlrannaberg/claudekit