If Claude Code keeps asking for permission on every Bash command and file edit, that is the default manual mode doing its job, not a bug. The fix is to write a few allow rules in a settings file so it stops asking for the commands you trust, and switch permission mode only where it is safe. The trap most guides skip: the "Yes, and don't ask again" button writes the whole command, secrets included, into a file that thousands of people have accidentally pushed to public GitHub. Here is how to stop the prompts without becoming one of them.
We run Claude Code headless to research and publish this site, so permission rules are not theory here. They are the difference between an unattended run that finishes and one that hangs on a prompt nobody is there to answer.
Why Claude Code keeps asking for permission
By default Claude Code runs in manual mode, which gates anything that can change your machine or reach the network. Reading files inside your working directory is free. Running a Bash command, editing or writing a file, and fetching a web page each need your approval, except a built-in set of read-only commands and preapproved documentation domains. That is why a session feels chatty: a single task can touch a dozen commands, and each new one you have not approved stops for a prompt.
The prompt itself offers more than yes or no. It shows the exact command, a "Yes, and don't ask again" option that saves a standing rule, and on some prompts a "Yes, and switch to auto mode" shortcut. Understanding which of those you are clicking is the whole game, because one of them quietly writes to a file in your repository.
Stop asking for the same command: write allow rules
The clean fix is an allow rule. Open ~/.claude/settings.json for yourself, or .claude/settings.json in the project to share the policy with your team, and list the tools Claude Code may run without asking. This is the exact shape from Anthropic's settings docs:
{
"permissions": {
"allow": [
"Bash(npm run lint)",
"Bash(npm run test *)",
"Bash(git log *)"
],
"deny": [
"Read(./.env)",
"Read(./.env.*)"
]
}
}
Once saved, Claude Code stops prompting for anything the allow list matches and keeps gating the rest. You can also manage rules live with the /permissions command, which lists every rule and the file it came from. A committed .claude/settings.json is the right home for team rules, because everyone who clones the repo inherits the same policy instead of each person clicking through the same prompts.
Why your allow rule does not match
Most "it still asks me" complaints come down to rule syntax, and the wildcard is where people trip. Claude Code matches everything before the first * literally, so the * has to go after the subcommand, not before it. Bash(git log *) allows every git log command; Bash(git *) allows every git command; and Bash(git * main) is rejected with a startup warning because the wildcard sits before the word that decides what git does. An exact rule like Bash(npm run build) matches only that command, nothing more.
Two more gotchas. You cannot match a command's main content field with a parameter rule, so Bash(command:rm *) is ignored as bypassable; write Bash(rm *) as a deny rule instead. And a project allow rule waits for you to trust the folder before it applies, so a freshly cloned repo still prompts until you accept the workspace-trust step.
Permission modes, from cautious to reckless
If per-command rules are too fine-grained, change the mode. Set defaultMode in a settings file, or pass --permission-mode for one session. These are the modes Anthropic documents, roughly in order of how much they hand over:
| Mode | What it does | When to use it |
|---|---|---|
| default (manual) | Asks before Bash, edits, and web fetches | Day-to-day work on anything you care about |
acceptEdits | Auto-accepts file edits and common filesystem commands, still asks on shell | Fast iteration on code when you review diffs after |
plan | Reads and explores only, never edits your source | Scoping a change before you let it write |
auto | Runs without routine prompts; a background classifier checks shell and network actions first | Trusted local work where you want flow, not a blank check |
bypassPermissions | Skips prompts entirely | Isolated containers or VMs only |
auto mode is the sensible middle: it approves the safe majority and still stops on the actions a classifier flags as risky. bypassPermissions (the same thing as the --dangerously-skip-permissions flag) is the one to be careful with. Anthropic's own docs warn to use it "only in isolated environments like containers or VMs where Claude Code can't cause damage", because it will happily write to protected paths like .git and .claude. Note that as of recent versions, auto and bypassPermissions no longer take effect from project or local settings files; set them in your user settings or pass the flag.
The part other guides miss: "don't ask again" leaks secrets
Here is the differentiator, and it is a real one. When you click "Yes, and don't ask again," Claude Code saves that approval as an allow rule in .claude/settings.local.json at your repository root, storing the full command text. If the command you approved contained a secret, a psql string with a password, a curl with a bearer token, an export with an API key, that secret is now sitting in plaintext in a file in your repo.
That is not hypothetical. In November 2026, security firm Apiiro found 1,122 secrets in public Claude Code settings files that approved commands had saved. A follow-up scan by GitGuardian counted 31,088 secrets in these files, 5,343 of them still valid at the time of detection: database connection strings, cloud tokens, SSH passwords, and API keys. The cause was not a Claude Code exploit. It was developers approving a command with a secret in it, then committing the local settings file.
Claude Code adds .claude/settings.local.json to your global git excludes the first time it writes the file, but that protection only holds if it created the file and you never force-added it. The safe habits:
- Never put a secret in a command you approve. Pass secrets through environment variables, a
.envfile (which you thendenyreading), or a secrets manager, so the approved command text is clean. - Confirm
.claude/settings.local.jsonis gitignored. If it already slipped in, rungit rm --cached .claude/settings.local.json, add the path to.gitignore, and rotate anything that was exposed. - Prefer a hand-written
.claude/settings.jsonwith specificallowrules over clicking "don't ask again" for everything. You control exactly what goes in, and secrets never get near it.
Stopping prompts in an unattended or CI run
A headless claude -p run has nobody to click the prompt, so an unapproved command would hang forever. Two safe patterns cover this without reaching for a blanket bypass. First, commit a tight .claude/settings.json that allows exactly the commands your job needs (your build, your tests, your linters) and denies reads of secret files. Second, for a fully unattended run set permissions.denyInsteadOfPrompting to true in user or managed settings, so instead of hanging, any call that would have prompted is denied and the session keeps moving.
Save bypassPermissions for a disposable, isolated environment: a throwaway container with no network and no credentials, where there is nothing worth stealing and nothing worth breaking. If you are running Claude Code unattended on a real machine, a specific allowlist beats a bypass every time. For the isolation side of this, see our guide to sandboxing Claude Code, and for the automation setup our headless Claude Code guide.
FAQ
Why does Claude Code keep asking for permission?
It runs in manual mode by default, which prompts before every Bash command, file edit, and web fetch that you have not pre-approved. Reads inside your working directory and a built-in set of safe commands never prompt. Add allow rules or change the permission mode to reduce the prompts.
How do I stop Claude Code asking for the same command?
Add an allow rule for it in ~/.claude/settings.json (just you) or .claude/settings.json (your team), for example "Bash(npm run test *)". Clicking "Yes, and don't ask again" does the same thing automatically, but it writes the full command to .claude/settings.local.json, so never use it on a command that contains a secret.
Why does my allow rule not match?
Usually the wildcard is in the wrong place. Put * after the subcommand (Bash(git log *), not Bash(git * main)), because Claude Code matches everything before the first * literally. A project rule also waits until you trust the folder, and Bash(command:rm *) style parameter rules on a tool's main field are ignored, so write Bash(rm *) instead.
Is --dangerously-skip-permissions safe?
Only in an isolated container or VM with no credentials and no network. The flag is the same as bypassPermissions mode and skips nearly every check, including writes to .git and .claude. On a real machine with real secrets, use a specific allowlist or auto mode instead.
Could my settings file be leaking secrets right now?
If you ever approved a command containing a password or token with "don't ask again," check .claude/settings.local.json. Apiiro and GitGuardian found tens of thousands of secrets in these files on public GitHub in late 2026. Make sure the file is gitignored, remove it from tracking with git rm --cached, and rotate any exposed credential.
Sources
- Claude Code docs, Configure permissions: permission modes, allow/ask/deny rule syntax, wildcard placement, the bypassPermissions warning, and denyInsteadOfPrompting.
- Claude Code docs, Settings files and precedence: the example permissions block, where "don't ask again" rules are saved, and settings precedence.
- InfoQ: Claude Code Has Been Leaking Secrets through its "Don't Ask Again" Feature: Apiiro's finding of 1,122 secrets in public settings files.
- CSO Online: Claude Code's 'don't ask again' button has a secrets-spilling problem: GitGuardian's count of 31,088 secrets, 5,343 still valid, and the remediation steps.
Some links may earn us a commission at no extra cost to you.
Waqas Ahmed Waseer
Waqas Ahmed Waseer is a developer and automation builder with 8+ years shipping production systems used by 100k+ people. He builds custom multi-tenant SaaS, AI automation (n8n, LLM workflows, WhatsApp bots) and hosting infrastructure (WHM/cPanel, CloudLinux) — and is the maker of WaSphere, FlowMaticX, and the WaseerHost hosting brand. 100+ projects delivered for SMBs, agencies and funded startups.






