Claude Code's permission rules only match the start of a command. A deny rule for rm * doesn't stop r''m -rf x, \rm -rf x or for f in x; do rm $f; done. This template closes that gap and locks down the rest of your machine around Claude.
It's a ready-to-use configuration for macOS and Linux (including WSL2). It runs every shell command in a sandbox, keeps Claude away from your credentials, shows what each session costs, makes Claude check current library docs instead of guessing, and installs a short list of reviewed plugins. Use it as is, or keep the security parts and swap the plugins for your own.
It also ships Claude OS, a local dashboard for your whole Claude setup: every plugin, skill, agent, hook, MCP server, permission rule and memory file, what each session cost, and which skills could run on a cheaper model. Type claude-os in any project folder to open it. It's read-only: every change it suggests is a command you run yourself, so it can't be used to get around the guardrails.
git clone https://github.com/kryo-o/claude-code-setup && cd claude-code-setup && bash install.shImportant
This setup puts security first, not convenience. Claude will run into blocked commands and extra prompts: rm, sudo, eval, pipes into a shell, edits to its own config and to CLAUDE.md, and every git push. That's on purpose. Keep ~/.claude/settings.json as it is, so every project starts locked down. When one project needs more room, loosen it in that project's .claude/settings.local.json (how). Commands the template blocks stay blocked in every project, so run those yourself with ! in front.
Claude reads untrusted text all day: READMEs, issues, web pages, package code and tool output. Any of it can carry instructions that Claude follows (prompt injection), and Claude can also get a command wrong on its own. The template assumes both will happen and limits the damage.
| Attack | Example | What stops it |
|---|---|---|
| Disguised destructive command | r''m -rf ~, a loop around rm, base64 -d | sh |
deny-guard scans the whole command and any script it runs. The sandbox only lets commands write in the project and temp folders |
| Credential theft | Reading ~/.ssh/id_ed25519, ~/.aws/credentials, browser cookies or .env, then sending them out |
Read deny rules, which the sandbox also enforces for shell commands |
| Turning off the guardrails | Writing a project's .claude/settings.local.json to disable the sandbox or add a hook |
Edit deny on Claude Code's config, in ~/.claude and in every project |
| Code that runs later, outside the sandbox | A line in ~/.zshrc, a LaunchAgent, a git hook, core.sshCommand in git config, a changed .mcp.json server |
Edit deny on shell startup files, login items, git and gh config, and .mcp.json |
| Prompt injection that lasts | A note in memory or a rule in CLAUDE.md that every later session follows |
ask rules, so you see each write. The sandbox blocks shell writes to CLAUDE.md |
| GitHub token leak or repo damage | gh auth token, git push --upload-pack=..., gh repo delete, gh api -X DELETE |
deny-guard and deny rules. Every gh command and git push asks first |
| Supply chain | Installing a typo-squatted npm package, a plugin update that swaps in new code | ask rules on package installs. Third-party mods are frozen at reviewed commits |
| Accidents | git push --force, git reset --hard, git clean -fd |
deny rules and deny-guard |
| Default | With this template | |
|---|---|---|
| Shell commands | Ask once, then run with your full user access | Run in a sandbox: writes only in the project and temp folders, filtered network |
SSH keys, cloud credentials, browser cookies, .env files |
No specific rule | Blocked for both file reads and shell commands |
Disguised commands (r''m, loops, eval, base64) |
Deny rules check the start of the command only | deny-guard.sh scans the whole command and any script it runs |
| Package installs | Normal permission prompt | Always asks, even when sandboxed commands are auto-approved |
| Session cost and plan limits | On demand through slash commands | Always visible in the status line |
| Third-party plugin updates | Install whatever the author pushes | Reviewed copies, frozen until you update them |
| Library APIs | From the model's training data | Looked up in current docs with Context7 |
| File | Purpose |
|---|---|
install.sh |
One-command installer: installs Claude Code if it's missing, backs up your settings, installs everything, runs the tests |
install-claude.sh and install-claude-test.sh |
The Claude Code install step and its 6 tests |
merge-settings.jq and install-test.sh |
The settings merge, its tests, and a full installer run against a fake home |
settings.json |
Permissions, sandbox, hook, status line, plugins and marketplaces |
hooks/deny-guard.sh |
Blocks dangerous Bash commands, including disguised ones |
hooks/deny-guard-test.sh and hooks/deny-guard-cases.txt |
99 test cases for the guard |
hooks/statusline.sh |
One-line status: model, context bar, cost, 5h/7d limits, git branch, plugin badges |
claude-md/docs-rule.md |
A CLAUDE.md rule that makes Claude check Context7 before using a library |
mods/vendored-mods/.claude-plugin/marketplace.json |
A local marketplace for frozen copies of third-party mods |
mods/vendored-mods/reflect-mod/ and mods/vendored-mods/cache-tax/ |
The reviewed code of the two third-party mods, with their MIT licenses |
dashboard/ |
Claude OS, a read-only local dashboard of everything installed and what it costs, with 67 tests |
demo/dashboard-gif.sh |
Turns a screen recording of the dashboard into demo/claude-os.gif |
Each layer misses things the others catch.
The sandbox is the actual boundary. With sandbox.enabled: true and allowUnsandboxedCommands: false, every Bash command runs inside the operating system's sandbox: Seatbelt on macOS, bubblewrap on Linux. Commands can only write to the project folder and temp folders, and network access goes through a filter. autoAllowBashIfSandboxed skips most permission prompts, which is safe because the sandbox limits what a command can damage.
Two kinds of commands can't work inside the sandbox. gh needs your GitHub login, and git push, pull and fetch over SSH can't get through the sandbox's network proxy on macOS. excludedCommands runs only these outside the sandbox: git push, pull and fetch, plus the gh subcommands repo, release, pr, issue and api. Any other gh command stays sandboxed and fails without your login. Claude asks before every one of them, so publishing stays your decision.
The exclusion only applies when the command starts with git or gh. A command like cd repo && git push stays sandboxed and fails, so start Claude inside the repo folder. If you'd rather run these commands yourself, delete the excludedCommands line.
These commands run with your full access, so the template blocks everything that could make them run other code or leak your token:
- git options that run a program:
--upload-pack,--receive-packand--exec(including abbreviated forms),git -coverrides, and environment overrides such asGIT_SSH_COMMAND git configkeys that run commands, andgit credentialgh extension,gh alias, thegh authcommands that touch the token, andgh repo deletegh apiDELETE calls and GraphQL mutations- edits to
.git/hooksand.git/config, including those of submodules and worktrees, so Claude can't plant a hook that runs on your next push
| Rule | Covers | Why |
|---|---|---|
Read deny |
SSH keys, cloud credentials, package registry and git tokens, Claude Code's own login on Linux, browser cookies, the keychain, shell history, .env files, iCloud |
Keeps secrets out of Claude's reach |
Bash deny |
rm, sudo, force-pushes, curl | bash |
Destructive, or runs code from the internet |
Edit deny, your machine |
Claude Code's settings, hooks, plugins, mods, skills, agents, commands, rules and global CLAUDE.md; the Claude OS dashboard and its claude-os command; shell startup files; ~/.gitconfig, ~/.config/git, ~/.config/gh and ~/.ssh; login items (~/Library/LaunchAgents on macOS, systemd user units and autostart on Linux) |
Claude can't change its own guardrails or plant code that runs later |
Edit deny, every project |
.claude/settings.json, .claude/settings.local.json, .claude/hooks, skills, agents, commands and rules, and .mcp.json |
Project settings override yours, so one planted file could turn off the sandbox or add a hook |
ask |
Package installs | Dependencies don't get added without you noticing |
ask |
Memories in ~/.claude/projects/*/memory/, and every CLAUDE.md and CLAUDE.local.md |
Every session loads them as instructions, so a prompt injection saved there would last |
Claude Code also applies the Read and Edit deny rules to the sandbox, so shell commands can't read or write those paths either. To change any of the denied files, edit them yourself.
Without these rules, Claude Code only asks before writes to a project's .claude/ folder, and in auto mode a classifier answers instead of you. That's why the template denies these writes outright. The project rules start with //**/ because a rule like **/.claude/... only matches under the folder Claude started in.
Memories and CLAUDE.md files get an ask rule instead of a deny, because you still want Claude to write them. Claude Code otherwise saves memories without asking, and a committed CLAUDE.md reaches everyone who clones the repo. The CLAUDE.md rules match any letter case, because macOS treats claude.md and CLAUDE.md as the same file. sandbox.filesystem.denyWrite stops shell commands from writing them, so every edit goes through the prompt. In headless mode (claude -p), an ask rule acts as a deny, so these writes fail there.
The deny-guard.sh hook covers a gap in those rules. Permission rules only match the start of a command, so for f in x; do rm $f; done or r''m gets past them. The hook searches the whole command, plus any script the command runs, for deletes, eval, base64-decoded commands, pipes into a shell and credential paths. It also blocks the common shell writes to CLAUDE.md (>, tee, sed -i, cp, mv) in any letter case. Text matching can always be worked around, so treat the hook as a speed bump and rely on the sandbox. Run bash ~/.claude/hooks/deny-guard-test.sh to test it.
One quirk: the hook decides which scripts to read by file extension. If a harmless command mentions a .sh or .ts file that happens to contain eval or .env, the hook blocks it.
Plugins and mods run code on your machine, and an update can replace that code with anything. The official Anthropic plugins update normally. The two third-party mods get more access than unreviewed code should have: reflect-mod writes to CLAUDE.md, and cache-tax sends model requests in the background. So this repo ships reviewed copies of their code in mods/vendored-mods/, and the template installs them from a local directory marketplace. Nothing is downloaded from their authors, so an upstream change, or a different release published under the same version number, can't reach you. Each copy is exactly the upstream code at the reviewed commit, and both are MIT licensed.
| Mod | Source | Reviewed commit |
|---|---|---|
| reflect-mod 3.3.0 | bayramannakov/claude-reflect (folder mod/) |
b6c42326903af3dd2bf3772b979730a44d8548ca |
| cache-tax 2.2.1 | karanb192/cache-tax |
06cac47ec125a41a4aeeb78a6b006bec8cc6d6ed |
To move to a newer version, download the new commit, read the diff against the folder in mods/vendored-mods/, replace the folder and update this table. The diff shows up in the commit, so anyone can check what changed.
From Anthropic's official marketplace:
security-guidancewarns about risky code as files are edited and reviews the changes at the end of each turn.claude-securityruns a deep scan on demand and checks each finding before reporting it.mattpocock-skillsadds skills for TDD, debugging, code review, PR writing and more.context7(by Upstash) connects Claude to Context7, a service that serves current, version-specific documentation for libraries. The installer adds a rule to~/.claude/CLAUDE.mdtelling Claude to look up docs there before writing code that uses a library. It works without an account; setCONTEXT7_API_KEYfor higher rate limits. Library names and your doc questions go to Upstash's servers.blast-radiusandreplay-theatercome fromanthropics/claude-code-playground. The first previews what a risky shell command would change; the second replays Claude's edits as diffs.
From the community:
cavemanmakes replies terse, which saves output tokens.ponytailpushes Claude toward the simplest code that works (YAGNI, standard library first).humanizerremoves AI-sounding patterns from prose.reflect-modturns your corrections intoCLAUDE.mdrules, and you approve each one.cache-taxwarns before an expensive resend after the prompt cache expires, and/keepwarmkeeps the cache alive while you're away.
Optional, for specific kinds of work. Delete the ones you don't need from settings.json before step 4:
commercial-legalandprivacy-legal(Anthropic) review contracts, data processing agreements and privacy impact assessments.claude-seoruns SEO audits.nateherk-designbuilds landing pages that animate as you scroll.
Opus | ████░░░░░░ 42% | $1.50 | 5h:12% 7d:30% | ⎇ main | [CAVEMAN] | [PONYTAIL]
It shows how full the context window is, what the session has cost and how much of your plan's usage limits you've used, so a runaway session is easy to spot. It finds the plugin badges by searching the plugin cache, so they survive plugin updates. It needs jq, which comes with macOS 15 and later; on Linux, install it with your package manager.
A local web page that shows everything Claude Code has installed: settings layers and which file each permission rule comes from, plugins (frozen or auto-updating), skills ranked by size with the model each one is pinned to, agents, commands, hooks, MCP servers, CLAUDE.md and memory files, and the cost of every session. It also shows how much you paid when an idle chat's prompt cache had gone cold. It needs only Python 3.
The installer copies it to ~/.claude/claude-os and adds a claude-os command to ~/.local/bin. Run it in your own terminal, not through Claude:
cd ~/projects/my-app && claude-os # opens the dashboard for this project in your browser
claude-os --mask # hides your username, paths, project names and own skillsclaude-os adds the current folder's settings, skills and MCP servers to the view, and works from any folder. Press Ctrl+C to stop it. Use --mask for screenshots and screen recordings. It replaces your username, paths, project names and the names of your own skills, agents and MCP servers with generic ones. It keeps public plugin names and every number, and drops proposals that would quote your own files. Without the installer, run python3 -I dashboard/serve.py --open from this repo.
The launcher and the dashboard code run outside the sandbox when you start them, so Claude may not edit either of them. Otherwise Claude could plant code that runs with your full access the next time you open the dashboard.
The dashboard never changes anything. Each change it suggests (turn a plugin off, pin a skill to a smaller model, allow an ask rule in one project) comes as a command or diff for you to apply, so the guardrails above stay in place. A dashboard that could write ~/.claude/settings.json would be a way around them. The server listens on 127.0.0.1 only, needs the random token from the printed link, refuses other host names, answers GET only and serves no files from disk. It never opens .env files, credentials, keys or shell history, never keeps message text from transcripts, and strips secret-shaped values from what it shows.
What it can't see: claude.ai projects, connectors and cloud routines (your claude.ai skills do show up, from ~/.claude/skills/synced), and how many tokens each MCP server's tool list costs per chat. For that, run /context in Claude Code. Session costs come from Claude Code's own record; sessions without one are estimated from list prices and marked ~.
Run its tests with python3 -I -m unittest discover -s dashboard/tests -t dashboard. Add CLAUDE_OS_SMOKE=1 to also scan your real ~/.claude.
git clone https://github.com/kryo-o/claude-code-setup && cd claude-code-setup && bash install.shThe installer needs git, jq and rsync. If Claude Code isn't installed, it offers to install it with Anthropic's installer from https://claude.ai/install.sh. It downloads the script in full over HTTPS before running it, so a cut-off download can't run half a script. On Linux it also needs bubblewrap and socat, which Claude Code's sandbox uses; on Debian or Ubuntu, install everything with sudo apt install jq rsync bubblewrap socat. It backs up your current settings.json with a timestamp, asks before installing the two third-party mods from their reviewed copies in this repo, adds the Context7 rule to ~/.claude/CLAUDE.md without touching your existing rules, installs every plugin, installs Claude OS and its claude-os command, and runs the guard tests.
Running it again is safe, because it merges the template into your settings.json instead of replacing it. Your own settings stay: model, effort, output style, environment variables, extra plugins, marketplaces, hooks and permission rules. A plugin you turned off stays off. The sandbox, the status line, the deny-guard hook and every template permission rule come from the template, and your extra rules are added to them. Three settings that switch the guardrails off are removed, and the installer lists each one it removes: disableAllHooks, skipDangerousModePermissionPrompt and permissions.defaultMode: bypassPermissions.
When the installer has no terminal to ask (for example when you run it with ! inside Claude), it keeps the third-party mods you already have instead of removing them.
These are the same steps the installer runs.
Clone this repo. Back up your current ~/.claude/settings.json if you have one. Make sure jq is installed, since the settings merge, the install loop and the status line all use it. On Linux, the sandbox also needs bubblewrap and socat. Install Claude Code if it isn't there yet (Anthropic's installer puts claude in ~/.local/bin):
which jq || brew install jq # macOS
sudo apt install jq rsync bubblewrap socat # Debian/Ubuntu
command -v claude || { curl -fsSL https://claude.ai/install.sh -o /tmp/claude-install.sh && bash /tmp/claude-install.sh; }mkdir -p ~/.claude/mods
git clone https://github.com/anthropics/claude-code-playground ~/.claude/mods/claude-code-playgroundRun this from inside this repo's folder. It installs the reviewed copies that ship in this repo:
V=~/.claude/mods/vendored-mods
mkdir -p $V
for m in reflect-mod cache-tax; do rsync -a --delete --exclude .in_use mods/vendored-mods/$m/ $V/$m/; doneRun these from inside this repo's folder:
cp -R mods/vendored-mods/.claude-plugin ~/.claude/mods/vendored-mods/
mkdir -p ~/.claude/hooks && cp hooks/* ~/.claude/hooks/ && chmod +x ~/.claude/hooks/deny-guard.sh
jq --arg h "$HOME" 'walk(if type == "string" then gsub("__HOME__"; $h) else . end)' settings.json > /tmp/template.json
[ -f ~/.claude/settings.json ] || echo '{}' > ~/.claude/settings.json
jq -n --slurpfile user ~/.claude/settings.json --slurpfile tpl /tmp/template.json -f merge-settings.jq > /tmp/merged.json
jq -r '.dropped[]' /tmp/merged.json # what the merge removed or replaced
jq '.settings' /tmp/merged.json > ~/.claude/settings.json
cat claude-md/docs-rule.md >> ~/.claude/CLAUDE.mdThe merge keeps your own settings and makes the security settings follow the template, as described under Quick install.
Don't count on the prompts Claude Code shows at first start. Copying settings.json on its own can leave plugins half-installed, and some (caveman and ponytail, for example) then fail on startup. This loop reads both lists from your new settings.json, removes any existing copy of each plugin and installs it again. If plugins break later, run it again:
S=~/.claude/settings.json
claude plugin marketplace add anthropics/claude-plugins-official # usually already there
for m in $(jq -r '.extraKnownMarketplaces[].source | .repo // .path' $S); do
claude plugin marketplace add "$m"
done
for p in $(jq -r '.enabledPlugins | to_entries[] | select(.value == true) | .key | select(endswith("@builtin") | not)' $S); do
claude plugin uninstall "$p" 2>/dev/null
claude plugin install "$p"
doneYou can ignore "already added" and "not installed" messages. Each install line should end with ✔ Successfully installed.
Run these from inside this repo's folder:
rsync -a --delete --exclude tests --exclude __pycache__ --exclude .claude --exclude .gitignore dashboard/ ~/.claude/claude-os/
mkdir -p ~/.local/bin
printf '%s\n' '#!/bin/bash' 'exec python3 -I "$HOME/.claude/claude-os/serve.py" --project "$PWD" --open "$@"' > ~/.local/bin/claude-os
chmod +x ~/.local/bin/claude-osbash ~/.claude/hooks/deny-guard-test.sh # should print: all cases pass
claudeIn Claude Code, run /plugin and check that every plugin listed in settings.json is installed (15 if you kept them all). The status line should appear at the bottom of the screen.
The rules in ~/.claude/settings.json are strict on purpose. Leave them as they are: they're the safe default every project starts from, and Claude can't change them. When one project needs more room, loosen it in that project's .claude/settings.local.json. Claude Code keeps this file out of git, it only applies to that project, and it takes precedence over your user settings. For example, to let Claude fetch your team's docs and use a sibling folder:
{
"permissions": {
"allow": ["WebFetch(domain:docs.example.com)"],
"additionalDirectories": ["../shared-lib"]
}
}Use .claude/settings.json instead for rules the whole team should share through git.
What a project file can't do:
- Remove a
denyrule or skip anaskrule from your user settings. A deny rule wins wherever it's defined, and an ask rule still prompts even when a projectallowrule matches. When you need a blocked command, run it yourself with!in front, for example! rm -rf build. - Be written by Claude. This template denies
Editon every project's.claude/settings.json,.claude/settings.local.json,.claude/hooks,skills,agents,commands,rulesand.mcp.json. Write these files yourself, or add rules with/permissions, which Claude Code saves without going through Claude's tools.
A project file can still turn the sandbox off or add hooks, so keep these files short and read them before you commit. When you open a cloned repo, Claude Code asks you to trust the folder before it uses that repo's .claude/settings.json. Read the file before you say yes.
Copy settings.json, CLAUDE.md, hooks/ and mods/ from ~/.claude. Leave out plugins/cache and plugins/marketplaces. On the new machine:
- Unzip into your home folder.
- If your username is different, fix the paths:
sed -i.bak "s#/Users/OLDNAME#$HOME#g" ~/.claude/settings.json(on Linux the old path starts with/home/). - Run the step 4 loop to install every plugin.
- Works on macOS and Linux, including WSL2 (WSL1 has no sandbox support). The permission rules cover both systems' credential paths: Keychains and
Library/Application Supporton macOS;~/.configbrowser profiles,~/.mozilla, GNOME keyrings andpasson Linux. Rules for paths that don't exist on your system do nothing. - On Ubuntu 24.04 and later, AppArmor stops bubblewrap from working until you add a profile for it. See Set up Linux and WSL2 in the Claude Code docs;
/sandboxin Claude Code shows whether anything is missing. - Linux support is newer and less tested than macOS. Please report problems with the bug report form.
- The status line script and the hook live in
~/.claude/hooks/, which the sandbox never lets shell commands write to. Both run outside the sandbox with your full access, so they must not be editable by a sandboxed command. cache-taxpings andsecurity-guidancereviews are model calls, so they count toward your plan's limits.- Keep the sandbox on. The hook and the permission rules can be worked around; the sandbox is what actually limits damage.
This template only wires things together. The plugins are other people's work, so if one helps you, star its repo:
- caveman by Julius Brussee
- ponytail by Dietrich Gebert
- humanizer by blader, based on Wikipedia's Signs of AI writing guide by WikiProject AI Cleanup
- claude-reflect (reflect-mod) by Bayram Annakov
- claude-code-mods (cache-tax) by Karan Bansal
- skills by Matt Pocock
- Context7 by Upstash
- claude-seo by AgriciDaniel
- scroll-craft by Nate Herk
- claude-code-playground, claude-for-legal, and the official marketplace plugins
security-guidanceandclaude-securityby Anthropic
Only reflect-mod and cache-tax are frozen at a reviewed version. Every other plugin and skill this template installs comes straight from its author's repository and can update when the author pushes a new version. That includes the community plugins (caveman, ponytail, humanizer, claude-seo, nateherk-design) and third-party plugins listed in Anthropic's marketplace (mattpocock-skills, Context7). Whether an update installs automatically depends on each marketplace's auto-update setting.
An update can change what a plugin does on your machine, and nobody behind this template reviews those updates. Keeping auto-update on is your decision and your risk. To check each version before it installs, open /plugin in Claude Code, go to Marketplaces, and turn off auto-update for the marketplaces you don't fully trust. Or freeze those plugins the same way this template freezes reflect-mod and cache-tax.
This template is provided as is, without warranty of any kind (see the MIT LICENSE). You are responsible for what you install and run.
MIT. See LICENSE. The plugins and mods this template installs keep their own licenses. Changes between versions are in CHANGELOG.md.

