auto-commit-rs
Minimal CLI tool that generates git commit messages via LLMs.
Fast, lightweight, cross-platform. No runtime dependencies — just a single binary.
⚠️ Disclaimer: AI Generation and Code Quality
Please note that the majority of the code in this repository was generated by agentic AI. To ensure the quality and stability of the project, the following workflows are strictly enforced:
- Human Oversight: An AI agent does not commit code blindly. Every pull request, architecture decision, and code block generated by the AI is carefully reviewed and refined by a human developer.
- Unit Testing: The codebase is supported by comprehensive unit tests. We rely on standard CI/CD practices and test coverage to verify that the AI-generated logic performs exactly as expected.
- Use at Your Own Risk: While we strive for high code quality through testing and review, this software is provided "as is," without warranty of any kind.
Why Rust?
Tools like opencommit do the same thing but require Node.js and weigh in at ~100MB of node_modules. cgen is a single ~2MB static binary. No runtimes, no interpreters, no package managers — download and run.
| cgen | opencommit | |
|---|---|---|
| Install size | ~2 MB | ~100 MB |
| Runtime deps | None | Node.js |
| Startup time | Instant | ~300ms (Node cold start) |
| Distribution | Single binary | npm install |
Install
Linux / macOS (curl)
|
This detects your OS and architecture, downloads the latest release binary to /usr/local/bin, and makes it executable. Set INSTALL_DIR to change the target:
INSTALL_DIR=/.local/bin |
Windows (PowerShell)
irm https://raw.githubusercontent.com/gtkacz/auto-commit-rs/main/scripts/install.ps1 | iex
This downloads the latest release to %LOCALAPPDATA%\cgen\ and adds it to your user PATH.
Cargo
From crates.io:
From git:
Manual Download
Grab a binary from the Releases page and place it somewhere in your PATH.
Available binaries:
cgen-linux-amd64— Linux x86_64cgen-macos-amd64— macOS Intelcgen-macos-arm64— macOS Apple Siliconcgen-windows-amd64.exe— Windows x86_64
Quick Start
# 1. Set your API key (one-time)
# or: export ACR_API_KEY=your-key-here
# 2. Stage files and generate commit
Usage
cgen # Generate commit message and commit
cgen --dry-run # Generate and show message without committing
cgen --verbose # Print final system prompt used for LLM call (diff omitted)
cgen --tag # Create next semantic version tag after commit
cgen --no-verify # Forward flags to git commit
cgen alter <hash> # Regenerate message from that commit's diff and rewrite it
cgen alter <old> <new> # Use old..new net diff, rewrite <new> message
cgen undo # Undo latest commit with safety prompts (soft reset)
cgen update # Update cgen to the latest version
cgen config # Interactive config editor (auto-detects scope)
cgen prompt # Print the LLM system prompt without running anything
Any arguments passed to cgen (without a subcommand) are forwarded directly to git commit.
Configuration
All settings use the ACR_ prefix. Layered resolution: defaults → global TOML → local .env → env vars.
| Variable | Default | Description |
|---|---|---|
ACR_PROVIDER |
groq |
LLM provider (groq, openai, anthropic, gemini, or custom) |
ACR_MODEL |
llama-3.3-70b-versatile |
Model name |
ACR_API_KEY |
— | API key (required) |
ACR_API_URL |
auto | API endpoint (auto-resolved from provider) |
ACR_API_HEADERS |
auto | Custom headers (Key: Value, Key2: Value2) |
ACR_LOCALE |
en |
Commit message language |
ACR_ONE_LINER |
1 |
Single-line commits (1/0) |
ACR_COMMIT_TEMPLATE |
$msg |
Template — $msg is replaced with LLM output |
ACR_LLM_SYSTEM_PROMPT |
(built-in) | Base system prompt |
ACR_USE_GITMOJI |
0 |
Enable gitmoji (1/0) |
ACR_GITMOJI_FORMAT |
unicode |
Gitmoji style (unicode/shortcode) |
ACR_REVIEW_COMMIT |
1 |
Review message before committing (1/0) |
ACR_POST_COMMIT_PUSH |
ask |
Post-commit push behavior (never/ask/always) |
ACR_SUPPRESS_TOOL_OUTPUT |
0 |
Suppress git subprocess output (1/0) |
ACR_WARN_STAGED_FILES_ENABLED |
1 |
Warn when staged file count exceeds threshold (1/0) |
ACR_WARN_STAGED_FILES_THRESHOLD |
20 |
Staged files warning threshold (warn when count is greater) |
ACR_CONFIRM_NEW_VERSION |
1 |
Ask before creating the computed --tag version (1/0) |
ACR_AUTO_UPDATE |
— | Enable automatic updates (1/0); prompts on first run if unset |
Config Locations
- Global:
~/.config/cgen/config.toml(Linux),~/Library/Application Support/cgen/config.toml(macOS),%APPDATA%\cgen\config.toml(Windows) - Local:
.envin git repo root
Variable Interpolation
ACR_API_URL and ACR_API_HEADERS support $VARIABLE interpolation from environment variables:
ACR_API_URL=https://api.example.com/v1//chat
ACR_API_HEADERS=Authorization:
Safety and Workflow Controls
cgennow prints staged file count and names before generating a commit message.- If staged files exceed
ACR_WARN_STAGED_FILES_THRESHOLDand warnings are enabled, cgen asks for confirmation before continuing. cgen --dry-rungenerates and prints the final commit message but does not create a commit.cgen --verboseprints the final system prompt sent to the LLM and never prints diff payload.cgen promptprints the full LLM system prompt (based on current config) without running any LLM call or git operations.cgen configauto-detects the context: inside a git repo it asks whether to edit local or global settings; outside a repo it opens the global config directly.cgen alter --dry-rungenerates and prints the rewritten message but does not rewrite history.cgen --tagcreates a semantic version tag after a successful commit:- no existing tag ->
0.1.0 - latest semver tag
x.y.z->x.(y+1).0 - latest tag not in semantic versioning -> error
- no existing tag ->
- If
ACR_CONFIRM_NEW_VERSION=1, cgen asks before creating the computed tag; if0, it creates it directly. cgen alter <old> <new>uses theold..newnet diff as LLM input and rewrites only the<new>commit message.- If
cgen altertargets an already-pushed commit, cgen requires explicit confirmation before rewriting. - After a real commit, push behavior follows
ACR_POST_COMMIT_PUSH:never: never pushask: prompt whether to push (default)always: push automatically
- For rewritten pushed history, cgen does not auto-force-push; use manual
git push --force-with-leaseif needed. cgen undoonly undoes the latest commit (git reset --soft HEAD~1), never pushes, and warns before undoing pushed commits.
Updating
cgen updatechecks for a newer version on GitHub and runs the appropriate installer:- If
cargois available:cargo install auto-commit-rs - Otherwise on Linux/macOS: re-runs the curl install script
- Otherwise on Windows: re-runs the PowerShell install script
- If
- On every run, cgen checks the latest GitHub release tag against the current version.
- The first time cgen runs, it asks whether to enable automatic updates and saves the preference to the global config.
- If
ACR_AUTO_UPDATE=1, cgen automatically updates when a newer version is found. - If
ACR_AUTO_UPDATE=0(or unset after the prompt), a warning is shown at the end of the output with the available version.
Providers
Built-in providers: Groq (default), OpenAI, Anthropic, Gemini.
For custom providers, set ACR_PROVIDER to any name and provide ACR_API_URL. Custom providers default to OpenAI-compatible request format.
Testing and Coverage
# Run all tests
# Enforce core logic coverage (matches CI gate)
Contributing
Contributions are welcome! Whether it's a new provider (often just 5 lines), a bug fix, or a documentation improvement — every bit helps.
See CONTRIBUTING.md for the full guide, including how to set up the development environment and how to add a new default provider step-by-step.