This example demonstrates how to use the automatic Git checkpoint system with Claude Code.
# Run the setup script
./.claude/helpers/setup-checkpoints.sh
# Choose option 1 for simple checkpoints or option 2 for advanced featuresBefore editing any file, Claude automatically creates a checkpoint:
- Creates a Git stash of current changes
- Creates a checkpoint branch
- Stores metadata in
.claude/checkpoints/
After editing a file, Claude:
- Commits the changes with a descriptive message
- Creates a Git tag for easy reference
- Updates checkpoint metadata
When you submit a new task, Claude:
- Creates a checkpoint of the current state
- Includes task description in commit message
- Optionally creates GitHub releases (advanced mode)
When ending a Claude session:
- Creates a final checkpoint
- Generates a session summary
- Lists all checkpoints created during the session
# 1. Start Claude Code with checkpoints enabled
claude --settings .claude/settings-checkpoint-simple.json
# 2. Work on your project
# Claude will automatically create checkpoints
# 3. List all checkpoints
git tag -l 'checkpoint-*' | sort -r
# 4. View checkpoint details
./.claude/helpers/checkpoint-manager.sh show checkpoint-20240130-143022
# 5. Compare current state with a checkpoint
./.claude/helpers/checkpoint-manager.sh diff checkpoint-20240130-143022
# 6. Rollback to a checkpoint if needed
./.claude/helpers/checkpoint-manager.sh rollback checkpoint-20240130-143022# List all checkpoints
./.claude/helpers/checkpoint-manager.sh list
# Show checkpoint details
./.claude/helpers/checkpoint-manager.sh show <checkpoint-name>
# Rollback to checkpoint
./.claude/helpers/checkpoint-manager.sh rollback <checkpoint-name> [--branch|--reset|--stash]
# Compare with checkpoint
./.claude/helpers/checkpoint-manager.sh diff <checkpoint-name>
# Clean old checkpoints
./.claude/helpers/checkpoint-manager.sh clean [days]
# Generate summary report
./.claude/helpers/checkpoint-manager.sh summary-
Branch Rollback (safest):
./.claude/helpers/checkpoint-manager.sh rollback checkpoint-20240130-143022 --branch
Creates a new branch from the checkpoint
-
Stash Rollback (reversible):
./.claude/helpers/checkpoint-manager.sh rollback checkpoint-20240130-143022 --stash
Stashes current changes before resetting
-
Hard Reset (destructive):
./.claude/helpers/checkpoint-manager.sh rollback checkpoint-20240130-143022 --reset
⚠️ Permanently discards current changes
With the advanced configuration, you can:
- Create GitHub releases for major checkpoints
- Use GitHub CLI for enhanced tracking
- Generate release notes automatically
Enable by setting:
export CREATE_GH_RELEASE=trueThe system uses the checkpoint-hooks.sh script which can be customized:
- Modify checkpoint naming conventions
- Add custom metadata
- Integrate with other tools
- Regular Cleanup: Use
checkpoint-manager.sh clean 7to remove checkpoints older than 7 days - Session Summaries: Check
.claude/checkpoints/summary-*.mdfiles for session overviews - Metadata: All checkpoint metadata is stored in
.claude/checkpoints/*.json - Git Integration: All checkpoints are standard Git tags and branches
- Ensure Git is initialized in your project
- Check that
jqis installed - Verify hooks are enabled in settings.json
- Ensure you have committed or stashed current changes
- Check that the checkpoint exists with
git tag -l - Use
--stashoption to save current work
- Use the simple configuration if you encounter JSON parsing issues
- Check that all quotes are properly escaped
- Validate JSON with
jq '.' .claude/settings.json