No description
Find a file
ferrumboll adda6bb0d3
Some checks failed
Test And Tag / check-version (push) Failing after 5s
Test And Tag / test (push) Has been skipped
Test And Tag / lint (push) Has been skipped
Test And Tag / build (push) Has been skipped
Test And Tag / build-nix (push) Has been skipped
Test And Tag / semver (push) Has been skipped
Test And Tag / test-integration (push) Has been skipped
fix: go version correct
2025-08-16 01:17:12 +02:00
.forgejo 🔥chore(ci): remove commitlint-rs installation step from test-and-tag workflow 2025-07-23 12:11:50 +02:00
.gitlab dependabot 2025-08-16 00:51:19 +02:00
commitlint ci: fix 2025-07-19 23:21:24 +02:00
config 🎨 style: reformat imports and update file permission literals to 0o notation across codebase 2025-07-23 07:30:40 +02:00
docs/themes feat: add GetCommitHistory method to VCS interface 2025-07-23 12:33:58 +02:00
generate refactor(generate): centralize RetryAttempt and GenerateResult types for reuse across modules 2025-07-19 21:49:19 +02:00
gitmoji 📝docs: add commit message examples and clarify gitmoji usage in documentation and prompts 2025-07-20 12:58:53 +02:00
openai ♻️ refactor(retry-callback): unify retry callback to use slice of attempts across codebase 2025-07-23 07:56:55 +02:00
prompt ♻️ refactor(prompt): include previous failed attempts in retry prompt for improved commit message generation 2025-07-23 07:42:46 +02:00
rebase fix: remove unreachable code in rebase message handling 2025-07-23 13:14:49 +02:00
types feat: add GetCommitHistory method to VCS interface 2025-07-23 12:33:58 +02:00
ui ♻️ refactor(ui): prevent regular commit flow initialization during rebase selection 2025-07-23 21:12:27 +02:00
vcs fix: remove unreachable code in rebase message handling 2025-07-23 13:14:49 +02:00
.fast-commit.example.toml feat(commitlint): add commitlint validation and auto-fix for commit messages with config support 2025-07-19 21:49:19 +02:00
.gitignore semver 2025-07-19 09:45:48 +02:00
.goreleaser.yaml 🔧ci: exclude ci directory from goreleaser source filters 2025-07-20 14:04:03 +02:00
flake.lock feat: Add comprehensive README with installation and usage guide 2025-07-17 07:19:43 +02:00
flake.nix ⬆️ chore(flake): bump version to 0.3.3 in flake.nix 2025-07-23 08:17:37 +02:00
go.mod fix: go version correct 2025-08-16 01:17:12 +02:00
go.sum test: add GoMock for OpenAIClient interface and update dependencies 2025-07-19 09:52:39 +02:00
LICENSE Initial commit 2025-07-16 22:24:15 +02:00
main.go fix: remove unreachable code in rebase message handling 2025-07-23 13:14:49 +02:00
main_test.go 🎨 style: reformat imports and update file permission literals to 0o notation across codebase 2025-07-23 07:30:40 +02:00
PLAN.md feat: implement Stage 1 rebase UI - commit selection and preview 2025-07-23 13:07:19 +02:00
README.md 📝docs: update README with improved install instructions and commitlint integration info 2025-07-21 08:06:12 +02:00
ROADMAP.md 📝 docs: add commitlint integration instructions and document related configuration options 2025-07-19 21:49:19 +02:00

Fast-Commit

A Go CLI application that generates intelligent commit messages using OpenAI's API. It analyzes git diffs and creates contextual commit messages, then prompts the user for confirmation.

