Skip to content

hsingjui/cc-guardian

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🛡️ ccg - Claude Code Checkpoint Guardian

简体中文

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.

✨ Features

  • ✍️ 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.

📦 Installation

  1. Download the appropriate binary for your system from the Releases page.
  2. Make the binary executable and move it to a directory in your system's PATH.

Linux

# 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

macOS

# 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

Windows

  1. Download the ccg-windows-x64.exe file.
  2. Create a folder for it, for example, C:\Program Files\ccg.
  3. Move the downloaded .exe file into this folder and rename it to ccg.exe.
  4. Add the folder (C:\Program Files\ccg) to your system's Path environment variable.

After these steps, you should be able to run ccg from any terminal.

🤖 Integration with Claude Code

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.

🚀 Usage

Initialize ccg

Before using ccg, you need to initialize it in your project's repository.

ccg init

➕ Create a Checkpoint

Save 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"

📋 List Checkpoints

View a list of all the checkpoints you've created.

ccg list

You can also specify the number of checkpoints to show:

ccg list -n 20

ℹ️ Show Checkpoint Details

View 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> --diff

🔙 Restore a Checkpoint

Revert your project's files to the state of a specific checkpoint.

ccg restore <checkpoint_hash>

👀 Compare Checkpoints

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>

💻 Local Development

To set up ccg for local development:

  1. Clone the repository:

    git clone https://github.com/your-username/cc-guardian.git
    cd cc-guardian
  2. Build the project:

    cargo build
  3. Run the tests:

    cargo test
  4. Run the application:

    cargo run -- <command>

    For example, to see the help message:

    cargo run -- --help

🤝 Contributing

Contributions are welcome! Please feel free to submit a pull request or open an issue.

📄 License

This project is licensed under the MIT License.

About

Claude Code Checkpoint Guardian

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages