Skip to main content
guidesSource-backedReview first Safety Privacy

Auto Mode Hard-Deny Policies For Safe Automation

Configure Claude Code auto mode hard-deny rules that block high-risk actions unconditionally, complement soft-deny prompts and team permission policy.

by kiannidev·added 2026-06-13·
HarnessClaude Code
Review first review before installing

Open the source and read safety notes before installing.

Safety notes

  • Hard-deny rules block regardless of user intent or allow exceptions—misconfiguration can halt legitimate workflows.
  • Auto mode classifiers can still fail open with evaluation errors; hard deny is not a substitute for branch protection and CI gates.
  • Do not rely on auto mode alone for secrets handling; deny credential reads and outbound bulk transfers explicitly.

Privacy notes

  • Auto mode classifiers evaluate tool names, arguments, and session context that may include file paths and repository metadata.
  • Denial messages and debug logs can retain snippets of blocked commands; restrict log access on shared machines.
  • Managed settings sync may expose rule text to all enrolled clients—avoid embedding internal codenames you do not want widely visible.

Prerequisites

  • Claude Code with auto mode available on your provider and organization policy.
  • Permission to edit project or managed settings.json for the target repositories.
  • A list of actions that must never run without explicit human approval.
  • Pilot engineers who can trigger both allowed and blocked auto mode actions safely.

Schema details

Install type
copy
Reading time
8 min
Difficulty score
58
Troubleshooting
Yes
Breaking changes
No
Source repository stats
Scope
Source repo
Full copyable content
Add settings.autoMode.hard_deny rules for destructive shell, credential, and exfiltration patterns, test them in a pilot repo, and document how hard denies differ from soft denies and permission prompts.

About this resource

TL;DR

Auto mode lets Claude act with less friction, but some actions should never run unattended. Use settings.autoMode.hard_deny for classifier rules that block unconditionally—regardless of stated user intent or softer allow paths. Pair hard denies with documented soft denies, normal permission rules, and human review for production changes.

Prerequisites & Requirements

  • {"task": "Auto mode enabled", "description": "Organization policy and provider support allow auto mode on pilot repos"}
  • {"task": "Risk inventory done", "description": "Destructive shell, secret access, and bulk exfiltration patterns are listed"}
  • {"task": "Settings path chosen", "description": "Project or managed settings.json is the source of truth"}
  • {"task": "Pilot owners assigned", "description": "Engineers can test blocks without touching production secrets"}
  • {"task": "Escalation documented", "description": "Teams know how to request temporary exceptions through security review"}

Core Concepts Explained

Hard deny vs soft deny

autoMode.soft_deny surfaces friction or prompts where context matters. autoMode.hard_deny blocks matching actions even when the user or skill argues they should proceed—use it for non-negotiable risks.

Classifier complements permissions

Enterprise permissions.deny and managed MCP policies still matter. Auto mode rules add a safety layer for autonomous sessions, especially when bypass-style modes are unavailable.

Defaults can be extended

You can include "$defaults" in autoMode.allow, autoMode.soft_deny, or autoMode.environment to append custom rules without replacing Anthropic's built-in lists.

Evaluation failures need a playbook

When the classifier cannot evaluate an action, sessions may stall. Document retry, /compact, or --debug steps from official release notes rather than disabling auto mode globally.

Step-by-Step Implementation Guide

  1. Inventory non-negotiable blocks. List commands and tools that must never run in auto mode: credential harvesting, rm -rf /, force pushes, arbitrary outbound uploads, and production database mutations.

  2. Draft hard_deny rules. Add entries under settings.autoMode.hard_deny in project settings for the pilot repository. Start narrow—one pattern per real incident or tabletop scenario.

  3. Preserve defaults where needed. If you customize allow or soft_deny lists, include "$defaults" so you extend rather than accidentally remove built-in protections.

  4. Run positive and negative tests. Confirm safe refactors still proceed while tabletop risky prompts are blocked with clear denial messaging.

  5. Align with permissions.deny. Ensure hard denies and static deny rules do not contradict each other; prefer managed settings for org-wide rollout.

  6. Publish escalation policy. Define how engineers request reviewed exceptions and who approves changes to managed hard_deny lists.

  7. Monitor after upgrades. Re-test after Claude Code updates—classifier latency, provider support, and default lists change over time.

