Skip to content
| Marketplace
Sign in
Visual Studio Code>SCM Providers>Smart AI CommitNew to Visual Studio Code? Get it now.
Smart AI Commit

Smart AI Commit

LanceMao

|
2 installs
| (0) | Free
Intelligent commit message generator with multi-language support powered by Claude and OpenAI
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

AI Commit Message Generator

Automatically generate conventional commit messages using AI (Claude or OpenAI) by analyzing your staged git changes.

English | 简体中文

Features

  • Automatically analyzes git staged changes (diff)
  • Generates commit messages following Conventional Commits specification
  • Supports multiple AI providers: Claude and OpenAI
  • Supports official API and proxy API
  • 🌍 Multi-language support: Generate commit messages in Chinese, English, Japanese, Korean, and more
  • Direct integration with VS Code's Source Control panel
  • Configurable models and parameters

Installation

From Source

  1. Clone this repository
  2. Run npm install to install dependencies
  3. Run npm run compile to compile TypeScript
  4. Press F5 to open a new VS Code window with the extension loaded

From VSIX (Future)

Download the .vsix file from releases and install via:

code --install-extension ai-commit-message-generator-0.1.0.vsix

Configuration

Before using the extension, you need to configure your AI provider and API key:

  1. Open VS Code Settings (Ctrl+,)
  2. Search for "aiCommit"
  3. Configure the following settings:

支持中转/代理 API

