{"slug": "how-to-set-up-claude-code-s-auto-mode-deny-rules-and-hooks", "title": "How to Set Up Claude Code's Auto Mode, Deny Rules, and Hooks", "summary": "Anthropic's Claude Code team has made auto mode the default in the Claude Code terminal and desktop app, using a separate classifier to approve routine commands such as tests and dependency installs while blocking anything it is unsure about, according to Claude Code team member Lydia Hallie. Hallie said Anthropic's own testing found auto mode still lets roughly one in ten risky commands through, so the team recommends deny rules in the settings file as a hard block for irreversible actions like reading a .env file, plus sandboxing to limit which files and network destinations a command can reach. The guidance also covers shrinking Claude.md files for stronger models like Opus 4.5, using hooks that exit with a failure code so Claude must fix problems, and Claude Code Projects, in beta on Pro, Max and Ultra plans, which lets one orchestrator session delegate tasks to sub-sessions.", "body_md": "# How to Set Up Claude Code's Auto Mode, Deny Rules, and Hooks\n\nA practical guide to Claude Code's auto mode, deny rules, sandboxing, and hooks, based on Anthropic's own internal workflow changes.\n\n## What changed in how Anthropic uses Claude Code?\n\nAnthropic’s own Claude Code team has shifted from manually steering and approving every command to running dozens of sessions in parallel and only stepping in where it actually matters. Lydia Hallie, who works on the Claude Code team, described this shift in a talk about how the team’s internal workflow has evolved alongside stronger models like Opus 4.5. The core idea: five things developers used to do by hand (steering, approving, denying, checking, and starting sessions) are now increasingly handled by the model, the harness, or the environment instead of the person typing prompts.\n\n## TL;DR\n\n- **Claude.md files should shrink, not grow** , because strong models like Opus 4.5 follow instructions well enough that all-caps “IMPORTANT” and “NEVER” lines can actually confuse them and produce worse results.\n- **Auto mode** is now the default behavior in the Claude Code terminal and desktop app, using a separate classifier to approve safe commands (tests, installs) automatically while blocking anything it’s unsure about, like pushes outside your trusted repo.\n- **Deny rules are a hard block** in your settings file, meant specifically for irreversible actions like reading a`.env` file, since Anthropic’s own testing found auto mode still lets roughly one in ten risky commands through.\n- **Sandboxing limits blast radius** by restricting which files and network destinations a command can reach, which matters because a compromised dependency can abuse a command you never explicitly denied.\n- **Hooks are scripts that run automatically** after specific actions (an edit, a finished task) and should exit with a specific failure code so Claude is forced to fix the problem instead of marking the task done anyway.\n- **Claude Code Projects** , in beta on Pro, Max, and Ultra plans, lets one orchestrator session delegate a list of tasks to separate sub-sessions and check their results, replacing the habit of juggling many manual chats.\n\n*Enterprises build with AI on Remy.*\n\n- Self-hosted\n- SOC 2\n- HIPAA\n- Audit log\n- Role-based access\n\n## How do you clean up a Claude.md file for stronger models?\n\nThe test Lydia Hallie described is simple: for every line in your Claude.md, ask whether Claude could already figure that out by reading your code. If the answer is yes, the line is probably just adding noise, or worse, actively distracting a model that no longer needs hand-holding. What should stay is information Claude has no way to infer on its own, things like where your business documentation lives, where brand assets are stored, or how your folder structure maps to different parts of a project.\n\nYou don’t have to audit this by hand. Claude Code supports a `/doctor` style prompt audit that checks your Claude.md and any skills files against the model you’re currently running, flagging instructions that are outdated, redundant, or no longer necessary for that model’s capabilities. Running this periodically, especially after upgrading models, keeps your instructions lean and keeps the model focused on your actual code instead of parsing excess guidance.\n\n## What does auto mode actually do?\n\nAuto mode is now the default inside the Claude Code terminal and desktop app, replacing the old binary choice between approving every single command or skipping permissions entirely. It works through a separate classifier that evaluates each command Claude wants to run. Routine, low-risk actions like running tests or installing dependencies execute without interruption. Anything the classifier isn’t confident about gets stopped for human approval, and by default auto mode only trusts your current folder and repository, so a command trying to push to a staging or deployment repo outside that scope gets blocked automatically.\n\nYou configure auto mode in plain English in your settings, describing which repos, buckets, or domains you trust and what should always be allowed or always refused. That configuration is what gets sent to the classifier at decision time. If writing this from scratch feels like a chore, running an automode setup command will draft entries based on your project structure and recent session history.\n\nAccording to internal testing Anthropic published, the gap between human and automated review is large: human reviewers caught only about 14% of clearly dangerous commands in a study, while auto mode caught around 89%. That’s a meaningful improvement, but it also means roughly one in ten bad commands can still slip through auto mode, which is why it isn’t meant to be the only safeguard.\n\n## Why do you still need deny rules if auto mode works?\n\nDeny rules exist specifically for that remaining gap. A deny rule is a hard block written into your settings file, checked before auto mode even gets involved, and it exists for actions you cannot undo. Hallie’s framing is a useful filter: if Claude gets something wrong once, can you take it back? Bad code can be rewritten. A leaked API key or a deleted file often can’t be recovered. That asymmetry is what belongs on a deny list, things like explicitly blocking Claude from ever reading a `.env` file where secrets typically live.\n\n*Enterprises have Remy.*\n\n**⌂** Self-hosted\n\n**✓** SOC 2\n\n**✚** HIPAA\n\n**☰** Audit log\n\nThis logic extends beyond coding. For knowledge work, a rewritten draft is reversible and low-stakes, but sending an email or deleting files is not. The same test applies regardless of what kind of work Claude Code is doing for you.\n\nThe limitation is that a deny rule only sees the command itself, not everything that command triggers. If Claude runs your test suite, that suite can execute arbitrary code you didn’t write, including dependencies. A compromised package buried in that chain could try to read your `.env` file or SSH keys without ever being explicitly denied, because nothing in the command text looked suspicious enough to flag, and a human reviewer would likely have approved it too since there’s nothing obviously wrong to reject.\n\n## What is sandboxing and when should you use it?\n\nSandboxing addresses the gap deny rules can’t cover. Running a sandboxed environment restricts which files a command can open and which network destinations it can reach, regardless of what that command’s text says it’s doing. Even if a dependency is compromised, it physically can’t retrieve files or reach servers outside the sandbox’s permitted scope.\n\nFor longer-running jobs, Claude Code also supports running sessions in the cloud, where the session gets a disposable copy of your code on a separate machine, without your actual keys present, and the task continues running even if you close your laptop. The framing here is that the machine itself is expendable, but outputs that leave it (a commit, a push, a message sent through a connector) are not, so those outputs still need the same deny rules and scrutiny. Those deny rules can be committed directly into your project repository so every future session, cloud or local, picks them up automatically.\n\n## How do hooks make Claude check its own work?\n\nChecks matter because identical prompts can produce very different results. Hallie’s example: asking Claude to migrate a login system to a new API could result in a clean migration, a migration that leaves the old API partially in place, or one that accidentally logs every user out. All three might look fine in a quick glance at the output.\n\nThe fix is giving Claude checkpoints along the way rather than only reviewing the final result. These can be literal tests, screenshots, or more subjective criteria like “does every claim in this report have a source link.” For checks that need to run automatically every time, Claude Code uses [hooks: scripts triggered after specific events](https://goremy.ai/blog/articles/why-your-ai-coding-agent-ignores-rules-and-the-fix), like a formatting check after every edit, or a full test suite before a task is allowed to be marked complete.\n\nThe exit code a hook script returns matters. Many tools default to exiting with a 1 on failure, but Claude Code treats that as the task still completing anyway. To force Claude back into fixing the problem, the hook needs to exit with a 2. Get that wrong and your “check” is just theater, Claude ignores the failure and reports success regardless.\n\n*Enterprises have Remy.*\n\nOn Hallie’s team, every pull request gets reviewed by Claude itself before any human looks at it, using a fresh session (not the one that wrote the code) paired with separate agents specifically checking for bugs. Humans then only review what’s flagged as genuinely risky, while low-stakes changes like documentation can merge automatically once checks pass.\n\n## What are Claude Code Projects?\n\nClaude Code Projects, currently in beta for Pro, Max, and Ultra plans, is Anthropic’s answer to the last manual task: starting and managing individual sessions. Instead of opening a dozen separate chats for a dozen tasks, you give one orchestrator session a full list of work, and it spins up separate sessions for each item, checking the results as they come back. It resembles the established pattern of an orchestrator agent delegating to sub-agents, but structured specifically around managing an entire project’s worth of tasks rather than a single multi-step job.\n\nThis isn’t limited to coding. A project list could include a client report, a research brief, and a batch of content ideas, mixed together under one coordinating session. Because the orchestrator session itself doesn’t write the output, just decides what to delegate and judges what comes back, it benefits from a model suited to planning and evaluation, while the individual task threads can run on a model suited to execution. Claude Code Projects lets you set these separately in project settings.\n\n## Frequently Asked Questions\n\n### What is auto mode in Claude Code?\n\nAuto mode is a default behavior in the Claude Code terminal and desktop app that uses a classifier to automatically approve low-risk commands, like running tests or installing packages, while blocking anything it isn’t confident about, such as actions outside your trusted repository.\n\n### How are deny rules different from auto mode?\n\nAuto mode makes probabilistic decisions and lets some risky commands through. Deny rules are hard blocks written into your settings file that are checked before auto mode runs, reserved for irreversible actions like reading a file containing API keys.\n\n### What exit code should a Claude Code hook use to force a fix?\n\nHooks should exit with a 2 code when a check fails. Exiting with a 1, the common default in many tools, causes Claude Code to mark the task as completed anyway rather than sending it back for correction.\n\n### What is Claude Code Projects used for?\n\nIt’s a beta feature on Pro, Max, and Ultra plans that lets one orchestrator session delegate a list of tasks to separate sub-sessions, checking their outputs, so you manage one coordinating chat instead of many individual ones.\n\n### Does sandboxing replace deny rules?\n\nNo. Deny rules block specific named actions outright, while sandboxing restricts what any command, including ones triggered indirectly through dependencies, can actually access on your file system or network. They address different gaps and are meant to work together.", "url": "https://wpnews.pro/news/how-to-set-up-claude-code-s-auto-mode-deny-rules-and-hooks", "canonical_source": "https://www.mindstudio.ai/blog/claude-code-new-workflow-rules/", "published_at": "2026-11-18 00:00:00+00:00", "updated_at": "2026-11-18 10:44:16.135756+00:00", "lang": "en", "topics": ["ai-agents", "ai-tools", "developer-tools", "ai-safety"], "entities": ["Anthropic", "Claude Code", "Lydia Hallie", "Opus 4.5", "Claude Code Projects"], "also_reported_by": [], "takeaway": "Auto mode's classifier still lets roughly one in ten risky commands through, so pair it with deny rules for irreversible actions like reading .env files and sandboxing to restrict file and network reach.", "recommendation": {"advice": "Keep auto mode on for routine tests and installs, but add deny rules for irreversible actions and sandbox commands, since Anthropic's testing found about one in ten risky commands still pass.", "playbook": "agent-security", "playbook_url": "https://wpnews.pro/playbooks/agent-security"}, "alternates": {"html": "https://wpnews.pro/news/how-to-set-up-claude-code-s-auto-mode-deny-rules-and-hooks", "markdown": "https://wpnews.pro/news/how-to-set-up-claude-code-s-auto-mode-deny-rules-and-hooks.md", "text": "https://wpnews.pro/news/how-to-set-up-claude-code-s-auto-mode-deny-rules-and-hooks.txt", "jsonld": "https://wpnews.pro/news/how-to-set-up-claude-code-s-auto-mode-deny-rules-and-hooks.jsonld"}}