commit-ai is a CLI tool that automatically generates Git commit messages using AI, leveraging Claude 3.5 to provide high-quality, standardized commit messages.
- AI-powered commit message generation using Anthropic's Claude 3.5
- Multi-language support (English, Korean, Japanese, Simplified Chinese, Traditional Chinese)
- Standardized commit message format following conventional commits
- Multiple commit message suggestions with detailed explanations
- Interactive commit message editing with your system's default editor
- Customizable message generation options
- Easy-to-use CLI interface
- Interactive commit message selection using arrow keys
- Visual progress indication for commit message generation and commit process
- Intelligent file filtering to exclude large files and specific file types (e.g., lock files, SVG, source maps)
You can install it globally using npm:
npm install -g @j-ho/commit-ai
You can set your Anthropic API key and preferred language either separately or together:
# Set both API key and language at once
commit-ai --key YOUR_API_KEY --language ko
# Or set them separately
commit-ai --key YOUR_API_KEY
commit-ai --language ja
# Check your current configuration
commit-ai --show-config
# Output example:
Current Configuration:
--------------------
Default Language: ko
API Key: Set
Supported Languages:
-------------------
en
ko (current)
ja
zh-CN
zh-TW
To generate a commit message using your stored settings, simply run:
commit-ai
You can override the stored language for a single commit:
commit-ai -l ko # Use Korean for this commit only
Supported languages:
- en: English (default)
- ko: Korean
- ja: Japanese
- zh-CN: Simplified Chinese
- zh-TW: Traditional Chinese
-
-k, --key <key>
: Set Anthropic API key -
-n, --number <number>
: Number of commit message suggestions to generate (default: 3) -
-l, --language <code>
: Set default language for commit messages -
--show-config
: Show current configuration
- Select a commit message using arrow keys
- Choose to edit the selected message (optional)
- Edit title and/or body in your system's default text editor
- Review and confirm your changes
- Commit with the final message
# Example workflow:
> Select a commit message to use
1. feat: Add user authentication
2. feat: Implement login functionality
3. feat: Create authentication system
✏️ Edit commit message
🌟 Cancel
# If you choose to edit:
> Would you like to edit the commit title? (y/N)
# Your default editor opens with the current title
> Would you like to edit the commit body? (y/N)
# Your default editor opens with the current body
# Review your changes before confirming
commit-ai follows a standardized commit message format:
-
Subject Line:
- Starts with a type (feat, fix, docs, style, refactor, perf, test, build, ci, chore, revert)
- Uses imperative mood
- Limited to 50 characters
- Capitalized first word
- No period at the end
-
Body Message:
- Provides context and reasoning for the change
- Limited to 72 characters per line
- Explains the impact and motivation
- Uses bullet points for multiple items
feat: Implement user authentication
Added user authentication to enhance app security:
- Integrated login and signup functionality
- Implemented JWT for session management
- Updated the database schema to store hashed passwords
- Added password recovery via email
- Analyzes staged changes in the current Git repository
- Filters out large files (configurable, default 100KB) and specific file types (package-lock.json, yarn.lock, pnpm-lock.yaml, .svg, .map)
- Uses Claude 3.5 to generate multiple commit message candidates based on the diff
- Provides interactive selection of the generated messages
- Commits the changes with the selected message
- Clone the repository
- Install dependencies:
pnpm install
- Build the project:
pnpm build
- Run tests:
pnpm test
- @anthropic-ai/sdk: For interacting with the Anthropic AI API
- @inquirer/prompts: For interactive command-line user interfaces
- commander: For building the command-line interface
- configstore: For storing configuration data
- ora: For elegant terminal spinners
This project is licensed under the MIT License.
We welcome all forms of contributions, including bug reports, feature suggestions, and pull requests. For major changes, please open an issue first to discuss what you would like to change.
If you encounter any issues with file paths or commit template detection, please ensure that:
- Your Git commit template path is correctly set in your Git config
- The commit template file exists and is readable
- You're using the correct format option (
-f template
) when you want to use a Git commit template
For any other issues or questions, please open an issue on the GitHub repository.