Features

  • 🤖 AI-Powered: Uses OpenAI's GPT models to generate intelligent commit messages
  • 🎯 Context-Aware: Analyzes actual code changes to create relevant messages
  • ⚙️ Configurable: Supports TOML configuration and environment variables
  • 🔄 Interactive: Prompts for confirmation with regenerate option
  • 🔒 Safe: Never commits without explicit user confirmation
  • 📦 Lightweight: Single binary with minimal dependencies
  • 🎨 Gitmoji Support: Optional gitmoji integration for expressive commits
  • 🔄 Multi-VCS: Supports both Git and Jujutsu (jj) version control systems
  • Commitlint Integration: Validates commit messages with commitlint and auto-fixes violations

Installation

Prerequisites

  • Go 1.19 or later
  • Git installed and configured (or jj for Jujutsu support)
  • OpenAI API key
  • (Optional) Commitlint for commit message validation

Install Options

For now it is only possible to install from source or with the flake. Feel free to let me know if you want to see it somewhere else.

Build from source

git clone https://codeberg.org/ferrumboll/fast-commit
cd fast-commit
go build -o fast-commit

Build with flake

nix profile install git+https://codeberg.org/ferrumboll/fast-commit

# to update
nix profile upgrade fast-commit

Configuration

Configuration File

Create a configuration file at ~/.config/fast-commit.toml:

api_key = "your-openai-api-key-here"
model = "gpt-4"
base_url = "" # If you want to use OpenAI compatible APIs
extra_prompt = "Write concise, conventional commit messages following the format: type(scope): description"
use_gitmoji = true
use_full_gitmoji = true
vcs = "git"  # or "jj" for Jujutsu

[commitlint]
enabled = false  # Enable commitlint validation and auto-fixing

Environment Variables

You can also use environment variables as fallback:

export FAST_COMMIT_API_KEY="your-openai-api-key"
export FAST_COMMIT_MODEL="gpt-4"
export FAST_COMMIT_BASE_URL=""
export FAST_COMMIT_EXTRA_PROMPT="Write conventional commit messages"
export FAST_COMMIT_USE_GITMOJI="true"
export FAST_COMMIT_USE_FULL_GITMOJI="true"
export FAST_COMMIT_VCS="git"  # or "jj"
export FAST_COMMIT_COMMITLINT_ENABLED="false"

Configuration Priority

  1. TOML configuration file
  2. Environment variables
  3. Default values (model: gpt-4, extra_prompt: empty, vcs: auto-detect)

Usage

Basic Usage

  1. Stage your changes (Git):
git add .

Or for Jujutsu (jj) there is no need to stage - jj tracks working copy changes automatically

  1. Run fast-commit:
fast-commit
  1. Review the generated commit message and choose:
    • y or yes: Commit with the generated message
    • n or no: Cancel the commit
    • r or regenerate: Generate a new commit message

CLI Flags

Flag Description
-y, --yes Skip confirmation prompt and commit immediately
-c, --context <string> Provide additional context to the AI about why changes were made
-p, --push Automatically push to remote after commit (Git: pushes current branch, jj: pushes most recent bookmark to @-)

Example Workflows

Git Workflow

# Make some changes
echo "console.log('Hello World')" > hello.js

# Stage changes
git add hello.js

# Generate commit message with context
./fast-commit -c "Added basic logging for debugging purposes"

# Output:
# Generated commit message:
# ✨ feat: add hello world console log for debugging
#
# Do you want to commit with this message? [y/n/r]: y
# Changes committed successfully!

# (OR) Skip confirmation prompt
./fast-commit -y

Jujutsu (jj) Workflow

# Make some changes
echo "console.log('Hello World')" > hello.js

# Generate commit message (no staging needed)
./fast-commit -c "Added basic logging for debugging purposes"

# Output:
# Generated commit message:
# ✨ feat: add hello world console log for debugging
#
# Do you want to commit with this message? [y/n/r]: y
# Changes committed successfully!

# (OR) Skip confirmation prompt
./fast-commit -y

# (OR) Auto-push with fast bookmark detection
./fast-commit -p
# Automatically pushes the most recent bookmark from parent commits to @-