Rollout Checklist

  • {"task": "Pilot rules merged", "description": "hard_deny JSON is reviewed and committed to settings"}
  • {"task": "Tests recorded", "description": "Blocked and allowed scenarios are documented with transcripts"}
  • {"task": "Docs updated", "description": "Team runbook explains hard vs soft deny and escalation"}
  • {"task": "Managed sync planned", "description": "Org-wide rollout uses managed settings, not ad-hoc copies"}
  • {"task": "CI unchanged", "description": "Branch protection and security CI remain authoritative"}

Troubleshooting

Legitimate work blocked repeatedly

Move borderline patterns from hard_deny to soft_deny or explicit permission asks after security review—hard deny should stay rare.

"Could not evaluate this action" errors

Follow release-note guidance: retry, compact context, or rerun with debug logging before weakening rules.

Bedrock or Vertex missing auto mode

Some providers require CLAUDE_CODE_ENABLE_AUTO_MODE=1; hard_deny rules only apply once auto mode is actually available.

Rules differ across teammates

Confirm everyone syncs the same managed settings file; local-only edits drift.

Source Verification Notes

Verified against the public anthropics/claude-code repository README and CHANGELOG.md on 2026-06-13:

  • CHANGELOG.md documents settings.autoMode.hard_deny for auto mode classifier rules that block unconditionally regardless of user intent or allow exceptions.
  • CHANGELOG.md notes auto mode support on Bedrock, Vertex, and Foundry with CLAUDE_CODE_ENABLE_AUTO_MODE=1 opt-in for eligible Opus models.
  • CHANGELOG.md documents including "$defaults" in autoMode.allow, autoMode.soft_deny, or autoMode.environment to extend built-in lists.
  • CHANGELOG.md records classifier improvements for data exfiltration detection and fixes for false blocks when evaluation runs out of output tokens.
  • The root README points to GitHub issues at anthropics/claude-code for integration feedback on settings behavior.

Duplicate Check

This guide complements permission-design guides and managed MCP allowlist entries. Those cover static permission modes and MCP governance. This guide focuses on auto mode classifier hard-deny configuration for unattended automation.

References

Source citations

Add this badge to your README

Show that Auto Mode Hard-Deny Policies For Safe Automation is listed on HeyClaude. Paste this Markdown into your README — it renders the badge and links back to this page.

