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:

  1. Inspect the staging area — staged files are listed up front; files excluded from the LLM payload are marked (not sent to LLM).
  2. 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).
  3. 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).
  4. Review — the proposed message is shown for you to accept, regenerate, edit in your editor, or cancel (configurable via ACR_REVIEW_COMMIT).
  5. Commit and push — the commit is created via git commit, and post-commit push behavior follows your ACR_POST_COMMIT_PUSH setting.

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.

cgenopencommit
Install size~2 MB~100 MB
Runtime depsNoneNode.js
Startup timeInstant~300ms (Node cold start)
Generation time~800ms~4s
DistributionSingle binarynpm install

Reading this book

⚠️ 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.