Diff Commit is a VSCode extension that helps you generate commit messages following the conventional commits specification using Anthropic's AI models like Claude 3.5 Sonnet. Commit messages are generated using the diff of staged changes and entered directly into the SCM message input or previewed in a new editor window.
The generated commit messages are compatible with googleapis/release-please and other tools that use conventional commits.
- Diff Commit
- Generate commit messages based on the diff of staged changes using Anthropic's AI models like Claude 3.5 Sonnet
- Preview and edit generated commit messages before applying the commit
- Uses markdown formatting for commit messages
- Implements conventional commit format with type, scope, subject, and body
- VSCode 1.9.4 or higher
- Git installed and configured in your workspace
- An Anthropic API key
Install the extension directly from the Visual Studio Code Marketplace or:
- Open VSCode
- Press Cmd/Ctrl + P
- Type
ext install tpsTech.diff-commit
- Stage the changes that you wish to commit as normal
- Run the command: "DiffCommit: Generate Commit Message" (Cmd/Ctrl + K → Cmd/Ctrl + G)
- Confirm or edit the generated commit message in the Source Control message input
- Click 'Commit' to commit the changes with the generated message
DiffCommit commands can be accessed from the Command Palette (Cmd/Ctrl + Shift + P) or using the default keyboard shortcuts.
This will generate a commit message for staged changes and enter it in the Source Control message input box. You can preview and edit the generated message before committing.
| Platform | Keyboard Shortcut |
|---|---|
| macOS | Cmd + K → Cmd + G |
| Linux | Ctrl + K → Ctrl + G |
| Windows | Ctrl + K → Ctrl + G |
This will generate a commit message for staged changes and open it in a new editor window. You can preview and edit the generated message before committing.
| Platform | Keyboard Shortcut |
|---|---|
| macOS | Cmd + K → Cmd + P |
| Linux | Ctrl + K → Ctrl + P |
| Windows | Ctrl + K → Ctrl + P |
This will update the Anthropic API key used for API access.
- Enter your API key when prompted
- Press Enter to confirm or Esc to cancel
This will delete the stored API key from your system and prevent DiffCommit from accessing the API in the future.
DiffCommit provides the following settings to customise its behavior.
A list of allowed commit types. If provided, this replaces the default options.
| Type | Description | Default Value |
|---|---|---|
| Array<string> | A list (array) of any string/s you want available as commit types | [ "feat", "fix", "refactor", "chore", "docs", "style", "test", "perf", "ci" ] |
Add additional custom instructions to the commit generation prompt. Useful for providing context or specific requirements like 'Use Australian English spelling'.
| Type | Description | Default Value |
|---|---|---|
| string | Free formatted string that you want included as custom instructions for the AI prompt | "" |
The Anthropic AI model to use for generating commit messages.
| Type | Options | Default Value |
|---|---|---|
| enum | "claude-3-opus-latest" | "claude-3-5-sonnet-latest" | "claude-3-haiku-20240307" | "claude-3-5-sonnet-latest" |
Maximum number of tokens to generate in the response. Higher values allow for longer commit messages but use more API tokens.
| Type | Minimum | Maximum | Default Value |
|---|---|---|---|
| number | 1 | 8192 | 1024 |
Controls randomness in the response. Lower values (like 0.3) produce more focused and consistent commit messages, while higher values introduce more variety.
For concise, focused commit messages, I recommend the default value of 0.3. If you want a little more creativity or room for the AI model to interpret the reason for changes, try a larger value.
| Type | Minimum | Maximum | Default Value |
|---|---|---|---|
| number | 0 | 1 | 0.3 |
Diff Commit accommodates error handling to provide clear feedback and assist in troubleshooting. The following are the common warning or error scenarios you might encounter.
| Error | Status Code | |
|---|---|---|
| Git Related | Git extension not found in VSCode | |
| No Git repository found in the current workspace | ||
| No workspace folder found | ||
| No staged changes detected | ||
| API Key Related | API key is missing or not provided | |
| Invalid API key format (should start with sk-ant-api) | ||
| Failed to access or update secure storage | ||
| Anthropic API Errors | Bad Request: Review your prompt and try again | 400 |
| Unauthorized: Invalid API key, update your API key and try again | 401 | |
| Forbidden: Permission denied, update your API key and try again | 403 | |
| Rate Limited: Too many requests, try again later | 429 | |
| Server Error: Anthropic API server error | 500 | |
| Other Errors | Failed to write commit message to Source Control | |
| Failed to open commit message preview | ||
| No commit message was generated by the API |
If you encounter any of these errors, Diff Commit will display a message with more details. For persistent issues, please check your configuration and if appropriate, raise an issue on GitHub.
- Clone the repository
- Install dependencies:
pnpm install - Build the extension:
pnpm compile - Run the tests:
pnpm test
- Press F5 (Cmd/Ctrl + Shift + P and select
Debug: Start Debugging) to start the debugger - This will open a new VSCode window with the extension loaded
- Make changes to files and use the source control panel to test the extension
Feature requests, suggestions and contributions to Diff Commit are welcome! Please feel free to submit an idea or Pull Request.
This project is licensed under the MIT License.




