When you pick 'Yes, and don't ask again' on a Claude Code permission prompt, where is that approval saved and how long does it last?
answer
- depends on the tool type
- personal file, not the shared one
- repository root since 2.1.211
- edits never reach the disk
basics
~20 sFor Bash commands and WebFetch domains it is saved permanently as an allow rule in .claude/settings.local.json at the git repository root (since v2.1.211); a file-edit approval is never saved and lasts only until the session ends.
solid answer
~40 sIt depends on the tool. A "don't ask again" answer for a Bash command or a WebFetch domain becomes a permanent allow rule in `.claude/settings.local.json` at the **root of the git repository** (resolved through worktrees to the main checkout), so it applies to later sessions anywhere in that repository. That root placement is v2.1.211 behaviour; earlier versions saved the rule in the starting directory, so it did not reach subdirectories or worktrees. A file-modification approval is not written anywhere: it lasts until the session ends. For a compound command, Claude Code saves one rule per subcommand that needed approval, up to five, rather than one rule for the whole string. `/permissions` lists every rule with the settings file it came from, and is where you review or remove saved ones.
go deeper
Recall the split: Bash commands and WebFetch domains are saved permanently, file edits only last for the session, and saved rules go to .claude/settings.local.json.
Explain the repository-root placement and its v2.1.211 change, the per-subcommand rules for compound commands, and how /permissions shows each rule's source file.
Show how accumulated saved rules become a checkout's real policy: audit them in /permissions, prune broad prefixes, and promote deliberate ones to committed settings.
Weigh convenience against drift: personal saved approvals are invisible to the team, so decide which rules belong in shared settings and how often local ones get reviewed.
## What the prompt offers When Claude Code needs your approval for a tool call it shows a **permission prompt**: what Claude is about to do, then a short list of answers. For a Bash command the list typically includes **Yes** (this call only), **Yes, and don't ask again for: `npm test *`** (save a rule), and **No**. The second answer is the interesting one, because it quietly turns your click into configuration that outlives the conversation. Not every prompt offers it. Claude Code shows a "don't ask again" or "rest of the session" option only when the prompt can show you everything the option would allow, so a saved rule covers only what its label named. When only the one-time answer appears, you approve once, or write the rule yourself in `/permissions`. ## How long each kind of approval lasts The permissions page gives the lifetime per tool type: | Tool type | Example | "Don't ask again" lasts | | :- | :- | :- | | Bash commands | `npm test` | **Permanently**, per repository and command | | Web fetch | `WebFetch` to a domain | **Permanently**, per repository and domain | | Web search | `WebSearch` | **Permanently**, per repository | | File modification | Edit or Write | **Until the session ends** | | Read-only | file reads inside the working directories | Not applicable: no prompt is shown | The asymmetry is deliberate. A command or a domain is a stable thing to trust; "let Claude edit files" for ever is not, so edit approvals die with the session. ## Where the saved rule is written A permanent approval is saved as an **allow rule** in `.claude/settings.local.json`, the personal, per-project settings file: - **At the git repository root**, resolved through worktrees to the main checkout. The rule therefore applies to future sessions started anywhere in the repository, including subdirectories and worktrees. - **Before v2.1.211** Claude Code saved the rule in the directory where the session started, so an approval granted inside `packages/api` or a worktree did not apply elsewhere in the repository. Rules saved that way still apply to sessions started in that directory. - **Outside a git repository, or on Windows**, Claude Code does not use the repository root; the settings documentation lists where it saves the rule instead. - **Kept out of git**: the first time Claude Code writes this file in a repository that does not already ignore it, it adds the file to your global git excludes. A hand-created file is your job to ignore. Because the file is local, a teammate never inherits your saved approvals. To share a rule, put it in the project's committed settings yourself. ## What exactly gets saved 1. **Space-separated wildcard form.** Approving `npm test` saves a prefix rule such as `Bash(npm test *)`, which also matches the bare `npm test`. 2. **One rule per subcommand.** Approving `git status && npm test` saves a rule for `npm test` only, since `git status` is a built-in read-only command that needed no approval. Up to five rules can be saved for one compound command, so a later `npm test` is recognised whatever precedes it. 3. **Directories outside the working tree.** A `cd` into a directory outside your working directories generates its own `Read` rule for that path. 4. **Literal paths.** When a generated rule contains a file path, Claude Code escapes gitignore pattern characters such as `[` and `*`, so the rule matches only the path you approved. ## Reviewing and removing saved approvals `/permissions` opens a dialog listing every allow, ask and deny rule **together with the settings file it comes from**, which is the fastest way to find a rule you saved months ago and forgot. You can add or remove rules there; a change made while Claude is working applies from Claude's next tool call in the same turn. Two cautions: - **A saved allow is still an allow.** Deny and ask rules are evaluated before allow rules, so a saved approval never overrides a deny written anywhere else. - **A tracked local file loses its privileges.** If `.claude/settings.local.json` is committed to git, or `.claude` is a symlink, Claude Code treats it as repository-supplied and holds its allow rules until you accept the workspace trust dialog. ## Why interviewers ask The question separates people who click through prompts from people who know what the clicks leave behind. A candidate should be able to say which approvals persist, in which file, at which directory, and how to audit them, because an accumulated pile of saved prefix rules is often the real permission policy of a long-lived checkout.
- Why might an approval saved in a monorepo subdirectory not apply at the repository root?Before v2.1.211, Claude Code saved the rule in `.claude/settings.local.json` in the directory where the session started, so a rule granted in `packages/api` applied only to sessions started there. From v2.1.211 new rules go to the repository root, resolved through worktrees to the main checkout. Old rules saved in the subdirectory still apply to sessions started in it, so check `/permissions` to see which file each rule came from.
- Why does a file edit never get a permanent "don't ask again" rule?Claude Code treats file modification as session-scoped: the approval lasts until the session ends and is not written to any settings file. A command or a domain is a narrow, stable thing to trust; blanket edit access across future sessions is not. If you want edits to a path approved permanently, write an `Edit(...)` allow rule yourself, which states its scope explicitly.
- Saved approvals go into the shared, committed .claude/settings.json
- Every 'don't ask again' answer lasts for ever, including file edits
- A saved allow rule overrides a deny rule written elsewhere
- Approving a compound command saves one rule for the whole string
- Don't ask again for a Bash command lasts only until restart
Assumes Claude Code 2.1.286; since v2.1.211 saved rules go to .claude/settings.local.json at the repository root instead of the starting directory.