auto-commit-msg
v1.0.1
Published
Generate automatic commit messages using artificial intelligence (OpenAI or Gemini), right from the terminal.
Maintainers
Readme
🧠 auto-commit-msg
Generate automatic commit messages using artificial intelligence (OpenAI or Gemini), right from the terminal. Ideal for developers who want speed without losing context and clarity in their commits.
✨ Features
- 🤖 Support for OpenAI (gpt-4o) and Google Gemini (gemini-2.0-flash)
- 🌍 Language: pt or en
- 🧑🎨 Style: default or gitmoji (with emojis following the Gitmoji standard)
- 🧪 Message preview before committing
- ✅ Interactive confirmation via CLI
- 📦 Ready to run with npx
🚀 Installation
- Install the package as devDependencies using npm or yarn:
npm install --save-dev auto-commit-msgor
yarn add --save-dev auto-commit-msg- Create a
.envfile in the root of your project and add the following environment variables:
COMMIT_LANG=en or pt
COMMIT_STYLE=default or gitmoji
COMMIT_MODEL=openai or gemini
OPENAI_API_KEY=your_openai_api_key
or
GEMINI_API_KEY=your_gemini_api_keyReplace your_openai_api_key or your_gemini_api_key with your actual API keys.
Usage
To use the auto-commit-msg tool, run the following command in your terminal:
npx auto-commit-msg --stage or npx auto-commit-msgThis will:
- Stage the changes with
git add .if you use--stage. - The package detects changes using
git diff --cached - Generate a descriptive commit message using the configured language, style, and AI model.
- Displays the message in the terminal
- You confirm whether to apply it.
- If confirmed, it will create the commit with the generated message.
You can also customize the behavior by passing command-line arguments:
npx auto-commit-msg --lang en --style gitmoji --model openai
npx auto-commit-msg --lang en
npx auto-commit-msg --style gitmoji
npx auto-commit-msg --model gemini⚠️ Warning: A deprecation warning related to the `punycode` module may appear during execution.
This originates from an indirect dependency (`tsup` → `source-map` → `whatwg-url` → `tr46` → `punycode`)
and does `not affect the CLI's functionality`.
In the meantime, feel free to ignore it safely.🏁 CLI Flags
| Flag | Description | Example |
| :-------- | :---------------------------------- | :---------------- |
| --stage | Adds files with git add . | --stage |
| --lang | Message language (pt, en) | --lang en |
| --style | Commit Style (default, gitmoji) | --style gitmoji |
| --model | AI Model (openai, gemini) | --model gemini |
Contributing
Contributions are welcome! If you find any issues or have suggestions for improvements, please feel free to open a new issue or submit a pull request.
