Halloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix NowHalloween DealsAmazon USOctober picks are moving - compare before checkoutAmazon US: current deals, useful picks and tech finds.See Picks×
FREEDOM251

Freedom251 › Blog › Claude Code

How to Configure Claude Code Permissions, Sandboxing, and Secret Protection

By Freedom251 Team · · 10 min read

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The safest Claude Code setup starts with the least-permissive mode that still lets you work: keep default for normal development, use plan for analysis without changes, and grant narrowly scoped rules only when a task needs them. Keep the startup directory at an isolated repository root, add other directories only with --add-dir when they are trusted and necessary, and use a devcontainer or virtual machine when prompts, scripts, or web content could be hostile.

Put allow and deny rules in the correct settings.json, remember that deny rules win, and inspect the effective result with /permissions. Never commit API keys or passwords: inject credentials at runtime through environment variables or secure credential storage, including ${API_KEY} expansion in MCP configuration.

As an Amazon Associate I earn from qualifying purchases.

Choose a permission mode before you start

Claude Code does not have one all-or-nothing security switch. Its permission mode determines how much work can proceed without an interactive approval. Begin with the mode that gives you the smallest useful blast radius, then add individual rules as the workflow proves it needs them.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Mode What it does Best use Main risk
default Keeps approval prompts for operations that need them. Routine development when you want to review commands, tests, and edits. Prompts can become repetitive, encouraging users to approve without reading.
plan Analysis-only operation with a proposed plan; it does not make edits or execute commands. Understanding an unfamiliar repository, scoping a change, or reviewing a proposed approach. You cannot validate a fix by running it until you leave plan mode.
acceptEdits Batches approval for file edits during the session while other operations retain their normal controls. A focused editing session in a trusted checkout where repeated edit prompts slow work. A mistaken instruction can authorize several file changes in one session.
bypassPermissions Skips permission prompts. Only a deliberately controlled, isolated environment with separate safeguards. A prompt, script, or generated command can act without the approval boundary.

For a no-change review, start Claude Code with:

claude --permission-mode plan

Use default as the normal baseline. Treat acceptEdits as a temporary convenience, not a permanent project policy. The command-line option commonly associated with bypassing prompts is --dangerously-skip-permissions; its name is an accurate warning. Avoid it for ordinary development.

#1 Best Overall
Sale
TOZO A1 Wireless Earbuds Bluetooth 5.3 Light Weight in Ear Headphones | IPX5 Waterproof,2 Mics for AI Calls,Immersive Premium Sound Bass Headset with Charging Case,32 EQ via App Black
  • [Ultra-Lightweight Ear Buds Designed for Small Ears] Each earbud weighs only 3.7g and features a compact, ergonomic in-ear design made especially for small ears. Secure, low-profile, and comfortable for workouts, all-day wear or overnight sleeping.The ultra-slim profile sits flush in your ear with no hard edges poking or rubbing, so you can even sleep on your side without discomfort.
  • [Immersive Stereo Sound with TOZO OrigX Technology] TOZO OrigX tuning delivers clear vocals, balanced mids, and natural stereo sound for music, podcasts, and videos.
  • [Long Battery Life for Daily Use] Get up to 7 hours of playtime on a single charge, with up to 32 hours total using the charging case—ideal for workdays, commuting, and extended listening sessions.
  • [Bluetooth 5.3 & Stable Connection] Bluetooth 5.3 provides fast pairing, stable wireless performance, and reduced dropouts as you move around home or office.
  • [Deep Bass with Clear Vocals] High-performance drivers produce punchy bass while keeping vocals clean and detailed for everyday listening.

Understand what Claude Code can access by default

Read-only inspection is the default behavior. Claude Code can inspect the project and, where needed, read libraries and dependencies outside the working directory. Shell commands, tests, and edits require approval unless a rule or selected mode changes that behavior.

Write access is narrower than read access: writes are confined to the directory where Claude Code started and its descendants unless you explicitly grant broader access. Start it at the repository root, or at a deliberately isolated checkout, rather than at a broad home directory. This choice establishes the default write boundary before you add any policy rules.

What the startup boundary means in practice

  • Starting in ~/work/project permits writes in that directory and its subdirectories, subject to permission prompts and rules.
  • A sibling directory such as ~/work/shared-lib is not automatically part of the write scope.
  • Reading an external dependency does not automatically authorize modifying it.
  • A command that reaches outside the repository can still have effects beyond the intended project if you approve it; review the exact command, not only the filename it mentions.

Build a least-privilege policy in settings.json

Use project settings for rules that should travel with a repository, and local settings for developer-specific exceptions. The documented rule form is Tool(optional-specifier). A tool name alone applies broadly; a specifier narrows the match to a command or path pattern.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