Commitlint Integration

Fast-commit includes built-in support for commitlint and commitlint-rs validation. When enabled, it automatically validates generated commit messages and uses AI to fix any violations.

How It Works

When commitlint integration is enabled:

  1. Validation: Each generated commit message is validated against your commitlint rules
  2. Auto-fixing: If validation fails, the AI automatically generates a corrected message
  3. Retry Logic: Up to 3 attempts are made to create a compliant message
  4. Transparency: All validation attempts and errors are shown to the user
  5. Gitmoji Handling: Emojis are automatically stripped before validation to avoid conflicts

User Interface

The interface shows detailed information about the validation process:

  • Retry attempts: Orange-colored indicators showing each validation attempt
  • Validation errors: Red-colored error messages from commitlint
  • Final result: Green confirmation when a valid message is generated

Example output:

Generated commit message:
✨ feat: add user authentication system

Validation attempt 1: ❌ Failed
Error: subject may not be longer than 50 characters

Validation attempt 2: ✅ Passed
✨ feat: add user auth system

Do you want to commit with this message? [y/n/r]: 

API Reference

Configuration

The configuration is loaded from ~/.config/fast-commit.toml with the following structure:

Field Type Required Description
api_key string Yes OpenAI API key
base_url string No OpenAI compatible api url
model string No OpenAI model to use (default: gpt-4)
extra_prompt string No Additional prompt instructions
vcs string No VCS to use: "git", "jj", or empty for auto-detect (default: auto-detect)
use_gitmoji bool No Enable gitmoji in commit messages (default: false)
use_full_gitmoji bool No Use full gitmoji set instead of common set (default: false)
commitlint.enabled bool No Enable commitlint validation and auto-fixing (default: false)

Environment Variables

Variable Description
FAST_COMMIT_API_KEY OpenAI API key
FAST_COMMIT_BASE_URL OpenAI compatible api url
FAST_COMMIT_MODEL OpenAI model to use
FAST_COMMIT_EXTRA_PROMPT Additional prompt instructions
FAST_COMMIT_VCS VCS to use: "git", "jj", or empty for auto-detect
FAST_COMMIT_USE_GITMOJI Enable gitmoji in commit messages
FAST_COMMIT_USE_FULL_GITMOJI Use full gitmoji set instead of common set
FAST_COMMIT_COMMITLINT_ENABLED Enable commitlint validation and auto-fixing

Development

Project Structure

fast-commit/
├── main.go                 # Entry point and CLI logic
├── config/                 # Configuration handling
│   └── config.go
├── vcs/                    # VCS abstraction layer
│   ├── interface.go        # VCS interface
│   ├── git/                # Git implementation
│   │   └── git.go
│   └── jj/                 # Jujutsu (jj) implementation
│       └── jj.go
├── openai/                 # OpenAI API integration
│   └── client.go
├── prompt/                 # User interaction
│   └── prompt.go
├── gitmoji/                # Gitmoji support
│   ├── gitmoji.go
│   ├── gitmojis.json
│   └── gitmojis_common.json
├── commitlint/             # Commitlint integration
│   └── commitlint.go
├── ui/                     # User interface
│   └── ui.go
└── README.md              # This file

Building

# Build for current platform
go build -o fast-commit

# Build for multiple platforms
GOOS=linux GOARCH=amd64 go build -o fast-commit-linux-amd64
GOOS=darwin GOARCH=amd64 go build -o fast-commit-darwin-amd64
GOOS=windows GOARCH=amd64 go build -o fast-commit-windows-amd64.exe

Testing

go test ./...

Contributing

  1. Fork the repository
  2. Create a feature/fix/refactor branch (git checkout -b [feat|fix|refactor]/new-feature)
  3. Make your changes
  4. Add tests for new functionality
  5. Ensure all tests pass (go test ./...)
  6. Commit your changes
  7. Push to the branch
  8. Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.