Why won't Claude Code auto-approve writes to .git, .claude or .bashrc, even in acceptEdits with an Edit(.claude/**) allow rule?
answer
- repository state and Claude's own config
- checked before allow rules from settings
- a per-mode outcome table
- only bypass writes them silently
- session-scoped option for .claude
basics
~20 sThose are protected paths: writes to them are never auto-approved, outside bypassPermissions, because they hold repository state, shell startup files and Claude's own configuration. The check runs before allow rules from settings, so Edit(.claude/**) changes nothing.
solid answer
~40 sClaude Code keeps a list of **protected paths**, such as `.git`, `.claude`, `.vscode`, `.husky` and files like `.bashrc`, `.zshrc`, `.gitconfig`, `.npmrc` and `.mcp.json`, whose writes are never auto-approved, to prevent corrupting repository state or Claude's own configuration. The safety check runs **before** allow rules from settings files, so `Edit(.claude/**)` does not pre-approve anything. Per mode: Manual and `acceptEdits` prompt, `auto` routes the write to the classifier, `dontAsk` denies, and `bypassPermissions` allows; plan mode allows only in interactive terminal sessions with bypass available. In prompting modes, a write to the project's `.claude/` or to `~/.claude/` can offer a session-scoped 'allow edits to this folder' option. `.claude/worktrees` and Claude's auto-memory markdown are exempt.
go deeper
Recall a few protected paths, such as .git, .claude and .bashrc, and that Claude Code asks before writing them.
Explain the per-mode table and why an allow rule in settings cannot pre-approve these writes.
Show the security reasoning: these files run code or govern Claude itself, so checked-in rules must not open them, and bypass removes the guard.
Judge where a team's automation must touch protected config and route that work to a reviewed, out-of-band path instead of loosening modes.
## What a protected path is A **protected path** is a file or directory whose writes Claude Code never auto-approves, except in `bypassPermissions` mode and in interactive terminal sessions in plan mode with bypass permissions available. The list exists to prevent accidental corruption of **repository state** and of **Claude's own configuration**, and many entries are files that execute code later: git hooks, shell startup files, package-manager config. Protected directories: - `.git`, `.config/git`, `.husky` - `.vscode`, `.idea`, `.devcontainer` - `.cargo`, `.yarn`, `.mvn` - `.claude`, except `.claude/worktrees` and the markdown files in Claude's auto-memory directory (in sessions started without `--restricted`) - a directory loaded with `--plugin-dir`, because its code is reloaded and run when a file changes Protected files include `.gitconfig` and `.gitmodules`; shell startup files such as `.bashrc`, `.bash_profile`, `.zshrc`, `.zshenv`, `.profile` and `.envrc`; package-manager files such as `.npmrc`, `.yarnrc.yml` and `.pnpmfile.cjs`; hook managers such as `.pre-commit-config.yaml` and `lefthook.yml`; build wrappers such as `gradle-wrapper.properties`; and `.mcp.json` and `.claude.json`. ## Why an allow rule doesn't help `permissions.allow` rules in settings files **do not pre-approve protected-path writes**. The safety check runs before Claude Code evaluates allow rules from settings, so an entry such as `Edit(.claude/**)` in `~/.claude/settings.json` or `.claude/settings.json` does not change the outcome. That ordering is the point: if a rule in a checked-in file could open `.claude/` or `.git/hooks`, a repository could grant itself the right to rewrite its own guard rails. What you can do in a prompting mode is answer the prompt. For the project's `.claude/` folder the prompt can offer **Yes, and allow Claude to edit files in this project's .claude folder for this session**, and for `~/.claude/` a matching option; both last only for the session. ## The outcome in each mode | Mode | Protected-path writes | | :- | :- | | `default`, `acceptEdits` | Prompted | | `plan` | Allowed in interactive terminal sessions with bypass available; otherwise routed to the classifier when auto is available during planning, prompted when it isn't | | `auto` | Routed to the classifier, even when an allow rule matches | | `dontAsk` | Denied | | `bypassPermissions` | Allowed | Two refinements: 1. **Symlinks.** In the modes that route protected writes to the classifier, a write whose requested path is not protected but which the symlink check resolves to a protected path prompts you instead. 2. **`--restricted`.** In a session started with `--restricted`, the classifier cannot approve protected-path writes. ## Protected paths versus critical paths A neighbouring safeguard is easy to confuse with this one. **Critical paths** are about `rm` and `rmdir`: removals aimed at the filesystem root, top-level directories, your home directory or your working directory and its parents. No allow rule and no `PreToolUse` hook `"allow"` approves them; Manual and `acceptEdits` ask, `dontAsk` denies, and even `bypassPermissions` asks. Protected paths are about **writes** to specific config locations and are the one thing `bypassPermissions` does let through. ## Diagnosing an unexpected prompt When a write prompts in a mode you expected to be quiet, work through it in order: 1. Is the target, or the place a symlink resolves to, on the protected list? If so, the prompt is the design, not a missing rule. 2. Is the target outside the working directory and `additionalDirectories`? `acceptEdits` only auto-approves in-scope paths. 3. Is it an `rm` or `rmdir` aimed at a critical path? That is a different check with its own per-mode outcomes. 4. Only then look at your permission rules; an ask rule that matches also forces a prompt in every mode. ## Practical consequences - If you want Claude to edit your project's `.claude/settings.json` or a skill under `.claude/`, expect a prompt in Manual or `acceptEdits`, or a classifier review in auto; choose the session-scoped option rather than hunting for a rule. - In `dontAsk`, a task that needs to change `.husky` hooks or `.pre-commit-config.yaml` is denied by design; make that change outside the run. - Do not treat `bypassPermissions` as a fix for these prompts on a workstation; it removes this guard along with the rest, which is why it belongs in an isolated environment.
- How do critical paths differ from protected paths in Claude Code?Critical paths concern `rm` and `rmdir` aimed at the root, top-level directories, your home or your working directory and its parents. No allow rule or hook approves them, and even `bypassPermissions` asks. Protected paths concern writes to configuration locations such as `.git` or `.bashrc`, which `bypassPermissions` does allow.
- Claude needs to update the project's .claude/settings.json during a Manual-mode session. What is the least-friction option?Approve the prompt with the session-scoped option, which lets Claude edit files in the project's `.claude` folder for the rest of the session. An `Edit(.claude/**)` allow rule would not help, because the protected-path check runs before allow rules from settings.
- An Edit(.claude/**) allow rule in settings pre-approves writes under .claude.
- Protected paths only matter in Manual mode.
- bypassPermissions still prompts before writing to .git.
- In dontAsk mode a protected-path write prompts once and is remembered.
- Everything under .claude is protected, including Claude's own worktrees.