Tired of writing git commit messages? Let AI do it for you! ✨
commiat is a simple CLI tool that:
- Optionally stages all changes (
git add .) if you use the-aor--add-allflag. - Analyzes your staged git changes (
git diff --staged). - Generates a commit message using an AI model via OpenRouter (defaults to Google Gemini 2.5 Flash Lite ⚡) or a local Ollama instance (defaults to qwen2.5).
- Supports custom commit message formats defined in a local
.commiatfile. - Allows prefixing and suffixing commit messages with custom strings using
--prefixand--affixoptions. - Prompts you to confirm ✅, adjust 📝, or cancel ❌ the commit.
- Optionally bypasses git commit hooks using the
-nor--no-verifyflag.
npm install -g commiat- Clone the repository:
git clone https://github.com/javimosch/commiat.git cd commiat - Install dependencies:
npm install
- Link the CLI:
This makes the
commiatcommand available globally.npm link
commiat uses two types of configuration:
This file stores settings that apply across all your projects, primarily your LLM provider choice, API keys, and default models. It uses the standard .env format (KEY=VALUE).
- Location:
~/.commiat/config(created automatically if needed) - Managed via:
commiat config(for OpenRouter),commiat config -m(for multi-commit default), andcommiat ollama(for Ollama) commands. - Key Settings:
- OpenRouter:
COMMIAT_OPENROUTER_API_KEY: Your OpenRouter API key (required if using OpenRouter). If not found here or in environment variables, you'll be prompted.COMMIAT_OPENROUTER_MODEL: The default OpenRouter model ID (e.g.,google/gemini-2.5-flash-lite,anthropic/claude-3-haiku). Defaults togoogle/gemini-2.5-flash-lite.
- Ollama: (Managed via
commiat ollama)COMMIAT_USE_OLLAMA: Set totrueto use Ollama instead of OpenRouter. Defaults tofalse.COMMIAT_OLLAMA_BASE_URL: The base URL for your running Ollama instance. Defaults tohttp://localhost:11434.COMMIAT_OLLAMA_MODEL: The Ollama model to use. Defaults tollama3.COMMIAT_OLLAMA_FALLBACK_TO_OPENROUTER: Set totrueto automatically fall back to OpenRouter if the Ollama request fails (requires OpenRouter API key to be configured). Defaults tofalse.
- Multi-Commit Mode: (Managed via
commiat config -m)COMMIAT_DEFAULT_MULTI: Set totrueto enable multi-commit mode by default. Defaults tofalse.
- OpenRouter:
This optional file, placed in your project's root directory, allows you to define a custom commit message format for that specific project.
- Location:
.commiatin your project root. - Format: JSON
- Structure Example:
{ "format": "{type}({scope}): {msg} [Ticket: {gitBranchNumber}]", "variables": { "scope": "Description of what 'scope' means in this project (e.g., component, module, feature name)" } } format(string, required): The template for your commit messages.- Use
{variableName}for placeholders. {msg}is special: The main commit message generated by the AI will replace this.- System Variables: These are automatically handled by
commiat:{gitBranch}: The full current Git branch name (e.g.,feature/DATA-123-button).{gitBranchNumber}: The first sequence of digits found in the branch name (e.g.,123fromfeature/DATA-123-button). Returns empty string if no number is found.{type}: The conventional commit type (e.g.,feat,fix,chore) determined by the AI based on the diff. The AI is instructed to generate this.
- Custom Variables: Any other
{variableName}(like{scope}above) is a custom variable.
- Use
variables(object, required): Contains descriptions for your custom variables.- The keys are the custom variable names (e.g.,
"scope"). - The values are strings describing what information should go into that variable. These descriptions are sent to the AI to help it fill the template correctly.
- If you add a new custom variable to your
formatstring,commiatwill prompt you to provide its description the next time you run it, and it will save the description back to your.commiatfile.
- The keys are the custom variable names (e.g.,
Settings are looked for in this order:
- Environment Variables / Local
.envFile:COMMIAT_OPENROUTER_API_KEY,COMMIAT_OPENROUTER_MODEL,COMMIAT_USE_OLLAMA,COMMIAT_OLLAMA_BASE_URL,COMMIAT_OLLAMA_MODEL,COMMIAT_OLLAMA_FALLBACK_TO_OPENROUTER,COMMIAT_DEFAULT_MULTIset in your shell or a project-local.envfile override everything else. - Project
.commiatFile: If present, theformatandvariablesdefined here are used for commit message generation. - Global
~/.commiat/configFile: Used for LLM provider settings if not set by environment variables. - Prompts / Defaults:
- If using OpenRouter and
COMMIAT_OPENROUTER_API_KEYis not found, you'll be prompted, and it will be saved globally. - If LLM provider settings are not found, defaults are used (OpenRouter with Gemini 2.5 Flash Lite, or Ollama with llama3 if enabled).
- If
.commiatis not found, a standard conventional commit format ({type}: {msg}) is used. If.commiatis missing custom variable descriptions, you'll be prompted.
- If using OpenRouter and
- (Optional) Configure your LLM provider:
- For OpenRouter (default): Run
commiatonce. It will prompt for your API key if needed and save it globally. You can edit the model later withcommiat config. - For Ollama: Run
commiat ollamato enable it, set the URL/model, and optionally enable fallback to OpenRouter.
- For OpenRouter (default): Run
- (Optional) Create a
.commiatfile in your project root if you want a custom format (see example above). - Stage your changes:
git add <your-files...> # OR stage all changes: git add .
- Run commiat:
# Generate commit message commiat # Stage all changes AND generate commit message commiat -a # or commiat --add-all # Generate commit message and bypass commit hooks commiat -n # or commiat --no-verify # Add a prefix to the commit message commiat --prefix "[WIP]" # Add a suffix/affix to the commit message commiat --affix "(#12345)" # Combine multiple options commiat -a --prefix "[HOTFIX]" --affix "(#URGENT-456)" # Enable multi-commit mode commiat --multi --untracked -n
- Follow the prompts:
- If it's the first time using a custom variable in
.commiat, you'll be asked for its description. - Confirm, adjust, or cancel the suggested commit message.
- If it's the first time using a custom variable in
Example Workflow with Custom Format:
- Create
.commiat:{ "format": "feat({component}): {msg} [JIRA-{gitBranchNumber}]", "variables": { "component": "The UI component or backend module affected" } } - Assume current branch is
feature/JIRA-456-new-login. - Make changes, stage them (
git add .). - Run
commiat. - AI generates a message like:
feat(Auth): implement new login flow [JIRA-456] - Confirm or adjust.
The --multi flag enables an interactive multi-commit workflow, allowing you to group changes logically and commit them individually. This is particularly useful for large feature branches or refactors where multiple distinct changes are made.
Example Output:
commiat --multi --untracked -n
Commiat CLI - Generating commit message...
Loaded format from .commiat
? No changes staged. Stage all changes now? (git add .) Yes
Staging all changes (`git add .`)...
Changes staged.
Multi-commit mode enabled...
Using provider: openrouter, Model: google/gemini-2.5-flash-lite
Sending request to OpenRouter: https://openrouter.ai/api/v1/chat/completions
Successfully parsed group results.
Using provider: openrouter, Model: google/gemini-2.5-flash-lite
Sending request to OpenRouter: https://openrouter.ai/api/v1/chat/completions
? Suggested Commit Message:
"chore: Update Node.js version in Dockerfile to 20.17.0-alpine"
What would you like to do? ✅ Confirm and Commit
Committing with --no-verify flag...
✅ Group commit successful!
Using provider: openrouter, Model: google/gemini-2.5-flash-lite
Sending request to OpenRouter: https://openrouter.ai/api/v1/chat/completions
? Suggested Commit Message:
"feat: Add Dockerfile for application"
What would you like to do? ✅ Confirm and Commit
Committing with --no-verify flag...
✅ Group commit successful!
Processing group 3: Update automation API endpoint logging
Files: automation-api.js
Description: Enhances the `/health` endpoint response in the automation API to log the available API endpoints for better discoverability.
Using provider: openrouter, Model: google/gemini-2.5-flash-lite
Sending request to OpenRouter: https://openrouter.ai/api/v1/chat/completions
? Suggested Commit Message:
"feat: Add endpoint listing to automation API startup message"
What would you like to do? ✅ Confirm and Commit
Committing with --no-verify flag...
✅ Group commit successful!
Processing group 4: Refactor docker-compose for separate app Dockerfile
Files: docker-compose.yml
Description: Modifies the docker-compose file to use the new `Dockerfile.app` for the 'app' service and removes the explicit `command` which was likely redundant.
Staged for this group: docker-compose.yml
Loaded format from .commiat
Detected current branch: master
Detected current branch: master
No number found in branch name: master
Using provider: openrouter, Model: google/gemini-2.5-flash-lite
Sending request to OpenRouter: https://openrouter.ai/api/v1/chat/completions
? Suggested Commit Message:
"feat: Add cleanup for Xvfb lock file"
What would you like to do? ✅ Confirm and Commit
Committing with --no-verify flag...
✅ Group commit successful!
Processing group 6: Update server startup logging for admin and public APIs
Files: server.js
Description: Expands the startup log messages for the admin server to include a comprehensive list of all admin API endpoints, along with a dedicated section for public API endpoints.
Staged for this group: server.js
Loaded format from .commiat
Detected current branch: master
Detected current branch: master
No number found in branch name: master
Using provider: openrouter, Model: google/gemini-2.5-flash-lite
Sending request to OpenRouter: https://openrouter.ai/api/v1/chat/completions
? Suggested Commit Message:
"feat: Enhance server startup logs with detailed API endpoints"
What would you like to do? ✅ Confirm and Commit
Committing with --no-verify flag...
✅ Group commit successful!
🎉 Multi-commit process completed successfully.
➜ substack-schedule git:(master)
Commiat provides two convenient options to modify the AI-generated commit message:
Prepends a string to the beginning of the generated commit message (first line only).
Common use cases:
# Mark work-in-progress commits (space added automatically)
commiat --prefix "[WIP]"
# Indicate hotfixes
commiat --prefix "[HOTFIX]"
# Add urgency markers
commiat --prefix "🚨"
# Specify environment
commiat --prefix "[PROD]"Note: A space is automatically added between the prefix and commit title if not already present.
Appends a string to the end of the generated commit message (first line only).
Common use cases:
# Add ticket numbers
commiat --affix "(#12345)"
# Reference JIRA tickets
commiat --affix "[JIRA-456]"
# Add GitHub issue references
commiat --affix " (closes #789)"
# Add reviewer mentions
commiat --affix " cc: @teamlead"You can use both --prefix and --affix together:
# Result: "[HOTFIX] fix authentication bug (#URGENT-123)"
commiat --prefix "[HOTFIX]" --affix "(#URGENT-123)"
# Result: "🚨 feat: add new login system [JIRA-456]"
commiat --prefix "🚨" --affix "[JIRA-456]"- AI generates the base commit message (potentially multi-line)
- Prefix is added to the beginning of the first line (if provided)
- Affix is added to the end of the first line (if provided)
- Final message is presented for confirmation/editing
Example:
- AI generates:
fix: resolve login timeout issue Updated authentication logic to handle edge cases - Command:
commiat --prefix "[HOTFIX] " --affix " (#12345)" - Result:
[HOTFIX] fix: resolve login timeout issue (#12345) Updated authentication logic to handle edge cases
Note: Only the first line (commit subject) is modified. The commit body remains unchanged.
- Edit Global Configuration (Mainly OpenRouter):
Opens
~/.commiat/configin your editor. Use this primarily for the OpenRouter API key and model if not using environment variables.commiat config
- Configure Ollama:
Interactively enable/disable Ollama, set its URL and model, and configure fallback to OpenRouter.
commiat ollama
- Test LLM Configuration:
Checks connection and basic generation using your currently configured provider (OpenRouter OR Ollama w/ fallback).
commiat config --test
- Set
--multias Default Mode: Interactively enables or disables multi-commit mode as the default behavior for allcommiatcommands. Once enabled, you don't need to pass--multito use multi-commit mode; you can disable it per-run with--no-multiif needed.commiat config -m # or commiat config --multi
Happy committing! 🎉