The password your coding agent wrote down
One click on "don't ask again" saves the command, password included, to .claude/settings.local.json. A public GitHub scan found 1,122 with a real secret.
Published
You ask Claude Code to check why the staging migration failed. It wants to run PGPASSWORD=... psql -h db.staging... -c "select ...", you click "Yes, and don't ask again" so the next ten queries go through, and the session goes on. That click saved the command, password included, as an allow rule in .claude/settings.local.json at the root of the repository. Months later someone runs git add -A in a clone where that file is not ignored, and the password is on GitHub.
Apiiro looked for that file on public GitHub between November 1 and 3, 2026 and published the results on November 5: Coding Agents Copy Your Secrets to a Hidden File. Thousands Are on GitHub. This guide gives their numbers, what Claude Code's documentation says about the file, the other places where agents write down what they ran or learned, a script that checks those places on your machine without printing a value, and what our own memory server caught and missed when we sent it the same lines.
What the scan found
| Count | |
|---|---|
Public copies of .claude/settings.local.json | 104,185, in 103,617 repositories |
| Files with at least one real secret | 1,122 (1.1%) |
| Distinct secrets in those files | 1,379: 636 provider keys, 743 passwords and tokens for public hosts |
| Database passwords | 379 |
| Supabase service-role keys / account tokens | 122 / 103 |
| SSH logins | 43 |
| GitHub, GitLab and npm tokens | 42 |
| AWS keys | 23 |
| Private keys | 6 |
| Secrets in git history, not in the current copy | 734, in 509 repositories |
| Distinct real secrets in total | 2,539, in 1,994 repositories |
Apiiro says it did not use or test any of the credentials. A few details change what you should do:
- Size predicts it. One file in ten above 8 KB had a secret, against fewer than one in 500 under 500 bytes. A long allow list is a long history of approved commands.
- The files stay. In the median repository with a real secret, the file was first committed 217 days before November 2; in 118 repositories, more than a year before. 211 forks of 74 repositories carried someone else's secret along.
- The agent touched the file. In 539 of the 1,105 repositories they could trace, a commit co-authored by Claude changed it.
- Scanners missed a fifth of them. Of the 1,122 files, gitleaks flagged 564 and TruffleHog 643, and 215 were flagged by neither. The gap is the shape: a provider key has a recognizable prefix, a password inside a command does not.
PGPASSWORD=,sshpass -p,mysql -pand a bearer header with an opaque token look like any other argument. - It is not one file. The same search found secrets in shared
.claude/settings.json(298 of 76,011 files), in exported agent chat transcripts such as.specstory, aider and Cursor exports (120 files in 87 repositories), in agent memory files such asMEMORY.md(9 repositories), in handoff and deploy notes (33 files, a third of them written by the agent itself) and in VS Code Copilot auto-approve settings (9 repositories).
Of the 16 coding agents whose documentation Apiiro compared, Claude Code was the only one confirmed to write the full approved command to a project file by default. In the report's November 8 update, Apiiro quotes Boris Cherny, Anthropic's head of Claude Code, replying on Hacker News on November 7: "Historically Claude Code has not done secret scrubbing (there are many good tools for that), but we are looking into what we can do to prevent this." The approaches he named were making auto mode catch it and building in basic secret scanning. He also said Claude Code adds the file to the global git excludes when it creates it, so in his view the exposed copies were created by hand and committed, and he recommended auto mode over permission rules and the secret scanning that GitHub and other hosts offer.
What Claude Code's documentation says about the file
The settings page and the permissions page, read on December 4, 2026, describe this:
- "Yes, and don't ask again" on a Bash command saves an
allowrule in.claude/settings.local.jsonat the root of the git repository. Started in a subdirectory or a worktree, Claude Code still uses the file at the main checkout's root, and the rule applies to the whole repository. - A rule without
*matches one exact command, and approving a compound command saves one rule per subcommand. Apiiro reproduced what that means for a password: the saved rule is the command string, password included. - "The first time Claude Code writes the file in a git repository that doesn't already ignore it, it adds
**/.claude/settings.local.jsonto your global git excludes file." That file iscore.excludesFile, or$XDG_CONFIG_HOME/git/ignore, or~/.config/git/ignore. - "If you created the file by hand and Claude Code hasn't written to it yet, add it to
.gitignoreyourself." - When the file is tracked in git, Claude Code treats it as supplied by the repository and holds its rules until you trust the folder.
So the protection lives in your global git config, on one machine. It does not travel with the repository. A teammate's clone, a CI runner, a container, a second laptop, a file written before git init, a file copied from another project or created by hand: none of those is covered until something writes the exclude there too. The repository's own .gitignore is the only line every clone reads.
Check your machine
agent-secret-sweep.py looks in the places agents write down what they ran or learned: .claude/settings.local.json and .claude/settings.json, MEMORY.md and ~/.claude/projects/*/memory, CLAUDE.md and AGENTS.md, handoff and deploy notes, .specstory transcripts and files under .cursor/ and .gemini/. It checks provider key formats and the shapes that scanners tend to miss: PGPASSWORD=, MYSQL_PWD=, SSHPASS=, sshpass -p, mysql -p, --password, bearer headers, *_PASSWORD= and *_TOKEN= assignments, and "password is ..." in prose. A $VAR or ${VAR} is not reported: that is the fix.
It never prints a value, only the file, the line, the kind and the length, and for each file what git will do with it. Standard library only. Read it before you run it.
curl -fsSLO https://docs.valorbrain.com.br/guides/agent-secret-sweep.py
# the current repository and Claude Code's per-project memory
python3 agent-secret-sweep.py
# every repository under ~/code
python3 agent-secret-sweep.py ~/code ~/.claude/projectsIn our lab, four repositories with fake 12-character passwords on made-up hosts, each in a different git state, and one memory file:
api/.claude/settings.local.json
git: TRACKED by git (it is in the next push)
line 5: env-password-in-command (12 chars)
home/.claude/projects/-tmp-infra/memory/MEMORY.md
git: not in a git repo
line 1: bearer header (20 chars)
infra/.claude/settings.local.json
git: ignored by your global ignore only (a clone elsewhere is not covered)
line 1: mysql -p (12 chars)
infra/HANDOFF.md
git: UNTRACKED and NOT ignored (git add -A takes it)
line 3: prose password (12 chars)
line 4: assigned secret (12 chars)
web/.claude/settings.local.json
git: NOT tracked now, but IN GIT HISTORY
line 5: sshpass -p (12 chars)
Scanned 5 agent files, 6 possible secret(s).
Rotate first, then delete the rule or line. Write $VAR in commands so the agent records the name, not the value.It exits 1 when it finds something, so it can run in a pre-commit hook or a CI step. The same rule in infra written as psql "$DATABASE_URL" was not reported. On our own working folders and Claude Code's project memory it scanned 38 agent files and found nothing; it is a pattern match, so treat a clean run as "nothing with these shapes", not as proof.
What to change
If the sweep finds something. Rotate the credential first: once it was pushed to a public repository, deleting it does not take it back. Then delete the rule or the line, git rm --cached .claude/settings.local.json if it is tracked, and add the file to the repository's .gitignore. Rewriting history is optional once the credential is dead.
In every repository. Put these in .gitignore, so every clone has them and not only your laptop:
**/.claude/settings.local.json
.specstory/
CLAUDE.local.mdThe **/ is what matters in the first line. A pattern with a slash in the middle, such as .claude/settings.local.json, only matches relative to the .gitignore it lives in. In a monorepo where someone started Claude Code inside api/ or web/, the file in those folders is not ignored. With **/ it matches at any depth, and it is the same line Claude Code adds to your machine's global excludes. If your organization has a .gitignore template, add them there.
In the commands you approve. Approve a pattern, not a command: Bash(npm run test *) instead of the full line with its arguments. Keep credentials in the environment and write psql "$DATABASE_URL" or PGPASSWORD="$PGPASSWORD", so the allow rule records a name. Before you click "don't ask again", read the command on the prompt once.
In what agents write down. Treat .claude/, .cursor/, .gemini/, .specstory/, memory files and handoff notes as files that can hold secrets. A line in CLAUDE.md or AGENTS.md such as "never write a credential value in notes, memory or handoff files; write the variable name" costs nothing and covers the notes the agent writes by itself.
In your scanners. Turn on your host's secret scanning and push protection. Check that your pre-commit scanner catches passwords inside commands, not only provider prefixes: generate a few fake lines with python3 agent-secret-sweep.py --canaries and run your scanner over them.
Where ValorBrain fits
ValorBrain is a memory server for teams of agents, reached over MCP from Claude Code, Codex, Cursor and other clients. When agents write their notes, decisions and handoffs to it instead of to files in the repository, those notes are not in anyone's git add -A.
On every write (MCP, REST, and the notes it consolidates on its own), it runs a secret detector over the title and body. What it finds is moved to an encrypted secret store and the stored note keeps a reference such as secret://db-staging-password in its place, so an agent that reads the note later gets the name, not the value. When the store cannot keep it, the value is redacted.
We sent the detector the same kinds of lines the sweep looks for, with values generated at random. On the first run, on the morning of December 4, 2026, it caught four of ten: a provider key in a curl header, a token inside a git clone URL, a database connection string with the password in it, and password: followed by a long random value. It missed PGPASSWORD= before psql, sshpass -p, mysql -p, a bearer header with an opaque 20-character token, a 12-character password in a sentence, and DATABASE_PASSWORD= with a 12-character value. That was the same gap the public scan found in gitleaks and TruffleHog. The fix went to production the same day, at 11:33 BRT (UTC−3): the detector gained patterns for passwords inside commands, --password flags, opaque bearer headers and passwords in a sentence, and its test suite now catches all ten lines, with no copy of the value left in the note. Two caveats. Notes written before the fix were not rescanned, because the detector runs on new writes only. And no detector catches every shape, so the line in CLAUDE.md is still what keeps the value out of the notes in the first place.
To keep notes about a database without the password in them, write where the credential lives, under a key:
{
"tool": "upsert_keyed_fact",
"arguments": {
"fact_key": "infra.staging_db.credential",
"fact_value": "Agents connect with psql \"$DATABASE_URL\"; the value is in the team vault as STAGING_DATABASE_URL. Never paste it into a command or a note.",
"as_of": "2026-12-04",
"evidence": "rotated after agent-secret-sweep found it in an allow rule",
"authority": "agent"
}
}Create a workspace from the terminal (this also works from inside an agent session):
npx -y @valorbrain/cli@latest init --agent --ref docs-secrets-coding-agents-write-into-repo-files --agent-caller claude-code --jsonOr connect an existing workspace to your tools:
npx -y @valorbrain/connect@latest --token <vbm_…> --harness <claude-code|codex|cursor>The token that connect uses goes in your environment or your client's config, not in a file you commit: Share an MCP server config without committing the token shows how in each client. Plans are on the pricing page.
What ValorBrain does not do
- It does not touch your repository.
.claude/settings.local.jsonis written by Claude Code on your disk. ValorBrain never sees it, and cannot remove a rule or stop a push. - It does not catch every shape. The ten lines above are caught since December 4, 2026, but a shape nobody anticipated goes through as written, and notes from before that date were not rescanned.
- It does not rotate anything. A credential that was pushed has to be rotated by whoever owns it.
What we ran and what we did not
We read Apiiro's report (published November 5, updated November 8) and did not repeat their GitHub search; every count in the first section is theirs. We read the Claude Code settings and permissions pages; Claude Code 2.1.329 and Codex CLI 0.156.1 were installed on the lab machine, but no model call ran and we did not click a real permission prompt, so what Claude Code writes is what its documentation says, not something we observed. The sweep ran on a lab with an isolated git configuration, four repositories in four git states and fake passwords on hosts under example.com, then on our own working folders. The detector test ran ValorBrain's detection function from its source at the current commit with randomly generated values, not through a live workspace. We did not test Cursor, Gemini CLI, Copilot auto-approve or Windows paths.
Checklist
.claude/settings.local.json,.specstory/andCLAUDE.local.mdare in each repository's.gitignore, not only in your global excludes.- Allow rules are patterns (
Bash(npm run test *)), and commands name credentials as$VAR. agent-secret-sweep.pyran on your machine; anything it found was rotated before it was deleted.CLAUDE.mdorAGENTS.mdtells agents to write variable names, never values, in notes, memory and handoffs.- Your host's secret scanning and push protection are on, and your pre-commit scanner catches the
--canarieslines. - Memory, notes and handoffs live where a
git add -Adoes not reach them.
Sources, read on December 4, 2026: Apiiro, Coding Agents Copy Your Secrets to a Hidden File. Thousands Are on GitHub (November 5, 2026, updated November 8); Claude Code, Settings and Configure permissions.
Next: Share an MCP server config without committing the token for the other credential that ends up in a repository, Memory poisoning in shared agent memory for what else should not get into shared notes, and Handoff between coding agents for what a handoff should carry instead.
Your agent remembers the old way to call the tool: what happens when an MCP server renames a field
An MCP server renames attendees to guests, the agent still sends attendees, the server says the event was created, and the agent tells you it is done. What a new paper measured across six models, what we saw in Claude Code, Codex and the official MCP SDKs, a script that catches the change before your agents do, and what to change on each side.
Claude Dispatch turns off: what to save, what stops
Dispatch turns off in stages. What Copy to project and Download keep, the size caps, the scheduled tasks that stop, and a script that backs it up first.