Day 3, 30 minutes · advanced
Why it matters
When you are not watching, two things go wrong. Claude stops to ask for something harmless, and nothing happens until you come back. Or it does something you would have said no to, and nobody was there to say it. Good settings fix both: routine steps run without a prompt, and the few things that must never happen are locked, whatever Claude decides.
In Claude Code 101 you added one deny rule. Today you go further. You learn where settings live and which file wins, write a small set of allow, ask and deny rules for the practice project, and see how auto mode and the sandbox fit around them.
The most important rule of the day: Claude may not edit its own check. A run that can change the test can always make the test pass. At the end Ines's project has a shared settings file in git that lets her check and commit run without prompts and blocks pushes and changes to check.sh.
Where settings live and which file wins
The settings page lists four places:
| Scope | File | Who it affects |
|---|---|---|
| User | ~/.claude/settings.json |
You, in every project on this computer |
| Shared project | .claude/settings.json |
Everyone who works in the project, once you commit it |
| Project local | .claude/settings.local.json |
You, in this project only. Claude Code keeps it out of git when it creates it |
| Managed | set by your organization | Everyone it is deployed to |
When the same setting is in several files, the order is: managed first, then the command line, then project local, then shared project, then user. Lists such as permissions.allow are combined across files instead of replaced.
/status shows which files loaded, on its Setting sources line. /permissions lists every rule and the file it comes from. When you choose "Yes, and don't ask again" for a command, Claude Code saves that as an allow rule in the project local file.
Allow, ask and deny
The permissions page checks rules in a fixed order: deny, then ask, then allow. The first match wins. A narrow allow rule cannot make an exception to a broad deny rule. Today's file:
{
"permissions": {
"allow": ["Bash(git check)", "Bash(git add *)", "Bash(git commit *)"],
"ask": ["Bash(git reset *)"],
"deny": ["Bash(git push *)", "Edit(/check.sh)"]
}
}
Bash(git check)with no*matches exactly that command.Bash(git add *)matchesgit addwith anything after it. Put the*after the subcommand:Bash(git *)would match every git subcommand.- An ask rule makes Claude Code ask even in auto mode. In
dontAskmode, which you meet in lesson 5, it is refused. - A deny rule holds in every mode, including auto and bypass permissions.
Edit(/check.sh)blocks Claude's file tools from changingcheck.sh. In a project settings file, a path that starts with/starts at the project folder.
Two limits. First, allow rules in a shared project file only work after you accept the trust question for the folder; deny and ask rules work at once. Second, rules match tool calls, not intent. An Edit rule also covers some shell commands Claude Code can read, such as sed and tee, but not a script that opens the file itself.
On Windows: with Git for Windows installed, any Bash deny rule also turns off Claude Code's PowerShell tool. So the Bash(git push *) rule means Claude runs every command through Git Bash, and your Bash rules cover all of them.
Auto mode and the sandbox
New terminal sessions start in auto mode when it is available. A separate classifier model reviews each action before it runs. The permission modes page is clear about its limits:
- It reduces prompts but does not guarantee safety. It is a judgement, and it can be wrong.
- After 3 blocks in a row or 20 in total, it goes back to asking you.
- "Don't push yet" in the chat works as a boundary, but it is re-read from the conversation and can be lost when the conversation is compacted. Anything that matters belongs in a deny rule.
The sandbox is a second layer, enforced by the operating system around the shell commands Claude runs: which files they can write and which websites they can reach. You turn it on with /sandbox. It works on macOS, Linux and WSL2. On native Windows, commands run without it. It covers shell commands only; Claude's file tools follow your permission rules.
The steps
- Start in Manual mode, so you see what still asks.
- Ask Claude to write the shared settings file. Claude Code asks before any write to the
.claudefolder. - Read the rules back with
/permissionsand/status. - Test the allow rule, then the deny rules, in Manual and in auto mode.
- Commit the settings file so it travels with the project.
- Write a rule map: one line per rule with the reason.
Follow the steps for Claude Code below.
Example: Ines's rule map
"git check, add, commit: allowed, routine. git reset: ask, it can throw work away. git push: never during unattended work. check.sh: never, the worker may not change the test." When she asked Claude to make Status: lent pass by changing check.sh, Claude Code blocked the edit and Claude fixed the card instead.
Common mistakes
- Putting a team rule in your local file. It works for you and nobody else. Shared rules go in
.claude/settings.jsonand into git. - Relying on auto mode for a "never". Use a deny rule.
- Allowing
Bash(git *). That allows every git command, push included. Keep allow rules narrow.
Today's actions
Ticks are not saved without an accountDo it in Claude Code
Claude Code
- Start Claude Code in your practice folder in Manual mode, so you see every prompt.
cd kettleby-tools claude --permission-mode manual - Ask Claude to write the shared settings file. Claude Code asks before it writes in the
.claudefolder: check the content and choose Yes.Create the file .claude/settings.json with exactly this content, and change nothing else: { "permissions": { "allow": ["Bash(git check)", "Bash(git add *)", "Bash(git commit *)"], "ask": ["Bash(git reset *)"], "deny": ["Bash(git push *)", "Edit(/check.sh)"] } } - Type
/permissionsto see each rule and the file it comes from, then press Esc. Type/statusand find theSetting sourcesline, then press Esc. - Test the allow rule. In Manual mode,
git checknow runs without a prompt.Run git check and show me the output. - Test the deny rule on the check. Claude Code blocks the edit. If Claude then asks to change the file with a shell command, choose No.
Change check.sh so that Status: lent also passes. - Press Shift+Tab until the bar shows
auto mode on(if auto mode is available to you), then test the push rule. Claude Code refuses it in this mode too.Push this branch to origin. - Ask Claude to commit the settings file. This runs without a prompt because of your allow rules. Then type
/exitand write your rule map.Commit .claude/settings.json with the message: Add permission rules for unattended runs.
Note: On some Windows setups the mode key is Alt+M instead of Shift+Tab. On Windows with Git for Windows, the Bash(git push *) deny rule also turns off the PowerShell tool, so Claude runs every command through Git Bash. The practice project has no remote, so the push would fail anyway; the point is that the rule stops it first. /sandbox works on macOS, Linux and WSL2 only.
Paid planNeeds a paid Claude plan (Pro, Max, Ultra, Team or Enterprise) or a Claude Console account. The free Claude plan does not include Claude Code.
Create a free account to save your progress
Free, and no payment details. Your ticks and finished lessons are kept, on every device.
Create a free account I already have an accountCreate a free account to save your progress. Sign in or sign up