Skip to content

Instantly share code, notes, and snippets.

@shurick81
Last active December 22, 2025 22:04
Show Gist options
  • Select an option

  • Save shurick81/3e658d31ab04f0a75d914e4fe36e85a1 to your computer and use it in GitHub Desktop.

Select an option

Save shurick81/3e658d31ab04f0a75d914e4fe36e85a1 to your computer and use it in GitHub Desktop.
Experiments: Claude Code Installation in Mac

Process Monitoring

Mac and in Windows WSL:

for pid in $(pgrep claude); do
  cmd=$(ps -p $pid -o command= | awk '{print $1}')
  [ "$cmd" = "claude" ] && cmd=$(which claude)
  echo "$pid: $cmd"
done

Windows:

Get-Process claude | Select Path
  • claude code running in a mac terminal: /opt/homebrew/bin/claude
  • claude code running in Mac VS Code Extension: /Users/aleksandr.sapozhkov/.vscode/extensions/anthropic.claude-code-2.0.62-darwin-arm64/resources/native-binary/claude
  • Visual Studio Claude Code extension running in Windows: c:\Users\azureuser\.vscode\extensions\anthropic.claude-code-2.0.75-win32-x64\resources\native-binary\claude.exe
  • Visual Studio Claude Code extension running in Windows opened from WSL: c:\Users\azureuser\.vscode\extensions\anthropic.claude-code-2.0.75-win32-x64\resources\native-binary\claude.exe
  • Visual Studio Claude Code extension running in Windows opened from WSL in dev-container: /root/.vscode-server/extensions/anthropic.claude-code-2.0.75-alpine-x64/resources/native-binary/claude

Check the contents of the HOME variable

Mac:

env | grep HOME

Windows:

$env:HOMEPATH;
  • usual terminal in Macos: HOME=/Users/aleksandr.sapozhkov
  • VS code terminal: HOME=/Users/aleksandr.sapozhkov
  • VS code Claude Code Extension: HOME=/Users/aleksandr.sapozhkov
  • VS code dev container: HOME=/home/vscode
  • VS code Claude Code Extension when running in dev container: HOME=/home/vscode
  • VS code Claude Code Extension in Windows:
image
  • VS code Claude Code Extension in WSL:
image
  • VS code Claude Code Extension in WSL + dev-container:

?

Check Claude Authorization

Mac:

security dump-keychain 2>&1 | grep -i "claude"
  1. Fresh MacOS VM with installed Claude Code and VS with extension
  2. security dump-keychain 2>&1 | grep -i "claude" returns nothing
  3. Running claude code and authenticating using console account
  4. security dump-keychain 2>&1 | grep -i "claude" returns
    0x00000007 <blob>="Claude Code"
    "svce"<blob>="Claude Code"
  1. Running Claude Code Extension in Visual Studio Code

Observed: Claude Code is not requesting authentication

Options or using credit balance

Mac

via ~/.claude/settings.json

contents of ~/.claude/settings.json:

{
  "apiKeyHelper": "~/.claude/anthropic_key.sh"
}

contents of ~/.claude/anthropic_key.sh:

echo 'sk-ant-api03-HIDDEN'
Testing Immediate Effect After Setting the API Helper
  1. Open first Visual Studio Code window.
  2. Open a second window.
  3. Set the key via ~/.claude/anthropic_key.sh.
  4. In the second window, open the Claude Code Extension and make a prompt.

Observed: Claude Code has no credits.

  1. Close second window but not closing the first window.
  2. Open a new window and repeat the prompt.

Observed: Claude Code works as it should.

Conclusion: after setting up new API key via ~/.claude/anthropic_key.sh, we don't need to close all VSCode windows and open again.

via environment variable

echo 'export ANTHROPIC_API_KEY="your-api-key-here"' >> ~/.zshrc

verify:

echo $ANTHROPIC_API_KEY

Inspired by: https://support.claude.com/en/articles/12304248-managing-api-key-environment-variables-in-claude-code#h_93fc3d36f7

Testing Immediate Effect After Setting the Variable
  1. Open first Visual Studio Code window.
  2. Open a separate terminal window.
  3. In the terminal window set the ANTHROPIC_API_KEY variable.
  4. Without closing the first Visual Studio Code window, open a second one.
  5. In the second window, verify in the terminal that the variable is set.
  6. In the second window, open the Claude Code Extension and make a prompt.

Observed: Claude Code has no credits.

  1. Close all Visual Studio Code windows
  2. Open a new window and repeat the prompt

Observed: Claude Code works as it should.

Conclusion: after setting up new API key via environment variable, we need to close all VSCode windows and open again.

In a devcontainer via environment variable

  1. Set the following content in a git repo in .devcontainer/terraform-az-claude-extension/devcontainer.json:
{
  "name": "Dev Container with Claude Code Extension",
  "image": "mcr.microsoft.com/vscode/devcontainers/base:debian",
  "customizations": {
    "vscode": {
      "extensions": [
        "anthropic.claude-code"
      ]
    }
  },
  "remoteEnv": {
    "ANTHROPIC_API_KEY": "${localEnv:ANTHROPIC_API_KEY}"
  }
}
  1. On the host set ANTHROPIC_API_KEY variable
  2. Close all VS Code windows
  3. Open a window with the git repo
  4. Open in devcontainer
  5. Rebuild container
  6. In terminal, verify that the variable is set
  7. Open Claude Code Extension
  8. Ask for any prompt

Observed: Claude Code responds with Invalid API key · Please run /login.

  1. Set contents of .claude/settings.json:
{
  "apiKeyHelper": "echo $ANTHROPIC_API_KEY"
}
  1. Reopen VS Code window and open in devcontainer
  2. Open Claude Code Extension
  3. Ask for any prompt

Observed: Claude Code responds properly

Conclusion: For running Claude Code Extension in devcontainer, we need to use ~/.claude/settings.json.

Setting up

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
cd /opt/homebrew/bin/
ls
PATH=$PATH:/opt/homebrew/bin
cd
touch .zshrc
echo export PATH=$PATH:/opt/homebrew/bin -> .zshrc

softwareupdate --install-rosetta --agree-to-license

brew install --cask docker
brew install --cask claude-code
brew install --cask visual-studio-code

code --install-extension anthropic.claude-code

Testing

  1. Open VS code with any project
  2. Ignore suggestion of opening the project in a dev container
  3. Open claude code extension
  4. Login with any account

Empty dialog

image

Open a new Claude Code session:

image

...

image
  1. Open project in dev container
  2. Open claude code extension
  3. Login with any account

Empty dialog

image

Open a new Claude Code session:

image

Conclusions:

  1. Installing Claude Code is not necessary if the need is only to have Claude Code Extension working in Visual Studio Code.
  2. Authorization of Claude Code extension in host does not remove the need to authorize in dev-container.
  3. Chat history in each dev container is separate from chat histories of other dev containers and from the chat history of the workspace on the host machine.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment