Ravindra BagaleCourses & study guides Track your progress
AI CODING ASSISTANTS · CHAPTER 2 · SETUP

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

WHY

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

WHAT
  • 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 claude in the terminal.

How setup flows

1 · Install extension Ctrl+Shift+X → Claude Code 2 · Open the panel Spark icon, top-right 3 · Sign in browser authorisation 4 · Pick a mode Manual or Plan to start 5 · First prompt review the diff, accept

Install steps

HOW
  1. Open VS Code. Check the version is 1.94.0 or later.
  2. Press Ctrl+Shift+X (Mac: Cmd+Shift+X) to open Extensions.
  3. Search Claude Code (publisher Anthropic). Click Install.
  4. If it does not appear, run Developer: Reload Window from the Command Palette.
  5. Open any file. Click the Spark icon in the top-right of the editor. (Or click ✻ Claude Code in the bottom status bar.)
  6. Click Sign in and finish authorisation in your browser.
  7. You will see a short “Learn Claude Code” checklist. Follow it or close it.

Settings (what to change first)

Open Ctrl+, → Extensions → Claude Code.

  1. Permission mode: click the mode at the bottom of the prompt box. Beginners: use Manual (asks before edits) or Plan (shows a plan first).
  2. initialPermissionMode: set the default for new chats, e.g. plan.
  3. preferredLocation: sidebar keeps Claude on the right while you code.
  4. respectGitIgnore: keep it on so ignored files are left out.
  5. Model: click the model name at the bottom of the prompt box, or type /model, to switch models.

Configuration (project and user files)

  1. CLAUDE.md in the project root: short project rules (language, test command, style). Claude reads it each session.
  2. ~/.claude/settings.json: shared by the extension and the CLI. Use it for allowed or denied commands and MCP servers.
  3. Block secret files with a deny rule so Claude never reads them:
~/.claude/settings.json
{
  "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)

  1. Open a folder with one small file, e.g. utils.py.
  2. Select a function. Claude sees the selected text automatically.
  3. Type: “Add input checks and a pytest test for this function. Run the tests.”
  4. In Manual mode, Claude shows a side-by-side diff. Read it. Click accept or reject for each change.
  5. When it wants to run pytest, approve it. Check the result yourself.
  6. Use Rewind (hover a message) if you want to undo its file changes.

Useful shortcuts

ActionWindows/LinuxMac
Focus Claude / editorCtrl+EscCmd+Esc
Insert @file#linesAlt+KOption+K
New tab chatCtrl+Shift+EscCmd+Shift+Esc
New line in promptShift+EnterShift+Enter
  • Optional CLI: to run claude in 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.
Rule: do not turn on “bypass permissions” on your real machine. Keep approval for commands that delete, install or deploy.

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.

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.

Practice label: Marigold Tiffin Service and its meal prices are fictional teaching data. It is not a real business, and no real customer data is used. Passing these tests proves only the listed cases.
Environment (tested): on 16 November 2026 the starter and fixed files below were run on this course's Linux build machine with 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.
Checked against official docs: every menu name, command and setting in this practice was checked on 16 November 2026 against the Claude Code VS Code extension page and the permissions and troubleshooting pages on code.claude.com. These tools update often. If a menu name looks different on your screen, search for the same words in the official docs or the Command Palette, and do not guess.

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)

HOW
  1. Create the practice folder with the name shown below, and save the two files from this section inside it.
  2. Create a virtual environment: on macOS or Linux run python3 -m venv .venv. On Windows run py -3 -m venv .venv.
  3. 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.
  4. 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):

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."""
    return meals * PRICE_PER_MEAL

Simple tests test_tiffin_bill.py:

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.txt
Read 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

HOW
  1. Open the folder and a file: in VS Code choose File and then Open Folder, pick marigold-tiffin, and open tiffin_bill.py. The Spark icon appears only when a file is open.
  2. 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.
  3. 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.
  4. 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.
  5. 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.
  6. 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.
  7. 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

HOW
  1. 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.
  2. 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.
  3. 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.
  4. 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.
  5. 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.
  6. 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 claude in a terminal, because it can show a more detailed error.
  7. 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.

PRACTICE CARDAI Coding

Choose Manual mode for practice

Click the mode indicator at the bottom of the prompt box and select Manual.
In Manual mode Claude asks before every file edit and most shell commands, so you see each step.
Ravindra Bagale · ravindrabagale.com/ai-coding
PRACTICE CARDAI Coding

Read the diff before you accept

Claude shows the old code and the new code side by side before it changes the file.
Reject any change to the test file, because the tests describe the correct answer.
Ravindra Bagale · ravindrabagale.com/ai-coding
सराव कार्डमराठी

सरावासाठी Manual mode निवडा

Prompt box च्या खाली mode indicator वर click करा आणि Manual निवडा.
Manual mode मध्ये प्रत्येक file edit आणि बहुतेक commands आधी Claude विचारतो, म्हणून प्रत्येक step तुम्हाला दिसते.
Ravindra Bagale · ravindrabagale.com/ai-coding
सराव कार्डमराठी

Accept करण्याआधी diff वाचा

File बदलण्याआधी Claude जुना आणि नवीन code शेजारी शेजारी दाखवतो.
Test file मधला कोणताही बदल reject करा, कारण tests बरोबर उत्तर काय आहे ते सांगतात.
Ravindra Bagale · ravindrabagale.com/ai-coding

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

SMART AI USE

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.

Save these cards

INTERVIEW CARDAI Coding

What is Claude Code in VS Code?

Anthropic's coding agent as a VS Code panel.
Plans, edits files, runs commands, shows diffs for approval.
Ravindra Bagale · ravindrabagale.com/ai-coding
COMPARISON CARDAI Coding

Claude Code vs Copilot in VS Code

Claude Code: agent + chat panel, plan/manual modes, no inline ghost text.
Copilot: inline ghost text + chat + agent mode.
Ravindra Bagale · ravindrabagale.com/ai-coding
REVISION CARDAI Coding

Setup in 4

Install “Claude Code” → Spark icon → Sign in → Manual/Plan mode.
Rules in CLAUDE.md. Deny .env in settings.json.
Ravindra Bagale · ravindrabagale.com/ai-coding