Listed on HeyClaude
[![Listed on HeyClaude](https://heyclau.de/badge/guides/auto-mode-hard-deny-policies-for-safe-automation.svg)](https://heyclau.de/entry/guides/auto-mode-hard-deny-policies-for-safe-automation)

How it compares

Auto Mode Hard-Deny Policies For Safe Automation side by side with 3 alternatives on trust, install, platform support, and disclosed safety notes — all from reviewed registry metadata.

FieldAuto Mode Hard-Deny Policies For Safe Automation

Configure Claude Code auto mode hard-deny rules that block high-risk actions unconditionally, complement soft-deny prompts and team permission policy.

Open dossier
Sandboxed Bash Setup For Autonomous Coding Agents

Enable Claude Code bash sandboxing for autonomous agents: filesystem and network boundaries, auto-allow rules, dependency checks, and fail-closed settings.

Open dossier
Claude Code on Amazon Bedrock Setup

Configure Claude Code on Amazon Bedrock: AWS region resolution, GovCloud inference profiles, credential export caching, service tiers, and CI empty-string pitfalls.

Open dossier
Claude Code on Microsoft Foundry Setup

Configure Claude Code on Microsoft Foundry: Azure auth, idle timeouts, auto mode opt-in, PowerShell tool defaults, and third-party provider messaging.

Open dossier
Trust
Install riskReview firstReview firstReview firstReview first
Notes Safety Privacy Safety Privacy Safety Privacy Safety Privacy
Categoryguidesguidesguidesguides
Sourcesource-backedsource-backedsource-backedsource-backed
Authorkiannidevkiannidevkiannidevkiannidev
Added2026-06-132026-06-132026-06-142026-06-14
Platforms
Claude Code
Claude Code
Claude Code
Claude Code
Source repo
Safety notesHard-deny rules block regardless of user intent or allow exceptions—misconfiguration can halt legitimate workflows. Auto mode classifiers can still fail open with evaluation errors; hard deny is not a substitute for branch protection and CI gates. Do not rely on auto mode alone for secrets handling; deny credential reads and outbound bulk transfers explicitly.Sandboxing reduces blast radius but does not eliminate malicious code—review diffs and keep branch protection enabled. Missing sandbox dependencies previously caused silent disable; use fail-closed settings and verify `/sandbox` status after upgrades. autoAllowBashIfSandboxed auto-approves some commands—pair with deny rules for destructive patterns.Bedrock credentials in shared CI must use OIDC or short-lived role assumption—not long-lived access keys in repos. Auto mode on Bedrock requires explicit `CLAUDE_CODE_ENABLE_AUTO_MODE=1` opt-in on third-party providers. Model picker may list models your account cannot serve—verify access before pinning defaults.Foundry credentials in CI should use federated workload identity—not checked-in client secrets. Auto mode requires `CLAUDE_CODE_ENABLE_AUTO_MODE=1` on third-party providers. PowerShell tool is enabled by default on Windows for Foundry users unless `CLAUDE_CODE_USE_POWERSHELL_TOOL=0`.
Privacy notesAuto mode classifiers evaluate tool names, arguments, and session context that may include file paths and repository metadata. Denial messages and debug logs can retain snippets of blocked commands; restrict log access on shared machines. Managed settings sync may expose rule text to all enrolled clients—avoid embedding internal codenames you do not want widely visible.Sandboxed commands still read repository files within allowed paths; do not store secrets in sandbox-writable directories. Network-allowed domains determine where agent output or tokens might be sent—document allowed egress. Sandbox logs and permission prompts may capture command text including paths and environment variable names.Prompts and tool outputs flow through your AWS account boundary; align with AWS logging and CloudTrail retention. Cross-account `awsCredentialExport` paths may expose role ARNs in `/status` output during debugging. Do not embed customer payloads in prompts when Bedrock logging to third-party observability is enabled.Prompts stay within Azure boundary subject to your logging and diagnostic settings. Welcome banner shows provider name instead of API Usage Billing on third-party providers. Telemetry tips pointing at first-party surfaces are suppressed on Foundry deployments.
Prerequisites
  • Claude Code with auto mode available on your provider and organization policy.
  • Permission to edit project or managed settings.json for the target repositories.
  • A list of actions that must never run without explicit human approval.
  • Pilot engineers who can trigger both allowed and blocked auto mode actions safely.
  • Claude Code on macOS, Linux, or WSL with sandbox dependencies available or installable.
  • Permission to edit project or managed settings.json sandbox blocks.
  • Representative build and test commands your agents run in CI.
  • A rollback plan if sandbox misconfiguration blocks legitimate workflows.
  • AWS account with Bedrock model access for required Anthropic model IDs.
  • IAM role or credential chain reachable from developer laptops and CI runners.
  • AWS region decision documented, including GovCloud if applicable.
  • Network path to Bedrock endpoints through corporate proxy if required.
  • Azure Foundry or Azure AI project with Anthropic model deployment access.
  • Azure AD app, managed identity, or key-based auth approved by security.
  • Regional endpoint and deployment names documented for the team.
  • Windows developers identified if PowerShell tool defaults apply.
Install
Config
Citations
ClaimUnclaimedUnclaimedUnclaimedUnclaimed

Signals

Loading live community signals…

More like this, weekly

A short, calm digest of reviewed Claude resources. Unsubscribe any time.