Fix Code with Claude
AI-powered code fixing and improvement extension for Visual Studio Code using Claude AI from Anthropic.
✨ Features
- 🔍 Smart CodeLens Integration - "Fix Code" buttons appear above functions and classes
- 🎯 Context-Aware Fixes - Understands full file context while fixing selected code
- 🔒 Secure API Key Storage - Uses VSCode's SecretStorage API
- 📝 Interactive Workflow - Choose to replace, diff, or copy fixed code
- ⚡ Multiple Trigger Methods - CodeLens, context menu, keyboard shortcut, or command palette
🚀 Getting Started
1. Install the Extension
Install from VSCode Marketplace or build from source.
2. Get Your API Key
- Visit Anthropic Console
- Create an account or sign in
- Generate an API key
The extension will prompt for your API key on first use, or you can:
📖 Usage
Method 1: CodeLens (Easiest)
- Open any code file
- Look for "✨ Fix Code" buttons above functions/classes
- Click the button
- Enter what you want to fix
- Choose how to apply the fix
Method 2: Text Selection
- Select code you want to fix
- Right-click → "Fix Code with Claude"
- Or use keyboard shortcut:
Ctrl+Shift+F (Windows/Linux) or Cmd+Shift+F (Mac)
Method 3: Command Palette
- Press
Ctrl+Shift+P (Windows/Linux) or Cmd+Shift+P (Mac)
- Type "Fix Code"
- Select "Fix Code: Fix Code with Claude"
🎯 Example Prompts
- "Refactor this to use async/await"
- "Add error handling"
- "Optimize for performance"
- "Add TypeScript types"
- "Convert to functional component"
- "Add unit tests"
- "Improve readability"
- "Fix the bug in this function"
⚙️ Configuration
Access settings via File > Preferences > Settings and search for "Fix Code":
| Setting |
Default |
Description |
fixCode.model |
claude-sonnet-4-20250514 |
Claude model to use |
fixCode.maxTokens |
4096 |
Maximum response length |
fixCode.autoApply |
false |
Auto-apply without confirmation |
Available Models
claude-opus-4-5-20251101 - Most powerful
claude-sonnet-4-5-20250929 - Balanced (recommended)
claude-sonnet-4-20250514 - Fast and efficient
claude-haiku-4-5-20251001 - Ultra-fast
🔧 Commands
| Command |
Description |
Fix Code: Fix Code with Claude |
Fix selected code |
Fix Code: Set API Key |
Update API key |
Fix Code: Reset API Key |
Remove stored API key |
🛠️ Development
Prerequisites
Setup
# Clone repository
git clone https://github.com/yourusername/fix-code-extension
cd fix-code-extension
# Install dependencies
npm install
# Compile TypeScript
npm run compile
# Run in development mode
# Press F5 in VSCode to launch Extension Development Host
Project Structure
fix-code-extension/
├── src/
│ ├── extension.ts # Main extension code
│ └── FixCodeLensProvider.ts # CodeLens provider
├── package.json # Extension manifest
├── tsconfig.json # TypeScript config
└── README.md # This file
🔒 Privacy & Security
- API keys are stored securely using VSCode's SecretStorage API
- Code is sent to Anthropic's API for processing
- No code is stored or logged by this extension
- Review Anthropic's Privacy Policy
🐛 Troubleshooting
"No active editor found"
Make sure you have a file open and code selected.
"API Key is required"
Set your API key using Fix Code: Set API Key command.
"API request failed: 401"
Your API key is invalid. Reset it with Fix Code: Reset API Key and enter a new one.
CodeLens not showing
Try:
- Reload VSCode window (
Ctrl+R or Cmd+R)
- Check if CodeLens is enabled in settings
- Ensure file is saved with proper extension
📄 License
MIT License - See LICENSE file for details
🙏 Credits
Built with ❤️ using Claude by Anthropic
📮 Support
- Report issues on GitHub Issues
- Star the repo if you find it useful!
Note: This extension requires an Anthropic API key and will incur API usage costs based on your usage.