🎬 Live Demonstration
1. The Experience: Before & After
--- a/src/auth/login.ts
+++ b/src/auth/login.ts
@@ -14,6 +14,9 @@ export async function handleLogin(req: Request) {
+ if (!req.body.email || !isValidEmail(req.body.email)) {
+ throw new ValidationError('A valid email address is required');
+ }
⚡ One click on the ✨ Sparkle Icon generates a meaningful commit:
feat(auth): validate email address format on login
Why:
- Malformed login payloads were reaching the database layer, triggering unhandled 500 exceptions and exposing internal error traces.
Changes:
- Add RFC 5322 regex validation in handleLogin handler
- Throw explicit ValidationError with user-friendly 400 Bad Request message
2. Native VS Code Source Control UI Integration
The extension integrates directly into the VS Code Source Control (SCM) panel:
┌─────────────────────────────────────────────────────────────┐
│ SOURCE CONTROL │
├─────────────────────────────────────────────────────────────┤
│ │
│ ┌───────────────────────────────────────────────┬───────┐ │
│ │ feat(auth): validate email address on login │ ✨ │◄─ Click!
│ │ │ │ │
│ │ Why: │ │ │
│ │ - Prevent unhandled DB exceptions from invalid│ │ │
│ │ inputs. │ │ │
│ │ │ │ │
│ │ Changes: │ │ │
│ │ - Add email regex validator in handleLogin │ │ │
│ └───────────────────────────────────────────────┴───────┘ │
│ │
│ ✓ Commit ✓ Commit & Push │
│ │
│ CHANGES │
│ M src/auth/login.ts │
└─────────────────────────────────────────────────────────────┘
Pro Tip: You can also press Ctrl + Alt + C (or Cmd + Alt + C on macOS) anywhere in VS Code to trigger commit generation!
🎯 Key Features
- ⚡ Blazing Fast Generation: Uses Google's ultra-responsive
gemini-1.5-flash or Groq's high-throughput llama-3.3-70b-versatile.
- 📐 100% Conventional Commits 1.0.0 Compliant: Strictly formats messages with appropriate types (
feat, fix, docs, refactor, perf, test, build, ci, chore, revert) and concise scopes.
- 🪄 Native SCM Title & Input Integration:
- Sparkle action button (
$(sparkle)) right on the commit message input box.
- SCM view header action button.
- Global shortcut keybinding.
- 🛡️ Smart Diff Inspection & Fallback:
- Analyzes staged changes (
git diff --cached).
- If you haven't staged changes yet, gives you an instant prompt to "Generate from Unstaged Changes" or "Stage All & Generate" without leaving the keyboard.
- Automatic diff truncation for large files and lockfiles to prevent token overflow.
- 🔐 Secure Key Storage: API keys are securely persisted inside VS Code's encrypted
SecretStorage (never stored in plain text files or checked into Git).
- 🎨 Optional Gitmoji Support: Easily toggle Gitmoji prefixes (e.g.,
✨ feat(ui): ... or 🐛 fix(api): ...).
- 📝 Custom Rules & Guidelines: Inject custom instructions (e.g., Jira ticket patterns, scope guidelines, language preferences).
🔄 How It Works
flowchart LR
A[Staged / Working Git Diff] --> B[GitService]
B --> C{Diff Detected?}
C -->|No| D[Prompt: Stage all or use working changes]
C -->|Yes| E[PromptBuilder: Enforce Conventional Commits]
E --> F[AIService: Gemini / Groq API]
F --> G[Sanitizer: Strip markdown & clean output]
G --> H[SCM Input Box Auto-Fill]
- Diff Extraction: The extension queries the VS Code Git Extension API for staged changes (
repository.diff(true)).
- Prompt Optimization: Prepares a targeted system instruction with strict Conventional Commit rules.
- Inference: Sends the diff payload over HTTPS to Google Gemini or Groq.
- Sanitization: Strips accidental markdown backticks, unwanted commentary, and ensures imperative tone.
- Auto-Fill & Focus: Populates the VS Code Git input box and focuses the Source Control view so you can review and commit immediately.
🚀 Quick Start Guide
Step 1: Install & Launch
Open this extension in VS Code. If developing locally, press F5 to launch the Extension Development Host.
Step 2: Get a Free API Key
Both supported providers offer generous free tiers:
Open the Command Palette (Ctrl+Shift+P or Cmd+Shift+P) and run:
AI: Set Groq / Gemini API Key
Select your provider and paste your key. (The key is encrypted in VS Code SecretStorage).
Step 4: Generate Your First Commit
- Make a change in any file.
- Open the Source Control panel (Ctrl+Shift+G).
- Click the ✨ Sparkle Icon in the commit message box or press Ctrl+Alt+C.
- Your commit message will appear instantly!
💡 Examples & Scenarios
| Diff Content |
Generated Commit Message |
Type |
| Added a new user avatar component and styled it |
feat(ui): add user avatar component |
feat |
| Fixed null pointer exception when JWT is expired |
fix(auth): handle null token on expired session |
fix |
| Updated API endpoint documentation in README |
docs: update authentication endpoint docs |
docs |
| Extracted database connection logic into helper |
refactor(db): extract connection pool utility |
refactor |
Added index on users.email column for faster queries |
perf(db): add index on user email lookup |
perf |
| Added unit tests for payment webhook |
test(payments): add unit test coverage for stripe webhook |
test |
Updated dependencies in package.json |
chore(deps): update project dependencies |
chore |
⌨️ Keyboard Shortcuts & Commands
| Command |
Title |
Default Shortcut |
Location |
ai-commit.generate |
AI: Generate Commit Message |
Ctrl+Alt+C / Cmd+Alt+C |
SCM Input Box, SCM Title, Palette |
ai-commit.setApiKey |
AI: Set Groq / Gemini API Key |
— |
Command Palette |
ai-commit.selectProvider |
AI: Select AI Provider (Groq / Gemini) |
— |
Command Palette |
⚙️ Configuration Reference
You can customize the extension via VS Code Settings (Ctrl+, or Cmd+, and search for AI Commit):
{
// Choose AI provider: "gemini" or "groq"
"aiCommit.provider": "gemini",
// Model to use for Google Gemini
"aiCommit.geminiModel": "gemini-1.5-flash",
// Model to use for Groq
"aiCommit.groqModel": "llama-3.3-70b-versatile",
// Commit style: "detailed" (includes Why/Reason & Changes) or "concise" (single-line summary only)
"aiCommit.commitStyle": "detailed",
// Explicitly explain the rationale and motivation behind changes in the commit body
"aiCommit.includeReason": true,
// Include Gitmoji in commit message (e.g. ✨ feat: ...)
"aiCommit.includeEmoji": false,
// Fallback to unstaged changes if no staged changes exist
"aiCommit.fallbackToWorkingTree": true,
// Custom instructions appended to the AI prompt
"aiCommit.customInstructions": ""
}
🎯 Custom Instructions Examples
Want tickets referenced in every commit? Add this to aiCommit.customInstructions:
"aiCommit.customInstructions": "Always include ticket format PROJ-123 in the scope if mentioned in modified files."
Want Bengali or bilingual commit bodies?
"aiCommit.customInstructions": "Write short description in English, then add a one-line Bengali translation in the commit body."
🔒 Security & Privacy
- No Data Harvesting: Your code diff is sent directly and exclusively via TLS to Google Gemini's or Groq's official API endpoints.
- Zero Third-Party Relays: We do not run any intermediate proxy or logging servers.
- Encrypted Secrets: Your API keys are stored in VS Code's native
SecretStorage, which leverages your operating system's keychain (Windows Credential Manager, macOS Keychain, or Linux Secret Service).
🛠️ Development & Building
Want to customize or contribute to this extension?
# 1. Clone the repository
git clone https://github.com/your-username/ai-commit-generator.git
cd ai-commit-generator
# 2. Install dependencies
npm install
# 3. Compile in watch mode
npm run watch
# 4. Press F5 in VS Code to launch the Extension Development Host!
To build a production bundle:
npm run package
📄 License
This project is licensed under the MIT License.