A VS Code extension that automatically adds intelligent comments to your code using AI. Supports OpenAI, Claude, Ollama (local), and Azure OpenAI.
Features
- 🤖 Multiple AI Providers: OpenAI, Claude, Ollama (local), Azure OpenAI
- 💰 Cost Estimation: See estimated cost before processing
- ⚡ Cancel Anytime: Stop generation mid-process
- ✅ Partial Accept: Click individual comments to accept/reject them
- 🗑️ Remove Comments: Strip all comments from a file
- ⚠️ File Size Warning: Warns before processing large files
- 📝 Custom Instructions: Add your own rules to the AI prompt
- 🎯 Inline Diff: Green ✓ for accepted, red ✗ for rejected comments
How It Works
- Run command (
Ctrl+Alt+C)
- Cost estimate shown (optional) - click Continue or Cancel
- Progress shown with Cancel button
- Comments appear with green highlighting
- Click any comment to toggle accept/reject (turns red with strikethrough)
- Status bar shows:
12/15 comments (click line to toggle)
- Accept (Ctrl+Enter) or Reject All (Esc)
Installation
- Download the
.vsix file from Releases
- In VS Code:
Ctrl+Shift+P → "Install from VSIX"
- Select the downloaded file
Or search for "AI Code Commenter" in the VS Code Extensions marketplace.
Setup
OpenAI (Default)
- Get API key from OpenAI Platform
Ctrl+Shift+P → "AI: Set API Key"
- Paste your key
Claude (Anthropic)
- Get API key from Anthropic Console
- Settings → Change
aiCodeCommenter.provider to claude
Ctrl+Shift+P → "AI: Set API Key"
Ollama (Local - Free!)
- Install Ollama
- Run:
ollama pull codellama
- Settings → Change
aiCodeCommenter.provider to ollama
- No API key needed!
Azure OpenAI
- Create Azure OpenAI resource
- Settings → Set
provider, azureEndpoint, azureDeployment
Ctrl+Shift+P → "AI: Set API Key"
Commands
| Command |
Shortcut |
Description |
| AI: Comment Current File |
Ctrl+Alt+C |
Add comments to entire file |
| AI: Comment Selected Code |
Ctrl+Alt+S |
Add comments to selection |
| AI: Remove All Comments |
Ctrl+Alt+R |
Strip all comments from file |
| AI: Set API Key |
- |
Configure API key for current provider |
| AI: Accept Changes |
Ctrl+Enter |
Accept (non-rejected) changes |
| AI: Reject Changes |
Esc |
Revert all changes |
Configuration
| Setting |
Default |
Description |
provider |
openai |
AI provider: openai, claude, ollama, azure |
openaiModel |
gpt-4o-mini |
OpenAI model |
claudeModel |
claude-sonnet-4-20250514 |
Claude model |
ollamaEndpoint |
http://localhost:11434 |
Ollama API URL |
ollamaModel |
codellama |
Ollama model name |
commentStyle |
detailed |
minimal, detailed, comprehensive |
customInstructions |
"" |
Custom rules for AI (see below) |
showCostEstimate |
true |
Show cost before processing |
fileSizeWarningThreshold |
500 |
Warn if file exceeds this many lines |
Custom Instructions
Add your own rules in Settings → aiCodeCommenter.customInstructions:
Always mention time complexity for algorithms.
Use British English spelling.
Include @throws annotations for functions that can throw.
Keep comments under 80 characters per line.
Cost Estimation
Before processing, you'll see:
Estimated: 2,500 input tokens, 3,750 output tokens. Cost: ~$0.002 (gpt-4o-mini)
[Continue] [Cancel]
Pricing (per 1M tokens)
| Model |
Input |
Output |
| gpt-4o-mini |
$0.15 |
$0.60 |
| gpt-4o |
$2.50 |
$10.00 |
| claude-3-5-sonnet |
$3.00 |
$15.00 |
| claude-3-haiku |
$0.25 |
$1.25 |
| Ollama |
Free |
Free |
Partial Accept/Reject
After generation:
- Green lines (✓) = Will be kept
- Click any green line → Turns red with strikethrough (✗)
- Click red line again → Back to green
- Status bar updates:
8/12 comments
- Accept only applies green lines
This lets you cherry-pick which comments to keep!
Ctrl+Alt+R or Command Palette → "AI: Remove All Comments"
- Removes all single-line comments (
//, #, etc.)
- Removes all multi-line comments (
/* */, """ """, etc.)
- Shows preview with Accept/Reject
Supported Languages
Python, JavaScript, TypeScript, JSX/TSX, Java, C, C++, C#, Go, Rust, PHP, Ruby, Swift, Kotlin, and more.
Troubleshooting
| Error |
Solution |
| Invalid API key |
Check key format, re-enter via "AI: Set API Key" |
| Rate limited |
Wait a moment, try again |
| Quota exceeded |
Check billing at provider's dashboard |
| Cannot connect (Ollama) |
Ensure Ollama is running: ollama serve |
Changelog
1.6.0
- Added extension icon
- Published to VS Code Marketplace
- Publisher: BanditVault
1.5.0
- Multiple AI Providers: Added Claude, Ollama, Azure OpenAI support
- Cancel Button: Stop generation anytime
- Cost Estimation: See estimated cost before processing
- Partial Accept: Click individual comments to accept/reject
- Custom Instructions: Add your own rules to the prompt
- Remove Comments: New command to strip all comments
- File Size Warning: Warns before processing large files
- Keyboard Shortcuts: Ctrl+Enter to accept, Esc to reject
1.4.0
- Flicker-free generation
- Non-modal accept/reject in status bar
1.3.0
- Live streaming output
- Improved diff detection
1.2.0
- Inline diff view with green/yellow highlighting
1.1.0
- Streaming API support
- Version management via version.txt
1.0.0
License
MIT License - see LICENSE file.