插件完全支持中转 API 服务!如果你使用的是中转服务而非官方 API:

  • Claude 中转:设置 aiCommit.claudeBaseUrl 为你的中转服务地址(如 https://your-proxy.com/v1)
  • OpenAI 中转:设置 aiCommit.openaiBaseUrl 为你的中转服务地址(如 https://your-proxy.com/v1)

留空则使用官方 API 地址。

Required Settings

  • AI Provider: Choose between claude or openai
  • API Key: Set the API key for your chosen provider
    • For Claude: Get your API key from Anthropic Console
    • For OpenAI: Get your API key from OpenAI Platform

Optional Settings

  • Claude Model: Manually enter the Claude model name to use (default: claude-3-5-sonnet-20241022)
    • Supports any model: claude-3-5-sonnet-20241022, claude-3-opus-20240229, claude-3-haiku-20240307, etc.
    • Can enter any new or custom model name
  • Claude Base URL: Custom Claude API base URL (for proxy services)
  • OpenAI Model: Manually enter the OpenAI model name to use (default: gpt-4-turbo-preview)
    • Supports any model: gpt-4-turbo-preview, gpt-4, gpt-4o, gpt-3.5-turbo, etc.
    • Can enter any new or custom model name
  • OpenAI Base URL: Custom OpenAI API base URL (for proxy services)
  • Max Diff Size: Maximum diff size in characters (default: 50000)
  • Enable Logging: Enable debug logging to output channel (default: false)
  • Language: Choose the language for generated commit messages (default: English)
    • Available: English, 中文 (Chinese), 日本語 (Japanese), 한국어 (Korean), Français (French), Deutsch (German), Español (Spanish)
    • Select "Custom" to enter any language name
  • Custom Language: Manually enter language name when Language is set to "Custom" (e.g., Русский, Português, etc.)
  • Detailed Message: Generate detailed commit message with body listing all changes (default: enabled)
    • Enabled: Generates a complete commit with title and detailed body, grouped by functional changes, describing what each feature does and which files are involved
    • Disabled: Only generates a brief title line

Example Configuration

使用官方 API:

{
  "aiCommit.provider": "claude",
  "aiCommit.claudeApiKey": "your-claude-api-key-here",
  "aiCommit.claudeModel": "claude-3-5-sonnet-20241022",
  "aiCommit.maxDiffSize": 50000
}

使用中转/代理 API:

{
  "aiCommit.provider": "claude",
  "aiCommit.claudeApiKey": "your-proxy-api-key",
  "aiCommit.claudeBaseUrl": "https://your-proxy-domain.com/v1",
  "aiCommit.claudeModel": "claude-3-5-sonnet-20241022",
  "aiCommit.maxDiffSize": 50000
}

或 OpenAI 中转:

{
  "aiCommit.provider": "openai",
  "aiCommit.openaiApiKey": "your-proxy-api-key",
  "aiCommit.openaiBaseUrl": "https://your-proxy-domain.com/v1",
  "aiCommit.openaiModel": "gpt-4-turbo-preview"
}

Using custom models (e.g., latest GPT-4o):

{
  "aiCommit.provider": "openai",
  "aiCommit.openaiApiKey": "your-api-key",
  "aiCommit.openaiModel": "gpt-4o"
}

Or using latest Claude model:

{
  "aiCommit.provider": "claude",
  "aiCommit.claudeApiKey": "your-api-key",
  "aiCommit.claudeModel": "claude-3-5-sonnet-20241022"
}

Generate commit messages in Chinese:

{
  "aiCommit.provider": "claude",
  "aiCommit.claudeApiKey": "your-api-key",
  "aiCommit.language": "中文"
}

Use custom language (e.g., Russian):

{
  "aiCommit.provider": "openai",
  "aiCommit.openaiApiKey": "your-api-key",
  "aiCommit.language": "Custom",
  "aiCommit.customLanguage": "Русский"
}

Usage

  1. Make changes to your code
  2. Stage files using git add or VS Code's Source Control panel
  3. Click the sparkle icon (✨) in the Source Control panel toolbar, or
  4. Open Command Palette (Ctrl+Shift+P) and run "AI: Generate Commit Message"
  5. Wait for AI to analyze your changes
  6. Review and edit the generated commit message if needed
  7. Commit your changes

How It Works

  1. The extension reads your staged changes using git diff --cached
  2. Sends the diff along with file statistics to the AI provider
  3. AI analyzes the changes and generates a commit message following Conventional Commits format
  4. The generated message is automatically filled into the Source Control commit input box

Conventional Commits Format

The extension generates commit messages in this format:

Brief Mode

<type>(<scope>): <description>

Detailed Mode (Default)

<type>(<scope>): <brief summary>

<blank line>
- High-level description of feature/capability 1
- High-level description of feature/capability 2
- High-level description of feature/capability 3

Important guidelines:

  • ✅ Describe what CAPABILITY/FEATURE was added from USER/DEVELOPER perspective
  • ✅ Each bullet = ONE complete feature/capability
  • ✅ Focus on WHAT was done, not which files changed
  • ❌ DO NOT list file names as bullet points
  • ❌ DO NOT include implementation details
  • Target: 3-5 major feature points

Example Comparison

Brief mode (aiCommit.detailedMessage: false):

feat(auth): add user login functionality

Detailed mode (aiCommit.detailedMessage: true, default):

feat(auth): implement complete user authentication system

- Implement user login and registration with JWT token-based authentication
- Add password encryption and secure session management
- Create global authentication state management accessible throughout the app

Example for more complex scenarios:

feat(payment): add payment processing capabilities

- Integrate Stripe payment gateway with support for credit cards and digital wallets
- Implement transaction history tracking and receipt generation
- Add refund and dispute handling workflows

Types

  • feat: A new feature
  • fix: A bug fix
  • docs: Documentation changes
  • style: Code style changes (formatting, missing semicolons, etc.)
  • refactor: Code refactoring without changing functionality
  • test: Adding or updating tests
  • chore: Maintenance tasks (build, dependencies, etc.)
  • perf: Performance improvements
  • ci: CI/CD changes
  • build: Build system changes
  • revert: Reverting previous commits

Examples

feat(auth): add user login functionality
fix(api): resolve null pointer exception in user service
docs(readme): update installation instructions
refactor(utils): simplify date formatting logic

Cost Considerations

This extension uses AI APIs which may incur costs:

  • Claude API: Charged per token (input + output)
  • OpenAI API: Charged per token (input + output)

To manage costs:

  • Set maxDiffSize to limit the amount of diff sent to AI
  • Use cheaper models for simple commits
  • The extension warns you when diff size exceeds the limit

Troubleshooting

"No Git repository found"

Make sure you have opened a folder that contains a Git repository.

"No staged changes found"

Stage your files first using git add or the Source Control panel.

"API Key not configured"

Go to settings and configure your API key for the selected AI provider.

"Failed to get staged diff"

Ensure Git is installed and accessible from command line.

Privacy & Security

  • API keys are stored in VS Code settings (not encrypted by default)
  • Your code changes are sent to third-party AI services
  • Do not commit sensitive files or credentials
  • Consider using .gitignore for sensitive files

Development

Project Structure

vscode-plug/
├── src/
│   ├── extension.ts              # Extension entry point
│   ├── commands/
│   │   └── generateCommit.ts     # Main command logic
│   ├── services/
│   │   ├── gitService.ts         # Git operations
│   │   ├── aiService.ts          # AI service factory
│   │   ├── claudeService.ts      # Claude API implementation
│   │   └── openaiService.ts      # OpenAI API implementation
│   ├── utils/
│   │   └── config.ts             # Configuration management
│   └── types/
│       └── index.ts              # TypeScript types
├── package.json                  # Extension manifest
└── tsconfig.json                 # TypeScript configuration

Building

npm install
npm run compile

Testing

npm run test

Debugging

Press F5 in VS Code to launch Extension Development Host.

Roadmap

  • [ ] Support for custom commit message templates
  • [ ] Multi-language support (Chinese, Spanish, etc.)
  • [ ] Commit history and favorites
  • [ ] Keyboard shortcuts
  • [ ] Diff preview before generation
  • [ ] Support for more AI providers

Contributing

Contributions are welcome! Please feel free to submit issues or pull requests.

License

MIT

Credits

Built with:

  • Anthropic SDK
  • OpenAI SDK
  • VS Code Extension API
  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2025 Microsoft