AI Autocomplete for VS Code
AI-powered inline code completions using Claude API for JavaScript, TypeScript, and Dart.
Features
- Inline Completions: Get AI-powered code suggestions as you type
- Language Support: JavaScript, TypeScript, JSX, TSX, and Dart
- Smart Caching: Reduces API calls with LRU cache
- Throttling: Prevents API spam with configurable debounce
- Error Handling: Graceful degradation with informative messages
- Language-Aware: Context-aware completions for each language
Supported Languages
- JavaScript (
.js, .jsx, .mjs)
- TypeScript (
.ts, .tsx)
- Dart (
.dart) - Great for Flutter development!
Setup
1. Get an API Key
- Go to Anthropic Console
- Sign up or log in
- Navigate to "API Keys" section
- Create a new API key
Option A: Via Command Palette
- Open VS Code Command Palette (
Ctrl+Shift+P / Cmd+Shift+P)
- Run
Claude: Set API Key
- Paste your API key when prompted
Option B: Via Settings
- Open Settings (
Ctrl+, / Cmd+,)
- Search for "Claude Autocomplete"
- Paste your API key in the
claudeAutocomplete.apiKey field
Usage
Automatic Completions
Completions appear automatically as you type in supported languages. The extension:
- Extracts context around your cursor
- Sends it to Claude API
- Displays suggestions inline
- Caches results to minimize API calls
Manual Trigger
Press Ctrl+Shift+Space (or Cmd+Shift+Space on Mac) to manually request a completion.
Commands
Available commands in the Command Palette:
Claude: Set API Key - Update your API key
Claude: Toggle Autocomplete - Enable/disable the extension
Claude: Clear Completion Cache - Clear cached completions
Claude: Trigger Completion Manually - Request a completion manually
Configuration
Open Settings and search for "Claude Autocomplete" to customize:
| Setting |
Default |
Description |
claudeAutocomplete.enabled |
true |
Enable/disable completions |
claudeAutocomplete.model |
claude-sonnet-4-20250514 |
Model to use |
claudeAutocomplete.maxTokens |
300 |
Max tokens per completion (100-1000) |
claudeAutocomplete.temperature |
0.2 |
Determinism (0=exact, 1=creative) |
claudeAutocomplete.debounceDelay |
300 |
Wait time (ms) before requesting (100-2000) |
claudeAutocomplete.contextLinesBefore |
30 |
Context lines before cursor (10-100) |
claudeAutocomplete.contextLinesAfter |
10 |
Context lines after cursor (0-50) |
Cost Estimation
Based on Claude Sonnet 4 pricing:
- Input: $3 / million tokens
- Output: $15 / million tokens
Typical usage: ~$0.10-0.50 per hour of active coding
Example:
- 50 completions/hour
- 500 input tokens average = 25,000 total input tokens
- 100 output tokens average = 5,000 total output tokens
- Cost: (25,000 × $3/M) + (5,000 × $15/M) ≈ $0.15
- Request Throttling: Max 1 request per 300ms to prevent API spam
- Smart Caching: 100-entry LRU cache with 5-minute TTL
- Aggressive Filtering: Only completes in code (not comments/strings)
- Timeouts: 5-second timeout per request to avoid blocking
- Memory: Uses <50MB memory typical usage
Limitations
- Only works in supported languages (JS/TS/Dart)
- No completions in comments or string literals
- Requires network connection
- API key is stored in VS Code settings
Troubleshooting
- Run
Claude: Set API Key command
- Or add your key to VS Code settings
"Rate limited by API"
- Reduce
debounceDelay setting to decrease request frequency
- Wait a moment before continuing typing
"Request timeout"
- The API took too long (>5s)
- Check your internet connection
- Try again
No completions appearing
- Ensure language is supported (JS/TS/Dart)
- Check you're not in a comment or string
- Verify API key is valid
- Check VS Code output channel:
Claude Autocomplete
Privacy & Security
- Your API key is stored securely in VS Code's encrypted settings
- Code context is sent to Anthropic API for processing
- Results are cached locally (not stored externally)
- No telemetry or usage tracking
License
MIT
Links
Support
For issues or questions:
- Check the troubleshooting section
- View logs in VS Code output channel:
Claude Autocomplete
- File an issue here
Made with ❤️ for developers who love AI-assisted coding
| |