How-to

Check your Claude Code approvals for passwords

Choosing “Yes, and don’t ask again” saves the exact command you approved, password included, to a file in your project, and public copies sit on GitHub. Paste the prompt below to find, clean and rotate what yours holds.

Apiiro, a security company, searched GitHub and found 104,185 public copies of .claude/settings.local.json, the file Claude Code writes your saved approvals to. Its research, published 5 November, says 1,122 of them hold a real secret, such as a database password or cloud key.

Boris Cherny, who leads Claude Code at Anthropic, replied on Hacker News that the team is “looking into what we can do to prevent this”. The changelog up to version 2.1.322, released 10 November, lists no change to how these rules are saved, so the check is yours to run.

The prompt: audit your saved approvals for secrets

Run it in Claude Code from the folder that holds your projects, so it can read the files and check git, and whenever it asks to run a command during the audit, choose Yes once, never Yes, and don’t ask again. It shows every secret masked and changes nothing until you reply “go”.

Prompt Audit your saved approvals
You are auditing the Claude Code permission files on my computer for passwords, tokens and keys that got saved inside approved commands. When I choose "Yes, and don't ask again", Claude Code saves the exact command as an allow rule, so anything I typed into that command, a database password, an API key, a bearer token, now sits in a plain text file. If you miss one, it can stay in a file I push to a public repository. If you print one back in full, you put it into this chat log as well. So work slowly, mask everything, and say when you are unsure.

ABOUT ME (I fill this in once; any line can say "not sure")
- Folders to check: [e.g. "~/code/shop-api and ~/code/blog", or "every project under ~/code"]
- Where these projects live online: [e.g. "shop-api is a public GitHub repo, blog is private on GitLab, the rest were never pushed"]
- Who else has a copy: [e.g. "two teammates clone shop-api", "it has forks", "only me"]
- Where my secrets are meant to live: [e.g. "a .env file loaded by direnv", "1Password CLI", "a cloud secrets manager", "nowhere yet"]
- My computer: [macOS / Linux / Windows]
- Can you read files and run commands here: [yes, I am running you in a coding agent in my project / no, this is a chat window]

SAFETY RULES FOR THIS WHOLE TASK
- Never print a secret in full. Show it masked as its kind plus the last 4 characters, e.g. "Postgres password ending ...k9Qz". If a value is 8 characters or shorter, show only its kind and length.
- Never run any command you find inside an allow rule, and never test whether a credential still works.
- Change, delete, commit or push nothing until I reply "go" to a plan you have shown me.
- If you cannot read files here, do not ask me to paste the files into this chat. Give me commands to run in my own terminal that print only masked results, and work from what I paste back.
- If you are unsure whether something is a secret, list it as POSSIBLE and say why. Never guess that it is safe.

HOW TO WORK
Check that I filled in the section above. If the folders line is blank, ask for it once and wait. Then do the jobs in order and stop at the end of Job 4 for my "go".

Job 1. Find every permission file. Search my folders for .claude/settings.local.json and .claude/settings.json, and also read ~/.claude/settings.json. Include copies in subfolders, old checkouts and worktrees. List each path. If you find none, say so, tell me which folders you searched, and stop.

