Claude Code Automation Configuration: Fewer Confirmations and Less Waiting
Set permissions.defaultMode to auto, then combine it with Bash timeout and workspace directory settings, and Claude Code will judge most tool calls on its own, stopping only when you genuinely need to make a decision. This page gives a configuration you can copy directly into ~/.claude/settings.json, and explains what real problem each item solves.
The configuration only affects client behavior; it does not change model capabilities, billing rules, or your API Key permissions. If you have not installed the client yet, first complete installation and key setup by following the Claude Code installation guide, then come back to this page to tune your experience.
First, distinguish three kinds of friction
Most people assume the pain point is having to confirm every step, but in practice the time usually comes from three other places. Locating the cause before changing configuration is more effective than copying a whole set at once.
| Symptom | Actual cause | Corresponding setting |
|---|---|---|
| Every command waits a few seconds | Auto mode runs its judgment every time | Use allow rules so common commands skip judgment |
| A command fails with a timeout partway through | The Bash default timeout is 120 seconds, with a 600-second cap | BASH_DEFAULT_TIMEOUT_MS |
| Reading a file outside the project prompts again | The path is not inside the working directory | additionalDirectories |
The first one is the most worth understanding: a tool call that matches an allow rule does not enter the judgment flow, so adding rules reduces both prompts and waiting. This is the highest-value adjustment.
Configuration at a glance
Write the following into ~/.claude/settings.json. Parts wrapped in angle brackets need to be replaced with your own values. The configuration file allows // comments; if your version does not accept them, delete the comments and save it as plain JSON.
{
"permissions": {
"defaultMode": "auto",
"allow": [
"Bash(git status)",
"Bash(git diff *)",
"Bash(git log *)"
],
"deny": [
"Read(//home/<username>/.ssh/**)"
],
"ask": [
"Bash(git push --force*)",
"Bash(git reset --hard*)",
"Bash(rm -rf*)"
],
"additionalDirectories": [
"/home/<username>/deploy"
]
},
"env": {
"BASH_DEFAULT_TIMEOUT_MS": "300000",
"BASH_MAX_TIMEOUT_MS": "1800000"
}
}
If you use this site's Claude Code access, fill in ANTHROPIC_AUTH_TOKEN, ANTHROPIC_BASE_URL, and the model variables under env according to the DeepSeek access guide or the page for the corresponding model; do not confuse them with the BASH_* items on this page.
Item-by-item explanation
permissions.defaultMode set to auto puts new sessions directly into auto mode, with the client deciding whether to allow or block each tool call. You can also cycle through modes with Shift + Tab in the interactive interface, or start with claude --permission-mode auto.
permissions.allow can range from narrow to broad, for example Bash(git status) or Bash(go test *). Note that broad rules have a cost: patterns such as Bash(bash *), Bash(ssh *), and Bash(curl *) amount to "allow running any command" and cause judgment to be skipped entirely. If you truly need broad rules, you must back them with deny or ask.
permissions.deny and permissions.ask have the precedence deny over ask, and ask over allow, so they can override broader allow rules. deny rejects unconditionally; ask forces a prompt even when an allow rule matches. Put credential directories in deny, and destructive commands in ask.
additionalDirectories registers paths outside the working directory that you often need to read and write. Without registration, the first read of a file outside the workspace prompts one extra time.
BASH_DEFAULT_TIMEOUT_MS and BASH_MAX_TIMEOUT_MS default to 120 seconds and 600 seconds. Compilation, builds, and cross-machine operations can easily hit the cap, and once a timeout occurs you have to rerun the whole round. The example relaxes them to 5 minutes and 30 minutes; adjust according to the actual duration of your tasks.
Make safety rules more reliable than judgment
Auto mode's decisions are made by the model and are probabilistic; hooks, by contrast, are deterministic rules. Write the pitfalls you have already hit into a hook, and you no longer depend on the model remembering them every time.
Hook scripts follow a simple contract: exit code 0 means allow, exit code 2 means block and pass the standard error content back to the model. The script must never crash, or one exception will block every command, so wrap the whole thing in exception handling that allows the command through.
#!/usr/bin/env python3
"""Pre-command check: exit 0 allows, exit 2 blocks and returns the reason."""
import json, re, sys
def main():
try:
payload = json.load(sys.stdin)
if payload.get("tool_name") != "Bash":
sys.exit(0)
cmd = (payload.get("tool_input") or {}).get("command") or ""
if re.search(r"\brm\s+-rf\s+/(\s|$)", cmd):
sys.stderr.write("BLOCKED: refusing to delete the root directory\n")
sys.exit(2)
except SystemExit:
raise
except Exception:
pass
sys.exit(0)
if __name__ == "__main__":
main()
After saving, register the absolute path in settings.json:
{
"hooks": {
"PreToolUse": [
{
"matcher": "Bash",
"hooks": [{ "type": "command", "command": "/绝对路径/guard-bash.py" }]
}
]
}
}
Typical scenarios suitable for hooks include deleting the root directory or wildcard deletions, running delete or truncate statements on a production database, and writing keys directly on the command line.
Verify that the changes take effect
After changing the configuration, confirm with a temporary session; there is no need to disturb a session you are working in:
claude --permission-mode auto --debug-file /tmp/cc.debug -p 'echo hi'
grep -E 'verifyAutoModeGateAccess|Skipping auto mode classifier|classifier_request_finished' /tmp/cc.debug
canEnterAuto=true means auto mode is available; the appearance of Skipping auto mode classifier means the command matched an allow rule and skipped judgment; the durationMs value is the waiting cost generated by commands not yet covered.
Two common misconceptions
First, auto mode is not a security boundary. Its judgments run on the model you configure; treat it as a convenience feature, and rely on deny and ask rules and hooks for safety.
Second, non-standard model names affect context compaction. If the client does not recognize your model name, it shows a notice and performs automatic compaction according to an assumed window size; when the actual window is smaller, compaction may never trigger in time, and the request ultimately fails. The fix is to set CLAUDE_CODE_MAX_CONTEXT_TOKENS, or add behavesAs to that entry in modelPicker with the real window value. Getting it wrong is worse than leaving it blank.
Suggested order of adjustments
Start by adding only defaultMode and the Bash timeouts, and use that for a week; then check the rejected records in /permissions and add frequent, safe commands to allow; after that, add deny and ask as backstops; only lastly consider hooks and broad rules. Changing everything at once makes it easy to obscure where a problem came from, while adjusting step by step lets you see clearly which item actually reduced your waiting.
If authentication or connection errors still occur frequently after configuration, see Connection and Recovery; for account, balance, and usage questions, see Pricing, Balance, and Usage.
Related guides
Install Claude Code, Configure a Custom API, and Troubleshoot Windows
Install Claude Code, configure a custom API key and URL, verify Windows or Unix settings, and troubleshoot authentication, rate limits, and connections.
DeepSeek API and Claude Code setup guide
Connect DeepSeek V4.1 Flash to Claude Code using an I Code Easy API key and deepseek-flash. Covers Windows, macOS, Linux, verification and common errors.
How do I troubleshoot slow connections or failed requests?
Match 401, 403, 429, timeouts, and Gemini path errors before changing hosts. Switch to the jp or sg backup domain only after the network is the problem.