Does Claude Code save passwords in settings.local.json?

Sometimes, yes. Pick "Yes, and don't ask again" on a command with a password in it and Claude Code can save that password in plain text in .claude/settings.local.json. In our test it depended on the shape of the command: a password in a psql prefix was saved, a bearer token in curl wasn't in that run, and a command using a variable got no option to save a rule.

We make fidelius, a Mac app for keeping API keys out of projects. The test below used fake values, and only its last row involves our tool.

What we tested

We ran Claude Code 2.1.319 with Haiku in throwaway git repos and asked it to run each command, choosing "Yes, and don't ask again" whenever the prompt offered it. One run per command, two for the curl variable, on one Mac with our usual setup, so treat this as a spot check: another model or version may offer different rules.

CommandThe prompt offeredSaved in the file
PGPASSWORD=fake-pw psql -h ...Don't ask again for PGPASSWORD=fake-pw psql *Bash(PGPASSWORD=fake-pw psql *), password included
curl -H "Authorization: Bearer fake-token" ...Don't ask again for curl *Bash(curl *), no token
PGPASSWORD="$DEMO_PW" psql -h ...A one-time yes or auto mode, no rule to saveNothing
curl -H "Authorization: Bearer $DEMO_TOKEN" ...A one-time yes or auto mode, no rule to saveNothing
accio myapp sh -c 'curl ... $DEMO_TOKEN ...'Don't ask again for accio myapp *Bash(accio myapp *), no token

Only the first row saved a secret. Row two saved none, and it did approve every future direct curl in that repo, including one that posts your files somewhere. That's one run, and Apiiro's files do include bearer headers, so row two is no guarantee. Rows three and four differ from Apiiro's advice that the saved rule will record the variable name: with these commands, no rule was offered. Claude Code's docs say it offers to save a rule only when the prompt can show everything the rule would allow.

How the password gets into the command

Apiiro, the security company that published this research in early November, describes the usual route. You ask Claude Code to check a database or call an API, it finds the connection string in your config, and the command it proposes carries the secret. The prompt shows it, but Apiiro's point is that it's easy to miss in a long line, and after enough prompts people stop reading them.

Claude Code tries to keep the file out of git by adding it to your global excludes the first time it writes the file. That covers one user on one computer. Our test runs got that entry. On a repo without it, as on a second machine, git add -A picked the file up when we tried it.

What Apiiro found

Of 104,185 public copies of the file on GitHub, Apiiro classed 1,122 as holding a secret, about 1.1%. Counting git history, the shared settings.json and other agent files, it reports 2,539 secrets in 1,994 repos. In the local file, 501 of 1,379 distinct secrets look like direct database access.

Apiiro didn't test any credential, so "secret" means it matched a provider's format or sat beside a public host, and passed an LLM review. One company it notified did confirm its key had been live.

gitleaks and TruffleHog both missed 215 of the 1,122 files, mostly passwords typed inside commands, so a clean scan doesn't settle this. Boris Cherny from the Claude Code team replied on Hacker News that the file is meant to stay local and that Anthropic is looking at how to prevent this, with basic secret scanning among the ideas. He also recommends auto mode over maintaining allow rules, and turning on secret scanning at your git host.

Check your own

Run these yourself, in your own terminal. If you ask an agent to read the file, whatever is in it goes into that conversation.

The quickest way is our free script, on macOS or Linux, with or without fidelius. It checks the Claude Code settings files in your home folder and their local git history, and reports what it found and whether this clone shows it was pushed. It never prints the values. It's one file, so read it before you run it:

$ curl -fsSLO https://raw.githubusercontent.com/nphardorworse/fidelius/main/skills/audit/scripts/audit.py$ python3 audit.py

In Claude Code, you can install it as a plugin with /plugin marketplace add nphardorworse/fidelius and /plugin install fidelius@fidelius, then run /fidelius:audit. It only sees this computer, so a clean result doesn't prove a key never leaked.

To check by hand, find the copies in your home folder (this skips ~/Library and can take a minute):

$ find ~ -path "$HOME/Library" -prune -o -path '*/.claude/settings.local.json' -type f -print 2>/dev/null

List what a file allows and any environment variables it sets, and look for passwords, tokens and connection strings:

$ jq '.permissions.allow, .env' .claude/settings.local.json

From the repo root, see whether git ignores it. If the source shown is your global excludes file, the protection stops at this machine. No output means no ignore rule covers it:

$ git check-ignore --no-index -v .claude/settings.local.json

See whether it's tracked now, and whether this clone's history has it, even if it's gone from the latest commit:

$ git ls-files -- .claude/settings.local.json$ git log --all --oneline -- .claude/settings.local.json .claude/settings.json

To search a whole GitHub organization, use org:your-org path:.claude/settings.local.json in GitHub's code search, then repeat for .claude/settings.json. It misses deleted files and other branches.

If you find a secret

Change the password or revoke the key first, then clean up. Removing the file from the latest commit leaves it in history, and in every fork and clone, so the old value has to stop working. The same goes for a committed .env file.

If the file is tracked, stop tracking it from the repo root, check git status, and commit:

$ git rm --cached .claude/settings.local.json$ printf '\n**/.claude/settings.local.json\n' >> .gitignore

The shared .claude/settings.json is meant to be committed, so there you delete the rule and commit the change. Then delete the rule from your local file too, even if it was never committed. The file can also leave in an npm package, a Docker image or a synced folder.

Stopping it from happening again

Keep literal values out of commands. Use a variable, or a runner that injects the key when the command starts. Expect a trade-off: in these runs, commands with a variable offered no rule to save, so each run needed approval, and constant prompts are how people stop reading them. A variable expanded into a command's arguments still reaches that command, so prefer tools that read the value from the environment or stdin.

Read the pattern before you accept it. curl * is a much bigger approval than the one command on your screen. /permissions lists every rule and lets you remove the ones you no longer want.

Put .claude/settings.local.json in each project's own .gitignore, so the protection travels with the repo. If you run a secret scanner in pre-commit or CI, point it at agent folders and git history, and check that it catches passwords inside commands, such as PGPASSWORD=, sshpass -p, mysql -p and bearer headers.

Where fidelius fits

fidelius is built on iCloud Keychain, with no vault or sync of its own. Once you add its instructions, Claude Code is told to run commands through accio, using the variable name, so a saved rule has no key in it as long as the agent follows those instructions.

For the wider picture, see can Claude Code read your .env file?