Introduction
cgen is a CLI tool that generates git commit messages from your staged diff
using an LLM. It ships as a single ~3 MB executable with no language runtime to
install. The executable is cgen; the crates.io package is auto-commit-rs.
How it works
Running cgen in a repository with staged changes walks through a short pipeline:
- Inspect the staging area — staged files are listed up front; files
excluded from the LLM payload are marked
(not sent to LLM). - Filter the diff — binary, generated, and lockfile-style paths are dropped from the payload by default (diff exclusion patterns), and sensitive paths or secret-looking content block the request entirely (safety & workflow controls).
- Generate — the filtered diff is sent to the configured provider. If the call fails transiently, cgen can fall back through your saved presets automatically (fallback order).
- Review — the proposed message is shown for you to accept, regenerate,
edit in your editor, or cancel (configurable via
ACR_REVIEW_COMMIT). - Commit and push — the commit is created via
git commit, and post-commit push behavior follows yourACR_POST_COMMIT_PUSHsetting.
Beyond generation, cgen can rewrite past commit messages (cgen alter), undo
the latest commit safely (cgen undo), create semantic version tags (--tag),
browse previously generated commits (cgen history), and update itself
(cgen update).
Why Rust?
Tools like opencommit do the same thing but require Node.js and weigh in at ~100MB of node_modules. cgen is a roughly 3MB self-contained executable. GNU/Linux release builds use the platform C library; a musl artifact is also published for portable x86_64 Linux installs.
| cgen | opencommit | |
|---|---|---|
| Install size | ~2 MB | ~100 MB |
| Runtime deps | None | Node.js |
| Startup time | Instant | ~300ms (Node cold start) |
| Generation time | ~800ms | ~4s |
| Distribution | Single binary | npm install |
Reading this book
- New users: start with Installation and the Quick Start.
- Usage is the full command and flag reference.
- The Configuration chapters document every setting, starting from the complete settings table.
- The LLM Providers chapters cover built-in providers, presets, and fallback.
- The Internals chapters explain how the prompt is designed and how commit history tracking works.
⚠️ Disclaimer: AI Generation and Code Quality
The majority of the code in this repository was generated by agentic AI. To ensure quality and stability:
- Human oversight — every pull request, architecture decision, and code block generated by the AI is reviewed and refined by a human developer.
- Testing — the codebase is supported by comprehensive unit tests, a CI coverage gate, strict lints, and cross-platform test runs.
- Use at your own risk — this software is provided "as is", without warranty of any kind.