From 371a6af0b40118a34b7bf13863db89007a4e2aba Mon Sep 17 00:00:00 2001 From: christian-westerkam Date: Wed, 21 Oct 2026 00:02:02 +0200 Subject: [PATCH] Sandbox Claude Code to the project folder Enable the Bash sandbox with writes limited to the project, block reads of credential and personal folders, and protect the settings files from edits. git commit/push/fetch/pull run unsandboxed so GPG and SSH work; network git commands always ask first. Co-Authored-By: Claude Opus 5.5 --- .claude/settings.json | 51 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-) diff --git a/.claude/settings.json b/.claude/settings.json index 83b43b2..20edfd7 100644 --- a/.claude/settings.json +++ b/.claude/settings.json @@ -11,7 +11,56 @@ ], "deny": [ "Bash(git push --force:*)", - "Read(./.env)" + "Read(./.env)", + "Read(~/.ssh/**)", + "Read(~/.aws/**)", + "Read(~/.gnupg/**)", + "Edit(.claude/settings.json)", + "Edit(.claude/settings.local.json)" + ], + "blockReadsOutsideWorkingDirectories": true, + "ask": [ + "Bash(git push:*)", + "Bash(git fetch:*)", + "Bash(git pull:*)" + ] + }, + "sandbox": { + "enabled": true, + "autoAllowBashIfSandboxed": true, + "allowUnsandboxedCommands": false, + "filesystem": { + "denyRead": [ + "~/.ssh", + "~/.aws", + "~/.gnupg", + "~/.config", + "~/.docker", + "~/.kube", + "~/.netrc", + "~/Library/Keychains", + "~/Documents", + "~/Desktop", + "~/Downloads" + ], + "denyWrite": [ + ".claude/settings.json", + ".claude/settings.local.json" + ], + "allowRead": [ + "~/.config/git" + ] + }, + "network": { + "allowedDomains": [ + "registry.npmjs.org" + ] + }, + "excludedCommands": [ + "git push:*", + "git fetch:*", + "git pull:*", + "git commit:*" ] }, "hooks": {