CommitWhisper
CommitWhisper is an AI-powered extension that automates your commit messages. Generate clear, concise, and informative commit messages based on your staged changes using Google's Gemini AI.
Features
- Automated Commit Messages: Generates commit messages based on the git diff.
- Incremental Generation: Supports large diffs by breaking them into chunks and combining responses.
- Ticket Extraction: Optionally extracts a ticket number from your branch name and inserts it into a customizable commit title template.
- Configurable: Modify settings such as your Gemini API key, ticket regex, and commit title template directly in VS Code.
- Skip Pre-commit Hooks: New option to bypass pre-commit hooks (e.g., Husky, lint) during commit. By default, this option is disabled.
- Commit Error Handling: If a commit fails (when pre-commit hooks are not skipped), an error is displayed with the generated commit message and an option to copy it to your clipboard.
- Smart File Filtering: Automatically ignores lock files, binary files, and other irrelevant files to improve performance and commit message quality. You can customize which files to ignore using regex patterns.
Installation
- Open VS Code.
- Go to the Extensions view by clicking on the Extensions icon or pressing
Ctrl+Shift+X
(Cmd+Shift+X
on macOS).
- Search for CommitWhisper.
- Click Install.
Setup
Before using CommitWhisper, you must generate a Gemini API key. If you don’t have one, generate it at:
https://aistudio.google.com/apikey
Then, add the API key and other settings to your VS Code settings. For example:
{
"commitwhisper.apiKey": "YOUR_GEMINI_API_KEY",
"commitwhisper.extractTicketFromBranch": true,
"commitwhisper.ticketRegex": "([A-Z]+-\\d+)",
"commitwhisper.titleTemplate": "[${ticket}] ${summary}",
"commitwhisper.skipPreCommitHooks": false,
"commitwhisper.ignoreFiles": [
".*\\.test\\..*",
".*\\.spec\\..*",
"docs/.*\\.md",
"migrations/.*"
]
}
Usage
- Stage Your Changes:
Ensure you have staged changes using git add
before generating a commit message.
- Generate Commit Message:
Open the Command Palette (Ctrl+Shift+P
or Cmd+Shift+P
on macOS) and run Generate Commit Message using AI.
- Review & Commit:
- The extension will generate a commit message.
- If pre-commit hooks are enabled (default) and the commit fails, an error modal will appear displaying the error and your generated commit message.
- You will have the option to copy the commit message to your clipboard if needed.
- Configure Behavior:
Use the commitwhisper.skipPreCommitHooks
setting to control whether pre-commit hooks should be skipped.
Configuration Options
commitwhisper.apiKey
: Your Gemini API key (required)
commitwhisper.extractTicketFromBranch
: Whether to extract ticket numbers from branch names (default: true
)
commitwhisper.ticketRegex
: Regex pattern to extract ticket numbers (default: ([A-Z]+-\\d+)
)
commitwhisper.titleTemplate
: Template for commit titles with ${ticket}
and ${summary}
variables (default: [${ticket}] ${summary}
)
commitwhisper.skipPreCommitHooks
: Whether to skip pre-commit hooks during commit (default: false
)
commitwhisper.ignoreFiles
: Array of regex patterns for files to ignore when generating commit messages (default: []
)
Troubleshooting
- No workspace open? Make sure you open a project/folder in VS Code.
- Large diffs: If the diff size exceeds the maximum chunk size, CommitWhisper will generate the message incrementally.
- Invalid API Key: Verify your API key in the configuration if falsy responses are encountered.
- Slow performance with lock files: The extension automatically ignores lock files and other irrelevant files. If you need to customize this behavior, see the
commitwhisper.ignoreFiles
setting.
License
MIT License
Contributing
Sooon...
Happy committing with CommitWhisper!