0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Claude Code の Sandbox を WSL2 で有効にする方法(メモ)

0
Last updated at Posted at 2026-03-21

その他の環境構築まとめはこちら
Claude Code 環境構築・運用Tipsまとめ

はじめに

Claude Code はコマンドを実行するたびに確認ダイアログが出ます。Sandbox を使うと、あらかじめ決めた範囲内では自動実行、範囲外のときだけ確認が来るようになります。

環境

  • Windows 11 + WSL2 (Ubuntu 22.04)
  • Node.js(nvm 管理)

前提条件

  • Claude Code がインストール済みであること
  • nvm で Node.js を管理していること(システム npm の場合はパスが異なる)

手順

1. パッケージをインストール

sudo apt install bubblewrap socat
npm install -g @anthropic-ai/sandbox-runtime  # sudo なしで

2. settings.json にパスを追加

npm root -g  # パスを確認

~/.claude/settings.json に追記します。

"sandbox": {
  "enabled": true,
  "seccomp": {
    "bpfPath": "~/.nvm/versions/node/v24.14.0/lib/node_modules/@anthropic-ai/sandbox-runtime/vendor/seccomp/x64/seccomp.bpf",
    "applyPath": "~/.nvm/versions/node/v24.14.0/lib/node_modules/@anthropic-ai/sandbox-runtime/vendor/seccomp/x64/apply"
  }
}

npm root -g のパスに合わせて書き換えてください。

3. モードを選択

Claude Code を再起動して /sandbox を実行 → 「1. Sandbox BashTool, with auto-allow」 を選択。

動作確認

/sandboxDependencies タブを開いて全項目が green になっていれば完了です。

ripgrep (rg):          found
bubblewrap (bwrap):    installed
socat:                 installed
seccomp filter:        installed  ← ここが重要

Mode タブで (current)Sandbox BashTool, with auto-allow になっていることも確認してください。

ハマりポイント

  • sudo npm install -g だと Claude Code から認識されない → sudo なしで実行
  • docker が失敗する → "excludedCommands": ["docker"] を settings.json に追加
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?