How does Claude Code decide when to ask? Permission rules, configuration files, and working directories

August 13, 2025

Suppose I give Claude Code a task: “Change the salutation in the invitation email, run the tests, and show me the result.” I'm happy for it to read templates in the repository directly. I want to confirm before it runs npm test. Publishing a release is outside this task. If every action prompts me, I have to watch constantly. If it asks just once, “Do you trust this project?”, how do I express those three different decisions?

In June, while building my own interface, I was interested in how to present a pending command to the user and send the decision back to the Claude Code SDK. On August 13 I searched for “claude的权限设计” and “claude code权限文件配置” (Claude's permission design and Claude Code permission file configuration). I read the Chinese security guide first, then opened the English security and settings documentation that afternoon.1 Trace one tool call back to before the confirmation dialog, and the program already has two decisions to make: is there an existing rule for this operation, and which working directory contains the file it wants to access? My June SDK command approval example

Which actions can proceed automatically within the same task?

Ernest Chiang described Anthropic's design as putting safety first. When using Claude Code he would ask it to read the relevant files and propose a plan, then decide whether to execute or discuss it further. His wording was “審閱 Claude Code 產生的計畫後再授權執行” (“review the plan generated by Claude Code before authorizing execution”).2 If I agree to the email template fix, I've approved that approach. When the assistant actually proposes running tests, the program still has to determine whether that specific command is authorized.

When the model proposes a test run, it supplies a tool name, Bash, and a specific command, npm test. Bash is Claude Code's tool for command-line execution. A rule such as Bash(npm test) limits the decision to that command. Here's an example project configuration for Claude Code 1.0.77 in August 2025.3

{
  "permissions": {
    "allow": ["Bash(git diff)"],
    "ask": ["Bash(npm test)"],
    "deny": ["Bash(npm publish)"]
  }
}

With this setup, a standalone request for git diff can inspect changes directly. For npm test, the person at the terminal decides on this occasion. A request for npm publish is denied. All three examples are complete commands. Authorizing the entire Bash tool has a much broader scope. Authorizing Bash(npm test) also says nothing about what the test script itself will do.3

What if personal settings allow npm test but project settings say to ask? This version retains permission rules from the different sources. For the exact Bash commands here, the matching code checks deny, then ask, then allow. When both rules apply, it still asks. If none of the three lists matches, the command goes on to further Bash checks. The JSON alone doesn't tell us the final outcome in that case.3

Is this permission mine, the project's, or only valid for this session?

The GitCode guide discusses permissions by user, project, and session. Take the same Bash(npm test) rule: am I willing to allow the tests in every repository, does the team accept it only in this email project, or do I want a temporary exception for today's debugging? In 1.0.77 these choices differ as follows.45

ScopeWhere to configure itWhat happens on the next launch
User~/.claude/settings.json, where ~ is the current user's home directoryLoaded for the same user even in another project.
Project, shared.claude/settings.json in the projectLoaded on launch from that project. If committed, colleagues get it when they check out the repository.
Project, local only.claude/settings.local.json in the projectLoaded the next time I start in that project. The file can stay local.
SessionStart with claude --allowedTools 'Bash(npm test)'The argument belongs to this process. A subsequent plain claude launch won't have that temporary authorization.

If the project already lists Bash(npm test) under ask, it will still ask even with --allowedTools at launch. User, project, and session describe where a rule comes from and how long it lasts. For the same exact Bash command, the final decision still follows deny, ask, allow in that order.53

In 最强Coding Agent: Claude Code权威实践指南, 木牛流码 discusses several entry points together: tell Claude to remember a decision at confirmation, manage existing rules with /permissions, edit a settings file directly, or specify allowed tools at startup. In the email project, putting npm test in CLAUDE.md tells the assistant which test command to run. Permission settings determine whether it must ask first. In 1.0.77, the default user-level permissions file is ~/.claude/settings.json and the launch argument is spelled --allowedTools.653

“Configuration belongs to this project” and “a tool can only access this project” affect the result independently. The first determines which rules are loaded. To decide whether a file can be read directly, you also need the actual path for that call.57

If I start from one repository, can it read a neighboring directory directly?

平淮齐Percy's GitCode article gives a concrete example: reading a file in a subdirectory went ahead, while reading one in the parent directory prompted for confirmation. The author's suggestion was to add the entire Read tool to the user-level allowlist, reducing confirmations in other projects too.4 But if I only need a template in the adjacent repository, how much additional scope do I actually need?

Suppose there are two sibling directories, mail-app for the email application and mail-templates for shared templates. I start in the former. In default mode, without extra grants or restrictions, 1.0.77's Read tool can directly read ordinary source files in the working directory. Reading an ordinary template in the sibling repository requires confirmation. Directory membership checks account for path separators, so mail-app-old doesn't count as inside mail-app just because its name starts the same way.7

If the task needs both directories, include the existing templates directory at launch:7

cd /work/mail-app
claude --add-dir ../mail-templates

Read can now handle the template as a file within the working directories. Ordinary file edits have their own checks. In default mode an edit with no matching rule still requires confirmation. In acceptEdits mode, eligible edits in the working directories are automatically accepted. Running tests is still a separate Bash request, even for a file in the second directory. Add a directory during the session with /add-dir, or set permissions.additionalDirectories if it should be available repeatedly within that configuration's scope.7

These checks determine what Claude Code does when it receives a tool request. Operating-system permissions granted to the process form another layer. Once a script is allowed to run, what it does next depends on its contents and execution environment. For the assistant I want to build, that determines what confirmation should show: the path for a file read, and the full command for command execution. Decisions with well-defined, reusable scope belong in rules. The remainder are worth interrupting me for.37

What permissions does Claude need to review repository changes?

When I looked at Cursor's Bugbot, I also considered connecting Claude review to my own repository. 木牛流码 gave an example well suited to automation: in continuous integration (CI, the checks a repository runs automatically), have Claude spot spelling mistakes, stale comments, or misleading variable names. The article also suggests dedicating a separate session to reviewing code written by the previous one.6

Chiang discusses division of labor through subagents, assistants the main assistant calls for specific tasks. He connects role and tool permissions: give each subagent only the tools it needs to do its job.2 In my repository, if a review assistant's only role is pointing out issues, I can let it read changes and write observations while leaving source edits to the repair step.

Suppose I want to review staged changes only. Git can provide the diff and the review can go to the terminal. This example uses the 1.0.77 arguments, with -p meaning print one response and exit.3

git diff --cached | claude -p '请检查这份改动里是否有与实现不符的注释。请写出文件名和理由。'

This step has the input it needs to produce review comments. To put those comments on a pull request (PR), CI also needs to send the output back to the repository, and the step that posts comments needs the corresponding permission. Separating reading the diff, generating the review, and posting comments makes clear which part of the workflow needs to read code and which needs to write comments.

References

Footnotes

  1. Anthropic. (n.d.). Official Claude Code documentation. Chinese security guide, English security guide, and English settings guide. On August 13, 2025, I visited the older addresses for Security in Chinese, Security in English, and Settings. The permission behavior discussed here is based on the 1.0.77 distribution. ↩

  2. Chiang, E. (2025, July 30). 我的 Anthropic Claude Code 學習筆記 [My Anthropic Claude Code study notes]. Ernest Chiang. See section 2 on safety-first design, the last step of section 7 for the quotation, and the third item in section 3 on subagents for tool permissions. ↩ ↩2

  3. Anthropic. (2025, August 12). Claude Code 1.0.77 [CLI distribution]. npm. Pinned version metadata and published package. Release date in UTC. In the package's cli.js, lines 739–741 collect permissions by source, and line 748 defines the permissions field. At line 1687, QTB and lq0 match Bash commands and handle exact-command rules. Line 3102 registers permissions; line 3437 registers --allowedTools and -p, --print. ↩ ↩2 ↩3 ↩4 ↩5 ↩6 ↩7

  4. 平淮齐Percy. (2025, May 28). Claude Code项目全局工具权限配置指南 [Guide to global tool permissions for Claude Code projects]. GitCode. Permission configuration levels, global configuration, and troubleshooting. ↩ ↩2

  5. Anthropic. (2025, August 12). Claude Code 1.0.77: Settings sources [CLI distribution]. npm. Published package. In cli.js, YQ at line 689 determines the user configuration directory, and cC1, sO, and XQ1 at line 751 resolve paths for different settings sources. At line 852 G8B places launch arguments into the current process's cliArg permission rules. The user directory in the table assumes the default. ↩ ↩2 ↩3 ↩4

  6. 木牛流码. (2025, June 23). 最强Coding Agent: Claude Code权威实践指南 [A practical guide to Claude Code]. Zhihu. Original article, sections 1.a on creating a CLAUDE.md context file, 1.c on managing the tool allowlist, 5.b on code review, and 6.a on one session coding and another verifying. ↩ ↩2

  7. Anthropic. (2025, August 12). Claude Code 1.0.77: Working directories and file-tool permissions [CLI distribution]. npm. Published package. In cli.js, BQ1, ti, ry, and Th at line 741 cover working directory sets, directory membership, and read/write decisions. Line 852's DZ1 checks added directories. Line 3437 registers --add-dir. ↩ ↩2 ↩3 ↩4 ↩5

© 2025 borui. All rights reserved. This content may be freely reproduced, displayed, modified, or distributed with proper attribution to borui and a link to the article: borui (2025-08-13). How does Claude Code decide when to ask? Permission rules, configuration files, and working directories. https://caiborui.com/blog/2025-08-13-zh-claude-code-permission-rules-working-directories-entrans

@misc{borui2025-b6ae48f3,
  author = {borui},
  title = {{How does Claude Code decide when to ask? Permission rules, configuration files, and working directories}},
  year = {2025},
  publisher = {borui's blog},
  url = {https://caiborui.com/blog/2025-08-13-zh-claude-code-permission-rules-working-directories-entrans}
}