C.W.K.
Stream
Lesson 03 of 06 · published

VS Code Remote, Dev Containers, WSL

~14 min · remote, vscode, dev-containers, wsl

Level 0🌱 Novice
0 XP0/70 lessons0/11 achievements
0/120 XP to next level120 XP to go0% complete

Same session, native IDE

Claude Code integrates with VS Code's Remote family — Remote-SSH, Remote-Containers, Remote-WSL. When VS Code is connected to a remote, Claude Code automatically resolves file paths against that remote, runs terminal commands there, and uses the remote's MCP configuration. The session stays coherent with where the code lives.

The two integration patterns: (a) Remote-SSH — VS Code SSHes into a host, you open a terminal in VS Code which is already on the remote, you run claude there. (b) Dev Containers — Claude Code is installed via postCreateCommand and your ANTHROPIC_API_KEY is forwarded via localEnv so it never lives in the container's source.

WSL2 is a third target: install Claude Code inside the WSL distro, connect VS Code via Remote-WSL, and the same workflow applies. Path translation is automatic.

Code

Dev Container with Claude Code·json
// .devcontainer/devcontainer.json
{
  "name": "My Dev Container",
  "image": "mcr.microsoft.com/devcontainers/typescript-node:20",
  "postCreateCommand": "npm install -g @anthropic-ai/claude-code",
  "remoteEnv": {
    "ANTHROPIC_API_KEY": "${localEnv:ANTHROPIC_API_KEY}"
  },
  "customizations": {
    "vscode": {
      "extensions": ["anthropic.claude-code"]
    }
  }
}
Multi-root workspace + Remote·json
// myproject.code-workspace
{
  "folders": [
    { "path": "/home/ubuntu/backend" },
    { "path": "/home/ubuntu/frontend" },
    { "path": "/home/ubuntu/shared-lib" }
  ],
  "settings": {
    "claude.remote.includeAllRoots": true,
    "claude.remote.compactBeforeHandoff": true,
    "claude.remote.preferSSHConfig": true
  }
}

External links

Exercise

Create a .devcontainer/devcontainer.json for one of your repos that installs Claude Code via postCreateCommand and forwards your API key via localEnv. Reopen the repo in the container. Run claude inside. Confirm it works without your key being in the file.

Progress

Progress is local-only — sign in to sync across devices.
Spotted a bug or have feedback on this page?Report an Issue

Comments 0

🔔 Reply notifications (sign in)
Sign inPlease sign in to comment.

No comments yet — be the first.