Skip to content

Repository files navigation

git ai

Stage all changes and generate a conventional commit message with OpenAI gpt-5.6-terra in one command.

git add -A && git diff --staged | english | git commit -F -

The implementation is a native Rust binary. It preserves the original CLI, terminal output, Git synchronization behavior, hooks, token estimate, fireworks, and Star Wars stream.

Features

  • Generates a concise, single-line conventional commit message
  • Preserves an existing partial staged patch across pull/rebase synchronization
  • Resolves upstream, push remote, and first-push branches
  • Runs Husky pre-commit hooks unless --no-verify is set
  • Excludes lock files and environment files from the prompt
  • Counts input tokens and estimates cost locally
  • Embeds the original firew0rks animation frames in the binary

Installation

Requirements: a current Rust toolchain, Git, and Node.js only for the npm development commands.

git clone https://github.com/preynal/git-ai
cd git-ai
npm install
npm run build

Export the OpenAI API key:

export OPENAI_API_KEY="your-api-key"

For compatibility with the previous setup, the binary also reads .env from the project directory. GIT_AI_ENV_FILE can point to another dotenv file.

Recommended usage

Point the alias directly to the release binary built inside the clone:

[alias]
    ai = "!/absolute/path/to/git-ai/target/release/git-ai"

Then run this from any Git repository:

git ai

This path starts the Rust executable directly; Node.js is not involved at runtime. The previous !node /path/to/git-ai/git-ai.js alias remains supported as a compatibility fallback.

To update the tool later:

git pull --rebase
npm run build

The alias does not need to change because Cargo replaces the release binary at the same path.

Options

-s, --staged     Use already staged files without modifying the staged area
-p, --push       Accept immediately and push
-n, --no-verify  Skip manual, commit, and push hooks
-f, --fireworks  Play fireworks after completion
    --star-wars  Stream Star Wars after completion (-sw)

Without --push, press Enter to accept the generated message or any other key to cancel.

Development

cargo build
cargo fmt -- --check
cargo clippy --all-targets -- -D warnings
npm test

npm test keeps the historical end-to-end harness and routes it through the Rust binary using the small git-ai.js compatibility launcher. The native binary itself has no Node.js runtime dependency.

Core configuration lives in rust/config.rs.

License

MIT. See THIRD_PARTY_NOTICES.md for the embedded terminal animation.

About

Git auto-stage changes and generate a commit message from the diff

Resources

Stars

Watchers

Forks

Used by

Contributors

Languages