The fastest way to use Claude in VS Code
You can use Claude inside VS Code through the Anthropic Claude extension, which you install from the VS Code marketplace in about two minutes. The extension lets you write prompts, send code to Claude, and see responses without leaving your editor. You will need an Anthropic API key, which you create on the Anthropic website — this is different from a free Claude.ai account and does cost money based on how much you use it.
The extension works with any file type and integrates with your existing code. You can highlight a section of code, ask Claude a question about it, and get an answer in a side panel. You can also start fresh conversations or use Claude to generate new code from scratch.
Key Takeaways
- Install the Anthropic Claude extension from the VS Code marketplace, then restart VS Code to activate it.
- You need an API key from Anthropic (not a free Claude.ai account) to authenticate the extension.
- Highlight code or text in your editor and send it to Claude without switching windows.
- The extension charges based on tokens used, so review Anthropic's pricing before your first request.
Installing the extension from the marketplace
Open VS Code and go to the Extensions view by clicking the Extensions icon in the left sidebar (it looks like four squares) or pressing Ctrl+Shift+X on Windows/Linux or Cmd+Shift+X on Mac. Search for "Claude" or "Anthropic Claude" in the search box.
Click the official Anthropic Claude extension (published by Anthropic) and then click Install. VS Code will download and install it. When the install finishes, you may see a prompt to reload VS Code — click Reload or restart the application manually to activate the extension.
After restart, you should see a Claude icon in your left sidebar. Click it to open the Claude panel. If you do not see it, check that the extension shows as "Installed" in the Extensions view.
Getting and adding your API key
Go to console.anthropic.com and sign in with your Anthropic account. If you do not have one, create it on that same page. This is separate from a free Claude.ai account — you need the console account to generate API keys.
Once logged in, click "API Keys" in the left menu, then click "Create Key". Give it a name (like "VS Code") so you remember what it is for. Anthropic will show you the key once — copy it immediately and save it somewhere safe, because you cannot view it again.
Go back to VS Code, open the Claude panel, and look for a settings or authentication section. Paste your API key into the field labeled "API Key" or similar. The extension will store it locally on your machine. Do not share this key with anyone or commit it to a repository.
Sending code and text to Claude
Highlight any code or text in your editor. Right-click and look for a Claude option, or use the keyboard shortcut shown in the extension (often Ctrl+L or Cmd+L, depending on your setup). This opens a prompt box where you can type your question.
Type what you want Claude to do — for example, "Explain this function" or "Fix the bug in this code" or "Write a test for this". Press Enter or click Send. Claude will process your request and show the response in the side panel.
You can continue the conversation by typing follow-up questions in the same panel. Each message counts toward your API usage and will be billed according to Anthropic's token pricing.
Understanding API costs and usage
The Claude extension uses the Anthropic API, which is not free. You pay based on the number of tokens you send and receive. Tokens are roughly equivalent to words — a typical sentence is 10 to 20 tokens. Pricing varies by Claude model (Claude 3.5 Sonnet, Claude 3 Opus, and others have different rates).
Before you start, visit anthropic.com/pricing to see current rates. Set up billing on your Anthropic console account and optionally set a usage limit so you do not spend more than you intend. You can check your usage and costs anytime in the console under "Usage".
If you want to try Claude without paying, use Claude.ai (the free web version) in your browser instead. It has a free tier with limits, but it does not require an API key or credit card. The extension is better for developers who want Claude integrated into their workflow and are willing to pay for that convenience.
Troubleshooting common problems
If the Claude panel does not appear after installing, restart VS Code completely. Close the application and open it again, not just the window. Check that the extension shows as "Installed" and not "Installing" in the Extensions view.
If you get an authentication error, double-check that you copied your API key correctly from the Anthropic console. Make sure there are no extra spaces or line breaks. If the key is old, generate a new one in the console — old keys sometimes stop working.
If Claude responds slowly or times out, check your internet connection. Very large files or requests may take longer. If you consistently hit timeouts, try breaking your request into smaller pieces or switching to a faster Claude model in the extension settings.
If you see a billing error, log into your Anthropic console and confirm that a payment method is on file and that you have not hit a usage limit you set. Add or update your payment method if needed.
Alternative ways to use Claude with VS Code
The Anthropic Claude extension is the official option, but other extensions exist that integrate Claude or similar AI models. GitHub Copilot is a different AI assistant (made by GitHub and OpenAI) that also works in VS Code and focuses on code completion. It has a free tier and a paid tier.
Continue.dev is an open-source extension that supports multiple AI models, including Claude, and may give you more control over how Claude behaves. Codeium is another free AI coding assistant that works in VS Code.
If you only need Claude occasionally, you can also keep Claude.ai open in a browser tab and copy code back and forth manually. This avoids API costs but is slower than using the extension.
Frequently Asked Questions
Do I need a paid Claude.ai account to use the extension?
No. You need an Anthropic API key, which you create on console.anthropic.com. This is separate from Claude.ai. You do need to add a payment method to your Anthropic console account, because API usage is billed per token.
Can I use the extension for free?
The extension itself is free to install, but using it costs money because it calls the Anthropic API. Each request is billed based on tokens. If you want free Claude access, use Claude.ai in your browser instead, which has a free tier with limits.
Will my code be stored or used to train Claude?
Code you send through the API is not used to train Claude models. Anthropic's API terms state that data sent through the API is not retained for training. Check Anthropic's privacy policy for full details.
What if I accidentally commit my API key to GitHub?
Regenerate your API key immediately in the Anthropic console. The old key will stop working. GitHub also scans for exposed API keys and may alert you. After regenerating, update the key in your VS Code extension settings.
Can I use the extension offline?
No. The extension requires an internet connection to send requests to Anthropic's servers. You cannot use Claude locally without an internet connection.