git-ai

git-ai

Save your prompts and keep track of code generated by AI.

curl -sSL https://gitai.run/install.sh | bash

git-ai blame src/log_fmt_authorship.rs

https://github.com/user-attachments/assets/74b49493-92af-4627-934a-a3c161dbb49f

How it works

git-ai uses checkpoints to establish authorship of specific lines of code. Agents call git-ai checkpoint before they write to the file system to mark any previous edits as yours. After they write to the file system they call checkpoint --author 'Claude Code' --model 'claude-4-sonnet' to mark their contribution as AI-generated. These checkpoints work similarly to how IDEs handle local history and they do not leave your machine.

When you commit code, the base commit’s checkpoints are compacted into a much smaller authorship log that is linked to your commit.

Status - Preview Release

July 2 2025 - Seeking Feedback. First version of the spec and Rust implementation released

Next: Finalize specification and start making PRs into Coding Agents

Why git-ai?

git blame attributes all code to the commit’s author, even when much of it is AI-generated.

⭐️Git-native - enhanced authorship is stored in Git and linked to commit hashes.

🫡Simple and explicit - no file system monitors, keyloggers or batch-write heuristics. Supported Agents call git-ai checkpoint --author "Claude Code" --model claude-4-sonnet after writing code.

🤞Emerging Standard - developers have tool choice, and they’re likely using a mix of Claude Code, Codex, Cursor, etc.

⚡️Fast + Cross Platform - implemented in Rust, as fast as git status, and built on libgit2


Installation

curl -sSL https://gitai.run/install.sh | bash

Init - adds a local precommit and postcommit hook

git-ai init

Setup your IDE or Agent CLI to log AI contributions

Supported:

[x] Cursor via Extension. Source and documentation are here

[x] Claude Code via Hooks

Help needed:

[ ] Sourcegraph Cody + Amp

[ ] OpenAI Codex

[ ] Windsurf

[ ] RovoDev CLI …your tool

Want to add yours? All PRs welcome! Add documentation or plugin code to /agent-support/{tool-name}.md

Manually:

If you want to manually mark code as written by you or your agent.

Before submitting your prompt (not specifying --author will default to your git.config.name.

git-ai checkpoint

After the AI has applied its changes, run checkpoint with the name of the agent you’re using.

git-ai checkpoint --author "Claude Code"

Work and commit

Claude Code will automatically mark its contributions after writing to the file system, and the pre-commit hooks will mark your contributions.

View authorship** - after your first commit, run:

git-ai blame path/to/file

For toolbuilders

The Standard (draft-1)

Authorship logs, attached to commits, pushed to the refs/ai/authorship as blob objects.

```json file=”refs/ai/authorship/f46b403b4f269bd2530b2d91a676449787886d02” { “schema_version”: “authorship/0.0.1”, “files”: { “src/main.rs”: { “file”: “src/main.rs”, “authors”: [ { “author”: “Claude Code”, “lines”: [12, [91, 101]], “agent_metadata”: { “model”: “claude-4-sonnet” } }, { “author”: “Aidan Cunniffe”, “lines”: [57], “agent_metadata”: null } ] } } }


**Coming next**: Prompt saving that maintains pointers to specific lines of code, across files.

### Adding Support to Your Agents

#### Via User-Installed CLI (Recommended)

Adding `git-ai` support to a coding agent is easy. You just have to call `git-ai checkpoint` once before writing to the file system and once immediately after your writes have completed. The `checkpoint` command has similar performance to `git status` and will not noticeably slow down your Agent's performance (we're talking ~100ms).

**Requirements:**

- Agents SHOULD check if `git-ai` is installed when they start and only try to log checkpoints if the user has it installed.
- Agents SHOULD write checkpoints to every git repo if the user has git-ai installed, no opt-in needed.
- Agents MUST only call `git-ai checkpoint` command from within a git repo. At the root or any sub directory will work.
- Agents MUST call `git-ai checkpoint` and wait for the command to finish before writing to the file system.
- Agents MUST call `git-ai checkpoint` immediately after writing generated code to the file system.
- Agents SHOULD not try to handle errors from the checkpoint command. Log them to the user to encourage them to fix or uninstall tool if it persists.

#### Via Rust Library

If you want to call `git-ai checkpoint` using a packaged rust binary and bindings, open an issue with runtime, language, and other details so we can provide the exact bindings you need. We'll provide a function like this that will run checkpoint without the CLI overhead.

**Note**: We suggest you adopt the CLI approach first, help make this a standard by providing great feedback, and then set up the deeper integration.

```rust
pub fn checkpoint_internal(
    repo_path: &str,
    author: &str,
    model: Option<&str>,
    human_author: Option<&str>,
) -> Result<(usize, usize, usize), GitAiError>

Known limitiaitons

Development Setup

git clone https://github.com/acunniffe/git-ai.git
cd git-ai
cargo build
cargo test

License

MIT