ccg is a Git-based checkpoint management tool designed for AI-assisted development. It helps you save and manage different stages of your code, creating a "checkpoint" that you can inspect or revert to at any time. This is particularly useful when working with AI code generators, allowing you to experiment freely with different approaches without losing track of your progress.
- ✍️ Checkpoint Management: Easily create, list, and restore code checkpoints.
- 🌳 Git-based: Leverages the power and reliability of Git to manage your code's history.
- 🔍 Detailed Diffs: Compare the changes between different checkpoints to understand your development process.
- 🌍 Internationalization: Supports multiple languages (English and Chinese).
- 💻 Simple CLI: An intuitive command-line interface for easy use.
- Download the appropriate binary for your system from the Releases page.
- Make the binary executable and move it to a directory in your system's
PATH.
# Make the binary executable
chmod +x ccg-linux-x64 # Or ccg-linux-x64-musl
# Move it to a directory in your PATH
sudo mv ccg-linux-x64 /usr/local/bin/ccg# Make the binary executable
chmod +x ccg-macos-arm64 # Or ccg-macos-x64
# Move it to a directory in your PATH
sudo mv ccg-macos-arm64 /usr/local/bin/ccg- Download the
ccg-windows-x64.exefile. - Create a folder for it, for example,
C:\Program Files\ccg. - Move the downloaded
.exefile into this folder and rename it toccg.exe. - Add the folder (
C:\Program Files\ccg) to your system'sPathenvironment variable.
After these steps, you should be able to run ccg from any terminal.
To automatically create a checkpoint after every file modification made by the AI, you can configure a hook in your Claude Code settings.json file.
Add the following hooks configuration to your settings.json:
"hooks": {
"PostToolUse": [
{
"matcher": "Edit|MultiEdit|Write",
"hooks": [
{
"type": "command",
"command": "ccg create"
}
]
}
]
}This will ensure that every time the AI edits, multi-edits, or writes a file, a new ccg checkpoint is automatically created.
Before using ccg, you need to initialize it in your project's repository.
ccg initSave the current state of your code as a new checkpoint. You can optionally add a message to describe the changes.
ccg create "Implemented the new feature"View a list of all the checkpoints you've created.
ccg listYou can also specify the number of checkpoints to show:
ccg list -n 20View the details of a specific checkpoint, including its commit information.
ccg show <checkpoint_hash>To see the code changes associated with a checkpoint, use the --diff or -d flag:
ccg show <checkpoint_hash> --diffRevert your project's files to the state of a specific checkpoint.
ccg restore <checkpoint_hash>See the difference between two checkpoints.
ccg diff <hash_a> <hash_b>If you omit the second hash, it will be compared against the current working directory.
ccg diff <hash_a>To set up ccg for local development:
-
Clone the repository:
git clone https://github.com/your-username/cc-guardian.git cd cc-guardian -
Build the project:
cargo build
-
Run the tests:
cargo test -
Run the application:
cargo run -- <command>
For example, to see the help message:
cargo run -- --help
Contributions are welcome! Please feel free to submit a pull request or open an issue.
This project is licensed under the MIT License.