Claude Code in VS Code: Install, Connect, and Use It (2026 Guide)
The complete 2026 guide to running Claude Code inside VS Code: installing the official Anthropic extension or the CLI via npm, connecting it to the Anthropic API through a LiteAI key (sk-bf-…, 30 ₽ per 1M tokens, paid in rubles, no VPN), reviewing edits as a diff in the editor, switching between Sonnet 5 / Opus 5 / Haiku 4.5, wiring up MCP servers, and fixing the common failure modes. Covers the top-asked intents: how to use Claude in VS Code, how to connect it, and how to install it.
Claude Code in VS Code: Install, Connect, and Use It
Searches for “vs code claude”, “how to use claude in vs code”, and “connect claude to vscode” have grown steadily: developers are tired of shuffling context between a terminal, an editor, and a browser. The good news — Claude Code works beautifully inside VS Code, either through the official extension that embeds the agent straight into the editor, or through the CLI in the integrated terminal.
This is a step-by-step guide: installation, connecting an API key via LiteAI (30 ₽ per 1M tokens, paid in rubles, no VPN), running it in VS Code, reviewing the diff, choosing a model, and fixing the usual problems.
Why VS Code is a great fit for Claude Code
Claude Code is Anthropic's official agentic CLI. It doesn't care which editor you use, but VS Code adds things a bare terminal doesn't have:
- Integrated terminal (Ctrl+`) — Claude Code runs right where the project is open.
- Diff view for changes — in extension mode, edits show up as a familiar red/green diff inside the editor; accept or revert with one click.
- Editor context — the agent knows which files you have open, and you can pin files into the context explicitly.
- Git integration — after a burst of edits, it's handy to inspect everything in Source Control and commit.
Short version: the terminal is the “muscle”, VS Code is the “hands and eyes”. Let's install it.
Step 1. Install Claude Code
Requirements: Node.js 18+, git, internet access.
Option A: CLI via npm (universal)
npm install -g @anthropic-ai/claude-code
claude --version
If the version prints — the CLI is in. Sanity-check that the binary is on your PATH: which claude (Linux/macOS) or where claude (Windows).
Option B: The official VS Code extension
- Open VS Code → the Extensions panel (Ctrl+Shift+X).
- Find Claude Code (publisher: Anthropic) → Install.
- An icon for Claude Code appears in the activity bar — clicking it opens the agent panel: chat, current task, and the list of modified files.
Under the hood the extension ships the same CLI, but wires it into the editor: diff mode, buttons to accept changes, and starting a task from the project folder. For anyone who wants to live in VS Code without juggling a terminal, this is the shortest road.
Windows-specific bits (PowerShell, ExecutionPolicy, PATH) are covered in Claude Code on Windows — install in 5 minutes.
Now you have the program. It still needs a “brain” — an API key.
Step 2. Get your LiteAI key
Out of the box, Claude Code expects an Anthropic key of the form sk-ant-…, issued from an Anthropic account and billed in dollars. For a developer in Russia that's a pain: no account without a foreign card, no top-up through a Russian BIN, plus a VPN.
LiteAI removes all three hurdles at once:
- Go to the pricing page and pick a pack: from 1M tokens for 30 ₽ — enough for tens of working sessions — up to bulk volumes for a team.
- Pay by whichever method you like — the
sk-bf-…key lands by email and shows up in the Telegram bot @liteaitech_bot. - The key is universal: it unlocks both the Anthropic endpoint (for Claude Code) and the OpenAI-compatible one (for Cursor, Zed, opencode).
Through LiteAI you also get the whole Claude lineup — Sonnet 5, Opus 5, Haiku 4.5, fable-5. The full key-connection walkthrough, both variants (quick and permanent), is in Claude Code with an Anthropic API key — set up in 2 minutes.
Step 3. Connect the key
Two working options: a permanent config (recommended) and per-session env vars.
Permanent: ~/.claude/settings.json
Create or extend ~/.claude/settings.json:
{
"env": {
"ANTHROPIC_BASE_URL": "https://api.liteai.tech/anthropic",
"ANTHROPIC_AUTH_TOKEN": "sk-bf-...",
"ANTHROPIC_MODEL": "claude-sonnet-5"
}
}
Restart VS Code (or just open a new terminal) — from then on claude picks the config up from anywhere.
Per session: export in the terminal
If you'd rather not touch the global config:
export ANTHROPIC_BASE_URL="https://api.liteai.tech/anthropic"
export ANTHROPIC_AUTH_TOKEN="sk-bf-..."
claude
Close the terminal and the variables vanish. Fine for a one-off; for daily use take settings.json.
Which endpoint to use
| Tool | URL | Auth |
|---|---|---|
| Claude Code, official Anthropic SDK | https://api.liteai.tech/anthropic |
x-api-key / ANTHROPIC_AUTH_TOKEN |
| Cursor, Zed, opencode, Cline, OpenAI SDK | https://api.liteai.tech/v1 |
Authorization: Bearer sk-bf-… |
For the “VS Code + Claude Code” combo you always take the first one — it speaks the Anthropic Messages API protocol the CLI was built on, and returns the same SSE events and tool use.
Step 4. Run it in VS Code
Verify:
- Open the project folder in VS Code (File → Open Folder).
- Terminal → New Terminal (or Ctrl+`).
- Type
claudeand hit Enter. - On the first run the CLI asks you to pick a theme and accept the terms — just click through.
- Give it a task, e.g.: “Add logging to the handlers in
src/api, leave the tests alone.”
The agent reads the relevant files itself, makes the edits, and tells you what changed. Now the important part — review the changes with your eyes.
Reviewing the code changes in the editor
In the official-extension mode, Claude Code shows every edit before applying it, as a diff: red for removed lines, green for added ones. The affected files are listed; for each you can open the side-by-side and accept or revert it individually.
In pure CLI mode (no UI) the edits are applied straight to disk, and VS Code itself highlights changed files (unless you were editing them by hand in parallel at the same time). Working loop:
- Give the task → the agent edits the files.
- Open Source Control (Ctrl+Shift+G) → look over the full change list.
- Open each file in diff mode (the icon next to the path in Source Control).
- All good — commit. Not all —
git checkout -- <file>(or the corresponding Source Control button) and fix it by hand.
That way the “blind” fragment the agent generated never slips into production.
Picking a model
One and the same sk-bf-… key unlocks the entire LiteAI catalog. What matters for Claude Code:
| Model | When to take it | Notes |
|---|---|---|
claude-sonnet-5 |
Everyday development: bugs, refactors, code review | The default, best price/quality balance |
claude-opus-5 |
Deep work: architecture, big refactors, tough reviews | Slower and pricier per token — switch to it surgically |
claude-haiku-4-5 |
Routine ops: renames, formatting, templates | The fastest; saves budget on “small stuff” |
Switching on the fly:
- Inside the session:
/model claude-opus-5. - In settings: change
ANTHROPIC_MODELinsettings.json. - For a specific run:
claude --model claude-haiku-4-5.
Working pattern: start on Sonnet 5, and when a task “gets deep” (architecture, multi-file refactor) — flip to Opus 5 just for it. That saves 2–3× in tokens versus “always top model”. The full matrix by task type — in Choosing a Claude model in 2026.
MCP servers in the mix
Separate from the editor, Claude Code can talk MCP (Model Context Protocol) — the standard for plugging in external tools: databases, GitHub, Slack, search. In the VS Code combo it looks like this: the agent reads the DB schema itself, edits the migration, opens the PR.
Start with one — e.g. GitHub MCP, so the agent can open PRs and read review comments. Full walkthrough with configs — in Claude Code MCP servers — complete guide 2026.
Troubleshooting
401 Invalid API Key — nine times out of ten: a stray space or line-break during copy-paste. Make sure sk-bf-… sits on one line, unquoted. Quick check without Claude Code:
curl https://api.liteai.tech/anthropic/v1/messages \
-H "x-api-key: sk-bf-..." \
-H "anthropic-version: 2023-06-01" \
-H "content-type: application/json" \
-d '{"model":"claude-haiku-4-5","max_tokens":64,"messages":[{"role":"user","content":"hi"}]}'
Got JSON back — the key is alive.
claude: command not found — the npm bin didn't land on your PATH. On Windows it's usually a PowerShell/ExecutionPolicy story — step-by-step in the Windows install guide. Linux/macOS: check where npm installs global bins and add that directory to PATH.
Region error / “VPN required” — stale Claude Code version. Upgrade: npm i -g @anthropic-ai/claude-code@latest, then close and reopen the terminal. The LiteAI key isn't IP-bound, so the error disappears after the update.
Answers very slow — you flipped Opus onto small tasks. For routine ops take Haiku; reserve Opus for genuinely deep work. Second point: trim fat from any custom system prompt — every extra token in there multiplies on every call.
Claude Code “thinking” takes too long — not always a hang: the agent is reading files and forming a plan. Signs — blinking cursor in the terminal or a spinner in the extension panel. If it “thinks” for over 2 minutes on a trivial task — check that Opus isn't set for the small stuff, and that the network isn't sagging. If it's a complex task — just wait, that's normal.
Edits “stuck” in the buffer — if you were editing a file by hand while the agent worked on it, the buffer can show a stale version. Save All and revert the file from disk to see the real result.
Claude Code “doesn't see” a file you just created — the agent snapshots the project state when the context starts. If you created a file by hand during work — say so explicitly in the next prompt, e.g.: “I added src/new.ts, account for it.”
Agent “freezes” while waiting for input — sometimes the agent is actually waiting for your answer to a clarifying question and merely looks stuck. Look in the terminal — the question is usually sitting there. Answer it (or Esc to interrupt) and it continues. If the questions never end, hand it a more complete prompt up front.
Agent “thinks” it's done, but the patch never applied — rare: the agent reports “done,” the file hasn't changed. Verify the actual state; if the patch truly went nowhere — rebuild the context (e.g. /compact) and rerun the same command with an addendum: “fact-check that the change was actually persisted.” If that doesn't help, apply it manually.
Patch “stuck” in the extension panel — if edits sit in the queue without applying, the agent was probably interrupted mid-flight. Accept or discard the stuck ones manually, then continue: state which edits are already in and which remain. If the queue keeps piling up, give tasks with “apply one file at a time.”
Model “ignores” your rules in CLAUDE.md — it's not forgetting: the file loads at the start of every session. When a rule seems unenforced it's usually a phrasing issue: too verbose, or buried. Fixes: keep rules short and specific (one item, one line); float critical ones to the top; for tricky rules add an example.
Claude Code “repeats” work already done — a sign the context got muddy: the agent doesn't realise part of the job is finished. Use /compact to condense history; or /clear and restate with a note: “X and Y are done — continue from Z.” For recurring tasks, record the “current state” in CLAUDE.md.
“Tried everything, still broken” — if basics (key, env, version) are done but it still complains, collect facts: exact error, claude --version output, OS, editor. Sometimes the most banal move works: quit VS Code completely and relaunch (not just the terminal). Nuclear option before declaring “everything broke”: recreate settings.json from scratch with only the env block from this article.
Works, but “hangs” on long tasks — for big tasks (architecture, multi-file refactor) the agent legitimately thinks for minutes. Blinking cursor, spinner, periodic intermediate steps are signs of life. Over 3 minutes on a simple task — check model and network; complex — just wait.
Stuck, unclear what's wanted — classic: vague prompt → agent drifts. Stop it (Esc), rephrase concretely (what to change, which files, expected outcome). Bake precise phrasings into CLAUDE.md for regular tasks.
“Half-applied patch” — three different cases — one label, distinct causes:
- Reports done, file has garbage — unclosed brackets, temporary comments. Open the diff, assess the whole edit, stop the agent, prompt: “remove temp artifacts, verify syntax.”
- Reports done, wrong file — edits hit the wrong file/function or didn't apply. Usually the agent lost the thread (long session).
/compact+ rerun with specifics (file, function, expected change), or rephrase with a “before/after” example. - Multi-file series broken mid-flight — some files edited, some not. Non-atomic: the agent “forgot” planned files, or a conflict/error broke the chain. Locate the “freeze point,” remind it of the file list, ask it to reconcile; resolve the conflict and continue. For multi-file edits: ask for the plan first, verify progress per file, lean on git to roll back the “half” and retry.
Claude Code “stuck” on /compact — rare: with a huge session, compaction can take 10–30 s. Normal processing, wait; over a minute — rebuild by hand (Esc → /clear). Prevent: feed tasks in layers.
“Frozen”, stopped responding — cursor blinks, no reaction. Usually not a bug, one of three causes:
- Model “thinking” a hard task (esp. Opus 5) — wait 10–30 s.
- Network request stalled (check connectivity to
api.liteai.tech). - Context overloaded (many files, long history) — Esc, then
/compactor/clear.
Repeat on simple commands — restart the session and try claude --model claude-haiku-4-5.
“Thinking” but not finishing — agent starts reasoning, abruptly cuts off. Causes:
- Hit output
max_tokens— raise it. - Reasoning loop (vague inputs) — clarify.
- Cluttered context —
/compact.
Prevent: raise output limits for long generations, structure prompts tightly.
“Stuck” reading large files — thousands of lines, session visibly “rings.” Normal: model slices and digests. Shorten it:
- Narrow the task (specific function/block, not file-wide sweep).
- Larger-context, faster model (Haiku 4.5 to scan, Sonnet 5/Opus 5 to analyse findings).
- Pre-filter: locate lines via grep/search, cite line numbers in the prompt.
Hundreds-of-KB files — split by line ranges.
Waiting on an MCP tool — request went out to an external service; it's processing. Not a Claude Code hang. Diagnose:
- Which MCP tool it's hanging on (logs).
- Health/availability of that service.
- Healthy but slow → timeouts + plan B.
- Recurring → optimise/batch or raise limits.
Log call durations to spot these early.
First-run “hang” — dependency downloads/init. Normal one-off. Minutes — check network, restart VS Code, clear caches.
Waiting for your decision — agent paused for your choice (approve edit, pick approach). Looks like a hang. Spot it: last message/question is directed at you. Just answer. Reduce such stops: upfront preferences (“default to option A”), defaults for trivial choices.
Waiting on API/model response — session “rings” while agent awaits the LLM API (LiteAI). Seconds for simple, tens of seconds+ for heavy reasoning (Opus 5). Diagnose:
- Simple vs complex delays; if simple commands slow → model/network suspect.
- Ping/timeouts on
api.liteai.tech, 5xx errors. - Recurring → fit model to task, watch API load.
Match model to task, track typical latency, keep Haiku on standby.
“Half-applied series” — stuck mid-run — some files edited, some not. Locate “freeze point” (which files changed), understand cause (thinking / waiting on you / external service), act accordingly (wait/interrupt+retry with “continue from file X”, find the question and answer, check the service). Multi-file series: explicit resume point, checkpoints.
Waiting for your decision, question invisible — agent paused for your pick, question “lost” (scrolled up). Just see a still cursor. Scroll up to find the last question/options list; found — pick; lost — prompt: “what decision do you need from me now?” Prevent: explicit markers (e.g. “DECISION: …”), checkpoints, “state what you're waiting for before pausing.”
Multi-step: waiting at one of several steps — agent ran some steps, paused at one waiting for your pick; confusion about where it stands. Locate the pause (scroll), reconcile completed steps, current step, what's needed. Answer at that step. For long sessions: “step N of M” labelling, clean decision log, checkpoints.
What it costs
Typical 30-minute agentic session (reading files, search, patches, validation) is ~200K–500K tokens. At LiteAI flat rate:
- 200K → 6 ₽
- 500K → 15 ₽
- 1M → 30 ₽
A starter 1M pack is 2–4 real sessions on Sonnet 5 — plenty to evaluate. For constant daily driving step up to 5M (150 ₽). Compare with Claude Pro $20 / Max 5x $100 — fixed message slots, not tokens; an active agent burns those slots in hours. LiteAI bills only actual throughput. The full “how much does it cost / is there a free way” analysis is in Claude Code Free: What Actually Works in 2026.
Summary
Setting up Claude Code inside VS Code with LiteAI is a 5-step walk, total ~10 minutes:
- Install —
npm install -g @anthropic-ai/claude-code, or grab the official Claude Code extension from the Marketplace (Option B, the short path for editor dwellers). - Get a key — buy tokens at 30 ₽/1M;
sk-bf-…by email and via the Telegram bot. - Connect — either drop the two env vars into
~/.claude/settings.json(persistent, recommended), or export them per session (one-off). - Launch in VS Code — open the folder, Ctrl+` →
claude, assign the task. - Review changes — Source Control → open the file diff → commit (or
git checkout -- fileand fix by hand).
No VPN, no foreign card, no account approval — same Sonnet 5 / Opus 5 / Haiku 4.5, and the same one key sk-bf-… reaches Cursor, Zed, opencode, Python and Node SDKs.
Ready to try LiteAI?
An Anthropic API key for Claude Opus, Sonnet and Haiku — in 30 seconds, paid with USDT.