A conservative project policy can allow read-oriented work, permit a few predictable command patterns, and deny destructive or network-fetching commands. The following is an illustrative shape using the documented rule syntax; adapt the command and path patterns to the tools your project actually uses:

{
  "permissions": {
    "allow": [
      "Bash(git diff:*)",
      "Bash(git status:*)",
      "Bash(npm test:*)",
      "Edit(docs/**)"
    ],
    "deny": [
      "Bash(rm -rf:*)",
      "Bash(curl:*)",
      "Bash(wget:*)",
      "Edit(.env*)",
      "Edit(**/secrets/**)"
    ]
  }
}

Keep patterns as narrow as the task allows. For example, Bash(git diff:*) is materially safer than allowing every shell command, and Edit(docs/**) does not authorize edits to application code or configuration. Do not treat this example as a universal allowlist: command names, test runners, and sensitive paths differ by repository.

Deny rules override allow rules

If a request matches both an allow rule and a deny rule, the deny wins. Use that precedence to create a safety net around broad workflow allowances. For instance, a project may permit a test command while denying a path that contains production credentials. Place sensitive-file and destructive-command denials deliberately, then test them rather than assuming the pattern matched.

Rank #2
Sale
Smart Watch for Men Women Compatible with iPhone Samsung Android Phone 1.69 inch Full Touch Screen IP68 Waterproof Bluetooh Fitness Tracker Heart Rate/Sleep Monitor (Black)
  • 【IP68 Waterproof Multifunctinal Smart Watch】Torjalph fitness activity tracker smart watch is IP68 waterproof technology ,you can wear it when swimming,handwashing,it's rain-proof which means that you perform multiple exercise modes outside without worrying about sweat or rain corroding your fitness smart watch,and this watch equipped with a 230 mAh large capacity battery magnetic charging ,and this sports activity tracker watch can be used 5-7 days If fully charged.
  • 【Larger 1.83'' Full Screen Watch & Multi-dial Selection】1.83 inch full HD color touch screen smart watch for men / women provides excellent 240*284 resolution image quality ,This Bluetooth smart watch offers a better touch experience and remarkable immersion and ,more than 200 watch faces for you to choose from App"Da Fit ", you can change the dial style according to your mood to wear keeping the world on your wrist
  • 【Accurate Activity Tracker Smart Watch 】sports watch activity tracker uses sweat and dust resistant breathable silicone strap, our Fitness Tracker Smart Watch for Android iOS Phones supports 12 sports modes,walking,running,bicycle,swimming,badminton,basketball,football,rope skipping. This bluetooth calls smart watch for men women is lightweight and stylish, bringing more convenient and relaxing sports experience while also providing more protection.
  • 【Your 24 Hour Personal Daily Health Monitor】Fitness watch for women men full touch screen IP67 waterproof bluetooth smartwatch for Android iOS Phones with heart rate blood pressure monitor multifunction Andriod smart watch with steps counter sleep monitor sports fitness watch, monitoring blood oxygen saturation allows you to understand your physical condition in real time to track fitness progress ,to know your health status in time.
  • 【More Functions Bluetooth Call Smart Watch】This fitness activity smart watch full screen for iPhone and Android phones includes a bunch of new features including:The bluetooth smart watch can hang up the phone, receive and display WhatsAPP /Text /Facebook /Twitter /Messenger reminder.Support sedentary reminder, alarm clock, stopwatch, timer,weather information,music control, remote camera control compatible with Android 5.0 and above or iOS 9.0 and above smartphones.

Review the effective policy

Rules can come from several levels and from command-line choices. In an active session, run:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
/permissions

Review the resulting allow and deny entries, their source, and the operations they cover. This catches a common failure mode: editing one settings file while a higher-precedence file or command-line argument continues to govern the session.

Know which settings file wins

Claude Code applies policy in this order, from highest to lowest precedence:

  1. Enterprise managed policy.
  2. Command-line arguments.
  3. Local project settings in .claude/settings.local.json.
  4. Shared project settings in .claude/settings.json.
  5. User settings in ~/.claude/settings.json.

A lower-level file cannot weaken a higher-level restriction. This makes the arrangement useful for teams: developers can keep personal preferences in user settings, repositories can distribute reviewed defaults, and the organization can enforce non-overridable controls above both.

Enterprise managed-settings.json locations

Managed policy files are installed at these documented locations:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • macOS: /Library/Application Support/ClaudeCode/managed-settings.json
  • Linux and Windows through WSL: /etc/claude-code/managed-settings.json

Use managed settings for controls that must not be bypassed by a project or individual developer. Keep the file owned and distributed by the team responsible for endpoint policy, and review changes through the organization’s normal change-control process.

Rank #3
New Bee Guitar Cable 10ft Electric Instrument Bass AMP Cord | 6.35mm Jack, Durable Design, Stage and Home Studio Use, Low Noise Shielded Electric Cord for Bass, Keyboard, Amp, Mixer
  • [Low Noise High Fidelity] New bee guitar cord with 22AWG oxygen-free-copper center conductors provides enhanced signal transfer, the PVC insulation material and the high-density stranded copper double shield provide noise rejection for quiet operation
  • [Ideal for Choice] New bee 1/4 straight and right angle metal connectors, ensures a secure connection in any instrument, pedal, or amp jack. L shape great fro on stage guitar stands
  • [Wide Compatible] Suitable for mixer, power amplifier, microphone, effector, decoder, equalizer, electoronic organ, electric guitar, electric bass and other electronic equipments. Widely used in the installation of smart home, karaoke speaker, professional stage audio, etc
  • [Easy Disassemble] Making incidental repairs quick and easy! Very nice, flexible cable
  • [Dont Hesite to Order] 24 hours customer services and professional technology team are standing by

Shared versus local project settings

Commit .claude/settings.json when the rules are part of the repository’s expected workflow and have been reviewed. Keep .claude/settings.local.json uncommitted for machine-specific paths or temporary exceptions. Never use a local file as a place to hide a secret; local does not mean encrypted, and it can still be copied, backed up, or exposed.

Expand the sandbox only when the workflow requires it

The default startup boundary is intentionally small. If a build genuinely needs a sibling library or another working tree, add only that directory:

claude --add-dir ../shared-lib

Use one --add-dir path for each required location, and verify that the path is trusted before granting it. Do not add a home directory, a filesystem root, a downloads folder, or a directory that contains unrelated credentials simply to avoid a missing-file error.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

A practical decision test for –add-dir

  1. Identify the exact file or command that failed because it is outside the startup directory.
  2. Confirm that the workflow truly needs that location rather than a copy or generated artifact inside the repository.
  3. Check who can modify the added directory and whether it contains secrets or untrusted files.
  4. Add the narrowest directory that satisfies the dependency.
  5. Run /permissions and review the resulting scope before continuing.

Remove the extra directory from later sessions when it is no longer needed. A temporary expansion should not become a permanent, invisible trust assumption.

Use a devcontainer or VM for hostile or high-impact work

Permission prompts reduce accidental actions, but they are not a complete isolation boundary. Prompts, scripts, generated files, and web content can contain instructions intended to manipulate an agent or a developer. When the input is untrusted, or when a mistake could affect production credentials or the host operating system, put Claude Code inside a devcontainer or virtual machine.

When a stronger boundary is justified

  • You are analyzing a repository downloaded from an unknown source.
  • Build scripts execute installers, code generators, or arbitrary post-install hooks.
  • The task involves web content, issue text, or documents that may contain hostile instructions.
  • The checkout has access to production-like credentials, deployment tools, or sensitive data.
  • You need to experiment with bypassPermissions for a controlled automation job.

Layered isolation

Use several controls together: an isolated checkout, a narrowly scoped startup directory, default approval prompts, restricted network access where practical, and a devcontainer or VM for untrusted work. A container or VM limits host impact, but it does not make secrets safe if you mount them into the environment or print them in logs. Isolation and secret handling must be designed together.

Rank #4
BSIMB 15.6" Digital Family Calendar & Chore Chart, No Subscription Fees
  • Digital Family Calendar: BSIMB digital calendar wall touch screen puts an end to your chaotic life. Designed for busy families, the digital calendar keeps you organised and in step with your family. Assign different colours and tasks to each family member to make family scheduling easier and more intuitive.
  • Easy Setup and Auto-Sync: Plug in, connect to WLAN and auto-syn your electric calendar in minutes. Digital wall calendar compatible with Google calendar, iCloud calendar, Outlook calendar, Cozi calendar and Yahoo calendar. Add events directly on the device or through the ecalendar app. Electronic calendar stays current whether you're at work or traveling—no manual updates needed.
  • All-In-One Home Assistant: Smart calendar builds habits and encourage independence with personalised chores. Display daily meal plan to reduce the daily ‘What's for dinner?’ stress. To-do lists keep track of everything you want. Turning chores into valuable achievements with stars and rewards, making life easier and more enjoyable.
  • Manage Anytime Anywhere: BSIMB electronic calendar for family stay connected with the powerful ecalendar app. Access and manage your digital wall calendar anytime, anywhere with free features like stars & rewards, photo screensaver, chore charts, meals plans, to-do lists etc. Electronic planner paid features like Magic Import tailor advanced tools for users with special needs.
  • Stay in Touch with Loved Ones: Share photos or videos from your phone to electronic wall calendar with app, instantly update your life moment, and keep in touch with your family, especially those who are far away; you can also surprise your smart calendar digital wall by sending him a wish card; it's also great for keeping tech-illiterate elders in touch with the youngsters.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Protect API keys, proxy credentials, and MCP secrets

Do not hard-code passwords, API keys, proxy tokens, or MCP credentials in committed scripts, project settings, prompts, or documentation. A permission policy can restrict what Claude Code does, but it cannot make a literal secret safe after that secret has been committed, copied into a tool output, or printed to a log.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Inject credentials at runtime

Use secure credential storage supported by your operating environment, or export a variable for the session that needs it. In MCP configuration, environment-variable expansion is supported in command, args, env, url, and headers. A committed template can therefore reference a variable without containing its value:

{
  "mcpServers": {
    "internal-api": {
      "url": "https://api.example.invalid/mcp",
      "headers": {
        "Authorization": "Bearer ${API_KEY}"
      }
    }
  }
}

The hostname above is an example placeholder, not a service recommendation. In your own configuration, keep the real endpoint and token outside version control, set API_KEY through an approved secret mechanism, and ensure shell history, CI logs, and diagnostic output do not echo it.

Keep secret-bearing files out of edit scope

Add explicit deny rules for common secret locations such as .env files, credential directories, private keys, and deployment configuration. Match the repository’s actual layout; a generic pattern that misses a differently named file provides false confidence. Also deny commands whose purpose is to print or upload files when the command pattern can be narrowed safely.

Rotate after an exposure

If a key appears in a prompt, tool output, commit, log, or generated artifact, treat it as compromised. Revoke or rotate it through the issuing service, remove the exposed copy from the repository and accessible logs where possible, and inspect related credentials. Changing a permission rule does not invalidate a key that has already leaked.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Configure a team policy without blocking useful work

A team policy should define the minimum access needed by the repository rather than copying one developer’s preferences. Start with a shared .claude/settings.json that allows safe, repeatable inspection and build commands. Add denies for destructive operations and sensitive paths. Enforce organization-wide restrictions in managed settings, then let project settings add narrower allowances that do not conflict with those restrictions.

Suggested rollout

  1. Begin in plan mode and document the commands and directories the workflow actually needs.
  2. Run in default mode and record repeated approval prompts.
  3. Convert only predictable, low-risk prompts into narrowly scoped allow rules.
  4. Add deny rules for destructive commands, network fetches that are not required, and secret-bearing paths.
  5. Review /permissions on a clean checkout and test both an allowed operation and an intentionally denied one.
  6. Commit the reviewed project settings and enforce non-overridable requirements through managed policy.

Review policy changes as code. A new allow rule can enlarge the blast radius even when the change looks like a convenience tweak.

Troubleshoot common permission and sandbox problems

Claude Code keeps asking for the same command

Check whether the command varies by arguments, working directory, or shell wrapper. A rule for Bash(git diff:*) will not necessarily match a different command that performs a similar operation. Use the narrowest stable pattern, then confirm the effective match in /permissions. Do not solve repetitive prompts by switching to bypassPermissions.

An allow rule appears to be ignored

Look for a matching deny rule, because deny takes precedence. Then inspect higher-precedence policy: managed settings, command-line arguments, and local project settings can all change the result. Check spelling, path globbing, and whether the request is using a different tool name than the one in the rule.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

A required file is outside the write boundary

First ask whether the file can be copied or generated inside the repository. If not, restart with a specific trusted directory using --add-dir, and review the expanded scope. Do not grant a broad parent directory merely because one dependency is missing.

A command runs but cannot reach a service

Separate permission from connectivity. An allowed command may still be blocked by the container, VM, firewall, proxy, or missing runtime credential. Verify that the required environment variable is present without printing its value, and check the MCP configuration for correct variable expansion in the field where it is used.

A secret was printed or committed

Stop using the credential, rotate or revoke it, and remove it from future outputs and commits. Search logs and generated files for additional copies. Add a deny rule for the affected path or command, then test the rule in a fresh session. The policy change is preventive; rotation is the immediate response.

Audit checklist before normal work

  • Claude Code starts in the repository root or an intentionally isolated checkout.
  • The session uses default unless analysis-only plan mode is the deliberate choice.
  • No routine workflow depends on --dangerously-skip-permissions.
  • Every --add-dir path is necessary, trusted, and as narrow as possible.
  • Allow rules specify exact command or path patterns instead of whole-tool access where feasible.
  • Deny rules cover destructive commands and secret-bearing paths, and their precedence has been tested.
  • /permissions shows the policy you intended after all settings layers are applied.
  • Project settings contain no literal API keys, passwords, private keys, or proxy tokens.
  • MCP credentials use runtime variables such as ${API_KEY} or an approved secure store.
  • Untrusted repositories and high-impact operations run inside a devcontainer or VM.
  • Team-wide restrictions live in managed settings when developers must not override them.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Claude Codedeveloper securityMCPpermissionssandboxingsecret management

Leave a Reply

Your email address will not be published. Required fields are marked *

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.