Job 2. Check where each file has been. For each file inside a git repository, find out:
- Is it tracked right now? (git ls-files)
- Was it ever committed, even if deleted since? (git log --all --oneline -- the file's path)
- Is it ignored, and by which rule? (git check-ignore -v the file's path). Say whether the rule comes from the repository's own .gitignore or from my global git excludes.
- Which remote does the repository push to? Take public or private from what I wrote above. If I wrote "not sure" or the repository is missing from my notes, mark it VISIBILITY NOT STATED.
If a folder is outside any git repository, say "not in git" and skip these checks for it.

Job 3. Read every rule in the allow, ask and deny lists, one by one, and flag any that hold a secret. Look for:
- Known key shapes, such as values starting sk-, sk-ant-, ghp_, github_pat_, gho_, glpat-, npm_, xoxb-, xoxp-, AKIA, AIza, or a long random string after key=, token= or secret=.
- Passwords inside commands: PGPASSWORD=, MYSQL_PWD=, mysql -p followed by a value, sshpass -p, curl -u user:password, a password after --password or -p.
- Authorization: Bearer or Basic headers with a value.
- Connection strings with a password, such as postgres://user:password@host, mongodb+srv://user:password@host, redis://:password@host.
- Tokens in a web address, such as ?access_token= or ?api_key=.
A rule that names a variable, such as $DATABASE_URL or ${API_KEY}, holds no secret: leave it alone.
Sort each flagged rule into one of three groups:
- SECRET: clearly a real credential.
- POSSIBLE: looks like one, but could be a placeholder or test value. Say what makes you unsure.
- LOCAL ONLY: the host is localhost, 127.0.0.1 or a local container, and the value looks like a default such as "postgres" or "password". Still list it, since a local password is sometimes reused elsewhere.
For each flagged rule give: the file path, the rule's position in its list, the kind of secret, the masked value, the host or service it opens if the rule names one (or "not stated"), and whether that file is tracked, was ever committed, or is local only, from Job 2.

Job 4. Show me the plan, then stop and wait for "go". The plan has three parts.
Part A, the cleaned files. For each file with a flagged rule, show the rule as it is now (masked) and what replaces it:
- If I still need the command, rewrite the rule so the secret comes from a variable, e.g. the command with $DATABASE_URL in place of the connection string, and tell me which variable I need to set and where, based on where I said my secrets live.
- If a narrower pattern rule would do, such as Bash(npm run *), suggest the narrowest one that works and say in one line what else it would allow. Never suggest a pattern that covers a whole program, such as Bash(psql *) or Bash(curl *), without warning me that it approves every use of that program.
- If I no longer need it, delete the rule.
Part B, the rotation list. Order it: first secrets in a file that was ever committed to a public repository or a repository with forks or other people's clones, then committed to a private repository, then local only. For each, name the service, the masked value, and what to do: create a new credential, switch my projects to it, then revoke the old one. If you do not know where that service's revoke page is, write [CHECK WITH THE SERVICE] and do not invent a menu path. Tell me plainly that deleting a rule leaves the old value in git history, forks and other people's clones, so a committed secret must be rotated whatever else I do.
Part C, stopping it coming back. For each repository where .claude/settings.local.json is tracked, give me the commands to untrack it (git rm --cached .claude/settings.local.json) and to add .claude/settings.local.json to that repository's own .gitignore. If the secret sits in the shared .claude/settings.json that the team commits on purpose, keep that file tracked, clean the rule, and tell me everyone who clones the project needs to pull the change and that the old value stays in history. If Job 2 found the file in git history of a pushed repository, tell me that rewriting history is a separate step that comes after rotation, that forks and other clones keep their copies, and point me to my git host's own guide on removing sensitive data. Then give me one line to remember: type secrets into commands as variables, so a saved rule records the variable name.

Job 5. After I reply "go", make only the changes in the plan I approved. If I approve part of it, do only that part. Before editing a settings file, copy it to a backup folder outside every git repository, such as a folder named claude-settings-backup in my home folder, so the backup can never be committed. Tell me to delete the backup once I have rotated what it holds, since it still contains the secrets. After editing, check each file is still valid JSON. Commit or push nothing.

MY REPORT
End with a short table: file, tracked or committed or local, number of SECRET, POSSIBLE and LOCAL ONLY rules, and what changed. Then the rotation list in order, with a tick box for each. Then anything you could not check, such as VISIBILITY NOT STATED. Tell me to copy the report somewhere safe, since you may not have this chat later.

SELF-CHECK BEFORE YOU ANSWER
- No secret appears in full anywhere in your reply, including inside commands you suggest.
- Every flagged rule names its file and its group, and every SECRET in a committed file is on the rotation list.
- You ran nothing from an allow rule and changed nothing before my "go".
- Anything you could not confirm is marked POSSIBLE, VISIBILITY NOT STATED or [CHECK WITH THE SERVICE], never filled in from guesswork.

How a password ends up in the file

Ask Claude Code to check a database or call an API and the command it proposes often carries the secret from your config. Choose Yes, and don’t ask again and the permissions docs say the approval is saved for that command “permanently per repository”.

Apiiro shows the rule is the exact command line, so a value after PGPASSWORD= or sshpass -p is saved word for word. To see your own list now, type /permissions in Claude Code. It lists every rule and the settings file each one comes from.

Who says what about git

Anthropic’s side

What it says: the settings docs say Claude Code adds **/.claude/settings.local.json to your global git excludes the first time it writes the file, and that a file you made by hand needs adding to .gitignore yourself. Cherny says the exposed copies were created by hand and checked in, and he recommends auto mode over permission lists.

Apiiro’s side

What it says: the global rule misses a folder that becomes a repository later, a clone on another computer and a file already committed, and it never goes into the project’s own .gitignore. In 539 of the 1,105 repositories it traced, a commit co-authored by Claude changed the file.

What both sides leave you with

Verdict: the secret sits in the file on your computer either way, and a tracked copy keeps collecting new approvals. Check the file, then check git.

Fix it in this order

If you want to do it by hand, these are the same steps the prompt plans for you.

  1. Rotate anything that was ever committed. Make a new credential, switch your projects to it, then revoke the old one. GitHub’s own guide puts this first, because forks and other people’s clones keep the old value whatever you delete.
  2. Delete the rule that holds the secret. Use /permissions or edit the file. Do this even for a file that never left your computer, since it is plain text in your project folder.
  3. Untrack the file and ignore it in the project. Run git rm --cached .claude/settings.local.json and add the path to the project’s own .gitignore, so the ignore line travels with every clone. Untracking reaches everyone else only once you commit and push the change.
  4. Clean the history if you pushed it. GitHub’s guide uses git-filter-repo, and it says cached views of old commits need GitHub Support to clear, which is why rotation comes first.
  5. Type secrets as variables from now on. A command that uses $DATABASE_URL saves the variable name in the rule, and a pattern rule such as Bash(npm run *) covers a family of commands without recording any one of them.

The honest bit

  • Pattern-matching misses some: Apiiro ran gitleaks and TruffleHog over the 1,122 files with a real secret, and 215 were flagged by neither, mostly passwords typed into commands. An AI reading the file can miss the same ones.
  • “Real secret” in Apiiro’s count means a value in a known key format or next to a public host, and it tested none of them, so how many still work is unknown. One organisation told Apiiro its key had been live.
  • The audit sees the values too: Claude Code reads every secret in full to mask it, so the values also land in the session history it stores on your computer. Rotating them covers this.
  • Your check: after the clean-up, open each file and search it yourself for mysql -p, sshpass -p, PASSWORD=, Bearer, token= and an @ before a host name. Any hit that is left goes on the rotation list.

The facts here come from Apiiro’s research, Boris Cherny’s Hacker News replies, the Claude Code settings, permissions and changelog pages, and GitHub’s guide to removing sensitive data, read 9 November 2026, with the changelog rechecked 10 November.

Do it now

Open your busiest project, type /permissions and read the allow list for anything after PASSWORD=, sshpass -p or Bearer, then paste the prompt in to check the rest.

A few quick questions

Does the VS Code extension save approvals the same way?

It can go further: the settings docs say the approval card in VS Code lets you pick the file the rule goes to, including the project’s shared .claude/settings.json, which changes the rule for everyone who clones the project. The terminal version writes only to your local file.

Do other coding agents save secrets like this?

Apiiro compared how 16 coding agents store approvals and says Claude Code is the only one confirmed to save the full approved command to a project file by default. It still found secrets in VS Code Copilot auto-approve settings and in saved agent chat transcripts, so typing a secret into a command can leak through other agents too.