autocommit-rs 0.1.0

Tool that generates conventional commits from staged changes and executes the commit in one go.
autocommit-rs-0.1.0 is not a library.

autocommit-rs

Crates.io

Tool that generates and publishes conventional commits from staged changes in one go. For free :)

This is a Rust port of the original @wthrajat/autocommit TypeScript project.

Prerequisites

  • Rust (for cargo install)
  • One of these API keys:

Installation

From crates.io (recommended)

cargo install autocommit-rs

From source

git clone https://github.com/wthrajat/autocommit-rs
cd autocommit-rs
cargo build --release

The binary will be at ./target/release/autocommit. Copy it to your PATH:

cp ./target/release/autocommit ~/.local/bin/

Pre-built binaries

Pre-built binaries for Linux, macOS (Intel & Apple Silicon), and Windows are available on the GitHub Releases page.

Updating

cargo install autocommit-rs --force

Or download the latest pre-built binary from the GitHub Releases page.

Usage

  1. Do code changes in any repo you're working on and stage them:

    git add <files>
    
  2. Run autocommit in the terminal:

    autocommit
    
  3. Choose an option:

    • Accept and commit: Commits right away.
    • Edit message: Opens a text editor to adjust the message before committing.
    • Regenerate: Asks the AI for a new attempt.
    • Quit: Cancels the operation.

Command-line options

Flag Description
-v, --version Show version
-h, --help Show help message
--openai-key <key> Set OpenAI API key
--gemini-key <key> Set Gemini API key
--model <model> Set default model (openai or gemini)
--short Use short message style (one-line summary)
--long Use long message style (with description)
--sign Enable GPG signed commits
--no-sign Disable GPG signed commits
--no-verify Bypass pre-commit and commit-msg git hooks

Environment variables

Variable Description
OPENAI_API_KEY OpenAI API key (overrides config file)
GEMINI_API_KEY Google Gemini API key (overrides config file)
AUTOCOMMIT_MODEL Model to use: openai or gemini
AUTOCOMMIT_MESSAGE_STYLE Message style: short or long

Configuration

Configuration is stored in ~/.autocommitrc as JSON. On first run, autocommit will guide you through an interactive setup.

Local development

cargo build
cargo test
cargo run -- --help

Releasing

New releases are automated via GitHub Actions. To publish a new version:

Initial setup (one-time)

  1. Log in to crates.io

    cargo login
    

    Follow the prompt to create and paste an API token from crates.io/tokens.

  2. Add the token to GitHub Secrets

    • Go to repo settings → Secrets and variables → Actions
    • Add CRATES_IO_TOKEN with the token from step 1

Release a new version

  1. Update the version in Cargo.toml:

    version = "0.2.0"
    
  2. Commit and push to main:

    git add Cargo.toml
    git commit -m "chore(release): bump version to 0.2.0"
    git push origin main
    

The release workflow will automatically (no need to push tags manually):

  • Create a git tag (v0.2.0)
  • Publish the crate to crates.io
  • Build binaries for Linux, macOS, and Windows
  • Create a GitHub Release with the binaries attached

Manual publish (if needed)

If you need to publish without the automated workflow:

cargo publish

License

MIT