How to Set Up Claude Code in VS Code (Step by Step)
Claude Code is Anthropic's coding agent. Its VS Code extension gives you a chat panel that can read your project, plan, edit files and show you the changes as diffs.
In short: install the “Claude Code” extension, sign in with a paid Claude plan or a Claude Console account, open the Spark icon, and start in Manual or Plan mode.
Why use Claude Code in VS Code
You stay in your editor. You see every change as a side-by-side diff before you accept it. It can work on many files at once, like adding a feature plus its tests.
What you need
- VS Code: version 1.94.0 or later (Help → About).
- An Anthropic account: any paid Claude plan (Pro, Max, Team or Enterprise) or a Claude Console account. No API key needed for sign-in.
- Claude Code extension: search “Claude Code” in Extensions. It includes its own copy of the CLI for the panel.
- Optional: the CLI: install it separately if you want to type
claudein the terminal.
How setup flows
Install steps
- Open VS Code. Check the version is 1.94.0 or later.
- Press Ctrl+Shift+X (Mac: Cmd+Shift+X) to open Extensions.
- Search Claude Code (publisher Anthropic). Click Install.
- If it does not appear, run Developer: Reload Window from the Command Palette.
- Open any file. Click the Spark icon in the top-right of the editor. (Or click ✻ Claude Code in the bottom status bar.)
- Click Sign in and finish authorisation in your browser.
- You will see a short “Learn Claude Code” checklist. Follow it or close it.
Settings (what to change first)
Open Ctrl+, → Extensions → Claude Code.
- Permission mode: click the mode at the bottom of the prompt box. Beginners: use Manual (asks before edits) or Plan (shows a plan first).
- initialPermissionMode: set the default for new chats, e.g.
plan. - preferredLocation:
sidebarkeeps Claude on the right while you code. - respectGitIgnore: keep it on so ignored files are left out.
- Model: click the model name at the bottom of the prompt box, or type
/model, to switch models.
Configuration (project and user files)
- CLAUDE.md in the project root: short project rules (language, test command, style). Claude reads it each session.
- ~/.claude/settings.json: shared by the extension and the CLI. Use it for allowed or denied commands and MCP servers.
- Block secret files with a deny rule so Claude never reads them:
{
"permissions": {
"deny": ["Read(./.env)", "Read(./secrets/**)"]
}
}CLAUDE.md# Project rules - Language: Python 3.12 - Tests: pytest -q (must pass before you finish) - Style: type hints, short functions - Never touch .env or deploy scripts
First test (5 minutes)
- Open a folder with one small file, e.g.
utils.py. - Select a function. Claude sees the selected text automatically.
- Type: “Add input checks and a pytest test for this function. Run the tests.”
- In Manual mode, Claude shows a side-by-side diff. Read it. Click accept or reject for each change.
- When it wants to run
pytest, approve it. Check the result yourself. - Use Rewind (hover a message) if you want to undo its file changes.
Useful shortcuts
| Action | Windows/Linux | Mac |
|---|---|---|
| Focus Claude / editor | Ctrl+Esc | Cmd+Esc |
| Insert @file#lines | Alt+K | Option+K |
| New tab chat | Ctrl+Shift+Esc | Cmd+Shift+Esc |
| New line in prompt | Shift+Enter | Shift+Enter |
- Optional CLI: to run
claudein the terminal, install the standalone CLI from the official Claude Code docs. The extension does not add it to PATH. - Company cloud: if your company uses Amazon Bedrock or Google Cloud, turn on Disable Login Prompt and set the provider in
~/.claude/settings.json.
Verify your setup: let Claude Code in VS Code fix a small tiffin bill bug, with a diff you approve
Hello friends. The chapter above showed how to install the Claude Code extension and sign in. Now we prove that the extension really works on your machine. You will open a tiny practice folder for a fictional tiffin service called Marigold Tiffin Service, open the Claude panel with the Spark icon, switch to Manual mode, and ask Claude to fix a bill bug. Claude shows every edit as a side-by-side diff, and you decide. The starter file fails 4 tests and passes 3, and a correct fix passes all 7.
नमस्कार मित्रांनो. वरच्या chapter मध्ये आपण Claude Code extension install करून sign in कसं करायचं ते पाहिलं. आता extension खरंच तुमच्या machine वर चालतो का ते तपासूया. Marigold Tiffin Service नावाच्या काल्पनिक tiffin service चा एक छोटा practice folder उघडा, Spark icon ने Claude panel उघडा, Manual mode निवडा, आणि Claude ला bill चा bug fix करायला सांगा. Claude प्रत्येक edit side-by-side diff मध्ये दाखवतो, आणि निर्णय तुम्ही घेता. Starter file मध्ये 4 tests fail आणि 3 pass होतात, आणि बरोबर fix केल्यावर सगळे 7 pass होतात.
नमस्ते दोस्तों. ऊपर के chapter में हमने Claude Code extension install करके sign in करना देखा. अब देखते हैं कि extension सच में आपकी machine पर चलता है या नहीं. Marigold Tiffin Service नाम की काल्पनिक tiffin service का एक छोटा practice folder खोलो, Spark icon से Claude panel खोलो, Manual mode चुनो, और Claude से bill का bug ठीक करवाओ. Claude हर edit side-by-side diff में दिखाता है, और फ़ैसला आप करते हो. Starter file में 4 tests fail और 3 pass होते हैं, और सही fix के बाद सभी 7 pass होते हैं।
Ravindra Bagale's Tip
Recent versions of the extension can start a new chat in Auto mode. For practice, click the mode indicator at the bottom of the prompt box and choose Manual, so Claude asks before every edit and most commands.
Ravindra Bagale's Tip – मराठी
Extension चे नवीन versions नवीन chat Auto mode मध्ये सुरू करू शकतात. सरावासाठी prompt box च्या खाली असलेल्या mode indicator वर click करा आणि Manual निवडा, म्हणजे प्रत्येक edit आणि बहुतेक commands आधी Claude परवानगी मागेल.
Ravindra Bagale's Tip – हिंदी
Extension के नए versions नई chat को Auto mode में शुरू कर सकते हैं. अभ्यास के लिए prompt box के नीचे mode indicator पर click करो और Manual चुनो, ताकि हर edit और ज़्यादातर commands से पहले Claude पूछे।
Python 3.13.5 and pytest 9.1.1. Starter: 4 failed, 3 passed. Fixed file: 7 passed. The AI tool itself runs on your own computer, so its words will differ from any example here.Your task: open the practice folder in VS Code, open the Claude Code panel, and ask Claude to make tiffin_bill charge 60 rupees per meal, give 10 percent off the whole bill when there are 20 or more meals, and reject fewer than 1 meal with a message that contains meals.
Setup (practice folder marigold-tiffin)
- Create the practice folder with the name shown below, and save the two files from this section inside it.
- Create a virtual environment: on macOS or Linux run
python3 -m venv .venv. On Windows runpy -3 -m venv .venv. - Activate it: on macOS or Linux run
source .venv/bin/activate. In Windows Command Prompt run.venv\Scripts\activate.bat, and in Windows PowerShell run.venv\Scripts\Activate.ps1. - Install pytest inside the virtual environment:
python -m pip install pytest.
Starter tiffin_bill.py (there is no discount for 20 or more meals, and 0 or negative meals are accepted):
"""Practice data: Marigold Tiffin Service is a fictional business made up for this exercise."""
PRICE_PER_MEAL = 60
def tiffin_bill(meals):
"""Return the monthly bill in rupees for the given number of meals."""
return meals * PRICE_PER_MEAL
Simple tests test_tiffin_bill.py:
import pytest
from tiffin_bill import tiffin_bill
def test_one_meal():
assert tiffin_bill(1) == 60
def test_five_meals():
assert tiffin_bill(5) == 300
def test_nineteen_meals_has_no_discount():
assert tiffin_bill(19) == 1140
def test_twenty_meals_get_ten_percent_off():
assert tiffin_bill(20) == 1080
def test_thirty_meals_get_ten_percent_off():
assert tiffin_bill(30) == 1620
def test_zero_meals_is_rejected():
with pytest.raises(ValueError, match="meals"):
tiffin_bill(0)
def test_negative_meals_is_rejected():
with pytest.raises(ValueError, match="meals"):
tiffin_bill(-3)
Before you ask the AI, run python -m pytest -q in the folder. You should see 4 failed, 3 passed. That proves Python and pytest work before the AI tool is involved.
The exact prompt to try (copy it as it is):
claude-vscode-prompt.txtRead tiffin_bill.py and test_tiffin_bill.py. Fix tiffin_bill for the fictional Marigold Tiffin Service: 60 rupees per meal, and 10 percent off the whole bill when meals is 20 or more, so 20 meals cost 1080. Raise ValueError with a message that contains meals when meals is less than 1. Do not change test_tiffin_bill.py. Then run python -m pytest -q and show me the result.
HOW to verify your Claude Code extension setup
- Open the folder and a file: in VS Code choose File and then Open Folder, pick
marigold-tiffin, and opentiffin_bill.py. The Spark icon appears only when a file is open. - Open Claude: click the Spark icon in the Editor Toolbar at the top-right of the editor. You can also click ✻ Claude Code in the Status Bar at the bottom. If a sign-in screen appears, click Sign in and finish in your browser.
- Choose Manual mode: click the mode indicator at the bottom of the prompt box and select Manual. In Manual mode, Claude asks permission before file edits and most shell commands.
- Send the prompt: paste the prompt above into the prompt box and press Enter. Claude reads both files and then asks before it edits
tiffin_bill.py. - Review the diff: Claude shows the original and the proposed code side by side. Accept it only if it adds the discount and the check for meals and leaves the test file alone. Otherwise reject it, or tell Claude what to do instead.
- Approve the test run with care: read the command Claude wants to run. It should be the pytest command from your prompt. Approve it only then.
- Confirm yourself: in the VS Code terminal, with your virtual environment active, run
python -m pytest -q. Expect 7 passed.
What a correct result looks like: Claude explains that the starter has no discount and does not reject 0 or negative meals. Its edit adds a check that raises ValueError with meals in the message, and a 10 percent discount from 20 meals, for example total - total // 10. The exact words and code style change from run to run, which is fine. The result is correct only when pytest shows 7 passed. If Claude proposes an edit to test_tiffin_bill.py, reject it, because the tests describe the correct bill.
Real pytest output after the fixed file:
pytest-after.txt....... [100%]
7 passed in 0.01s
Optional completed tiffin_bill.py (try it yourself first)
Claude may calculate the discount in a different way, such as multiplying by 0.9 and converting to a whole number. Any version is fine if all 7 tests pass and the test file is unchanged.
tiffin_bill.py"""Practice data: Marigold Tiffin Service is a fictional business made up for this exercise."""
PRICE_PER_MEAL = 60
def tiffin_bill(meals):
"""Return the monthly bill in rupees for the given number of meals."""
if meals < 1:
raise ValueError("meals must be at least 1")
total = meals * PRICE_PER_MEAL
if meals >= 20:
total = total - total // 10
return total
Troubleshooting: common Claude Code extension problems
- Problem: the Spark icon is not visible. Fix: open a file, because a folder alone is not enough. Check that VS Code is 1.94.0 or later under Help and then About, run Developer: Reload Window from the Command Palette, and temporarily turn off other AI extensions. The extension also does not work in Restricted Mode, so trust the workspace.
- Problem: the extension will not install. Fix: check that VS Code is 1.94.0 or later and that VS Code is allowed to install extensions. You can also install it from the Claude Code page on the Visual Studio Marketplace.
- Problem: you see Not logged in · Please run /login. Fix: the extension normally reopens the sign-in screen by itself. If it does not, run Developer: Reload Window from the Command Palette.
- Problem: Claude edits files without asking you first. Fix: the chat is in Auto or Edit automatically mode. Click the mode indicator at the bottom of the prompt box and choose Manual.
- Problem: the Claude Code panel opens but stays blank. Fix: update the extension in the Extensions view and run Developer: Reload Window. If it is still blank, run Claude Code: Show Logs from the Command Palette and read the log. Remove code and personal details before you share any log.
- Problem: Claude never answers your prompt. Fix: check your internet connection and start a new conversation. If you also installed the Claude Code CLI, run
claudein a terminal, because it can show a more detailed error. - Problem: you accepted a change and now want it back. Fix: hover over the message, click the rewind button, and choose Rewind code to here. This reverts Claude's file edits but keeps the conversation.
Practice cards: English and spoken Marathi
Each card below explains one idea on its own, so you can save or revise a single card without reading the whole chapter.
Choose Manual mode for practice
Read the diff before you accept
सरावासाठी Manual mode निवडा
Accept करण्याआधी diff वाचा
Quick quiz
1. What VS Code version does the extension need?
1.94.0 or later.
2. Which mode shows the plan before any change?
Plan mode.
3. Which file holds project rules for Claude?
CLAUDE.md in the project root.
4. How do you stop Claude reading .env?
Add a Read(./.env) deny rule in ~/.claude/settings.json.
Save tokens and money
Select only the code you need and use @file#lines instead of whole folders. Keep CLAUDE.md short. Start a new chat for a new task. Run /compact on long chats. Check /usage to see what is using your plan.