This hook integrates with Claude Code to automatically create git checkpoints (snapshots) of your code before any file modifications. It provides a safety net allowing you to easily restore previous states if needed, without interfering with your main git repository.
git clone https://github.com/Ixe1/claude-code-checkpointing-hook.gitThis hook integrates with Claude Code to automatically create git checkpoints (snapshots) of your code before any file modifications. It provides a safety net allowing you to easily restore previous states if needed, without interfering with your main git repository.
No install command available. Check the GitHub repository for manual installation instructions.
git clone https://github.com/Ixe1/claude-code-checkpointing-hookCopy the install command above and run it in your terminal.
Launch Claude Code, Cursor, or your preferred AI coding agent.
Use the prompt template or examples below to test the skill.
Adapt the skill to your specific use case and workflow.
Create a checkpoint hook for my [PROJECT_NAME] project in [PROGRAMMING_LANGUAGE]. I want to automatically save a snapshot of my code before any modifications. The checkpoint should be stored in a [STORAGE_LOCATION] directory and include a timestamp. Make sure the hook works with my existing git workflow.
# Git Checkpoint Hook for [PROJECT_NAME]
```python
import os
import shutil
from datetime import datetime
def create_checkpoint():
# Get current timestamp
timestamp = datetime.now().strftime('%Y%m%d_%H%M%S')
# Define source and destination paths
source_dir = os.getcwd()
destination_dir = os.path.join(os.getcwd(), 'checkpoints', f'checkpoint_{timestamp}')
# Create checkpoint directory
os.makedirs(destination_dir, exist_ok=True)
# Copy all files to checkpoint directory
for root, dirs, files in os.walk(source_dir):
for file in files:
if file.endswith('.py') or file.endswith('.js'): # Add more extensions as needed
source_file = os.path.join(root, file)
relative_path = os.path.relpath(source_file, source_dir)
destination_file = os.path.join(destination_dir, relative_path)
os.makedirs(os.path.dirname(destination_file), exist_ok=True)
shutil.copy2(source_file, destination_file)
print(f'Checkpoint created at {destination_dir}')
# Call the function to create a checkpoint
create_checkpoint()
```
## How to Use This Hook
1. Save this script as `create_checkpoint.py` in your project root directory.
2. Add the following line to your `.git/hooks/pre-commit` file:
```bash
python ../create_checkpoint.py
```
3. Make sure the `checkpoints` directory exists in your project root.
4. Now, every time you commit changes, a checkpoint will be automatically created.AI assistant built for thoughtful, nuanced conversation
Your one-stop shop for church and ministry supplies.
Automate your browser workflows effortlessly
Agents that listen, think and act for you.
Enterprise workflow automation and service management platform
Automate your spreadsheet tasks with AI power
Take a free 3-minute scan and get personalized AI skill recommendations.
Take free scan