Skip to content
VibeSafeDaily

Secrets

Your database password is saved in Claude Code's local settings file

Cataloged November 13, 2026 · Cursor · Supabase

Symptom

A Bash command you approved in Claude Code can be saved, password and all, in this project's .claude/settings.local.json. This applies if you run Claude Code, for example in a terminal while you build. Claude Code is not a Cursor feature. The Claude Code docs page "Settings files and precedence" says the project local file is .claude/settings.local.json. It says "When Claude asks permission to run a Bash command and you choose "Yes, and don't ask again", Claude Code saves that permission approval here as an allow rule." The same page says "You, in this one project only. Claude Code keeps it out of git when it creates the file; if you create it by hand, add it to .gitignore yourself." The Hacker News article "Claude Code's 'Don't Ask Again' File Exposes Passwords and Keys in 1,122 Public Copies on GitHub" (November 7, 2026) says that when a user selects "Yes, and don't ask again", Claude Code can save the command word for word, including the secret, in that project settings file. The rule covers only what the prompt offered: sometimes a pattern such as npm test *, sometimes one exact command. When it is the exact command, any password or token typed into it is saved too, in plain text. That article says the global git excludes protection stays in one user's git settings on one computer. It does nothing for a file already committed, and Claude Code never adds the file to the project's own .gitignore, so the protection does not travel with the project. The GitLab blog "How to prevent leaks from Claude Code's 'Don't ask again' file" (November 11, 2026) says Claude Code keeps the file out of Git through the developer's personal global excludes, not the project's .gitignore. That protection lives on one laptop and does not travel with the repository. The Hacker News article says Apiiro found 104,185 public copies of the file in 103,617 repositories. 1,122 hold at least one secret, 1,379 different secrets total. More than a third open a database directly, including 379 database passwords. LATENT's article "Claude Code's 'Don't ask again' and secrets in public repositories" (November 8, 2026) says that, per Apiiro's breakdown, those 1,379 secrets included 122 Supabase service-role keys and 103 Supabase account tokens. The Hacker News article also says to treat agent folders such as .claude/, .cursor/, .gemini/, and .specstory/ as holding secrets, like .env files.

Root cause

In a git repository, the Claude Code docs page "Settings files and precedence" says Claude Code reads and writes .claude/settings.local.json at the repository root. That page says the first time Claude Code writes the file in a git repository that doesn't already ignore it, it adds **/.claude/settings.local.json to your global git excludes file (core.excludesFile, otherwise $XDG_CONFIG_HOME/git/ignore or ~/.config/git/ignore). The same page says that in the VS Code extension the approval card lets you pick the destination file, including the project's shared .claude/settings.json, which changes the rule for everyone. In the CLI, Claude Code writes only to your local file. The Hacker News article "Claude Code's 'Don't Ask Again' File Exposes Passwords and Keys in 1,122 Public Copies on GitHub" (November 7, 2026) says Apiiro found 104,185 public copies of the file in 103,617 repositories. 1,122 hold at least one secret, 1,379 different secrets total. Apiiro did not test whether they still work. One notified company confirmed its key had been live. More than a third open a database directly, including 379 database passwords. LATENT's article "Claude Code's 'Don't ask again' and secrets in public repositories" (November 8, 2026) says that, per Apiiro's breakdown, those 1,379 secrets included 122 Supabase service-role keys and 103 Supabase account tokens. The Hacker News article says older versions of the file hold 734 more secrets across 509 repositories not in any current copy. Removing the file does not undo the leak, because older versions stay in git history and forks. Of the 1,122 files, that article says gitleaks flagged 564, TruffleHog 643, and neither flagged 215. Most misses are passwords typed inside commands, after PGPASSWORD=, sshpass -p, or mysql -p. The docs' example denies reading env files with the permissions.deny rules "Read(./.env)" and "Read(./.env.*)", and it approves patterns like "Bash(npm run test *)". The Hacker News article's steps are to check your own repos and their git history for .claude/settings.local.json and .claude/settings.json, rotate every password, token, and key the files ever held before cleaning up, stop tracking with git rm --cached .claude/settings.local.json, and add the file to the repository's own .gitignore. Open the file on your own computer even if it was never committed, and delete every rule that contains a secret. Keep secrets out of commands. Refer to them as variables such as $DB_URL so the saved rule holds the variable name. Approve patterns such as Bash(npm run:*) instead of single commands. That article says the file can also be left inside an npm package, Docker image, zip archive, or synced folder. LATENT lists three commands for your own repo: git ls-files .claude, git check-ignore -v .claude/settings.local.json, and git log --all --oneline -- .claude/settings.local.json .claude/settings.json. For an npm package, LATENT says to exclude .claude/ via files or .npmignore. For Docker, exclude it via .dockerignore. LATENT says GitHub's documentation says to revoke or rotate a secret before removing it from history, and that rewriting history does not remove it from forks or other clones.

Before and after

The before line is not a rule copied from a repository. It is the shape The Hacker News article describes when the allow rule is one exact command and a password was typed into it. That article says the password is saved in plain text. The angle brackets around password are a placeholder, not a password, and user, host, and db are not a real database. The after line follows that article's advice to refer to the secret as a variable, so the saved rule holds the variable name. The article's example variable is $DB_URL. $DATABASE_URL here is a variable name of that kind. The Claude Code docs' example of an allow rule is the pattern "Bash(npm run test *)", and the article says to approve patterns such as Bash(npm run:*) instead of single commands. This pair shows the placeholder secret and the variable name. It does not show those patterns.

Before

Bash(psql postgres://user:<password>@host/db ...)

After

Bash(psql $DATABASE_URL)

Fix prompt

In this project only. Do not scan or test anyone else's app or repository. Do not search GitHub, GitLab, or any other host for copies of this file. Do not print keys, tokens, passwords, database URLs that contain a password, or environment variable values. When you mention a variable, print the name only. Do not print an allow rule that contains a secret. If a rule contains one, print the file name and say that a rule contains a secret.

1. This prompt applies if I run Claude Code in this project, for example in a terminal while I build. Claude Code is not a Cursor feature. If I do not run Claude Code here, say so. Still look, in this project only, at the agent folders in step 10. The Hacker News article "Claude Code's 'Don't Ask Again' File Exposes Passwords and Keys in 1,122 Public Copies on GitHub" (November 7, 2026) says to treat agent folders such as .claude/, .cursor/, .gemini/, and .specstory/ as holding secrets, like .env files.

2. In this project only, say whether .claude/settings.local.json and .claude/settings.json exist. The Claude Code docs page "Settings files and precedence" says the project local file is .claude/settings.local.json. In a git repository, that page says Claude Code reads and writes that file at the repository root. Do not print the file contents.

3. Run only these three commands, in this repository only, and paste their output. LATENT's article "Claude Code's 'Don't ask again' and secrets in public repositories" (November 8, 2026) lists them for your own repo.

git ls-files .claude
git check-ignore -v .claude/settings.local.json
git log --all --oneline -- .claude/settings.local.json .claude/settings.json

Do not run git show, git log -p, git diff, or cat on those files. Do not run these commands in any other repository.

4. Read the current files and, if the log printed commits, read those versions in this repository only. Do not print them. Say whether any version contains a secret. The Hacker News article says to rotate every password, token, and key the files ever held before cleaning up. LATENT says GitHub's documentation says to revoke or rotate a secret before removing it from history, and that rewriting history does not remove it from forks or other clones. If any version contains a secret, name the kind when the file names the kind, such as a database password, a Supabase service-role key, or a Supabase account token. LATENT says that, per Apiiro's breakdown, the 1,379 secrets in public copies included 122 Supabase service-role keys and 103 Supabase account tokens. Those counts are not a count of this project. Do not print a value. Do not test whether a key still works. The Hacker News article says Apiiro did not test whether the secrets it found still work, and that one notified company confirmed its key had been live. Do not call a provider with a secret. Tell me to rotate the secrets myself, in accounts I own, and stop until I say that rotation is done. If no version contains a secret, say so and continue.

5. After any required rotation, if git ls-files listed .claude/settings.local.json, run git rm --cached .claude/settings.local.json. The Hacker News article lists that command. Leave the working copy on disk. If .claude/settings.local.json exists, or git log listed it, add .claude/settings.local.json to this repository's own .gitignore when that line is absent. The docs say "if you create it by hand, add it to .gitignore yourself." The Hacker News article says Claude Code never adds the file to the project's own .gitignore. The GitLab blog "How to prevent leaks from Claude Code's 'Don't ask again' file" (November 11, 2026) says Claude Code keeps the file out of Git through the developer's personal global excludes, not the project's .gitignore, and that this protection lives on one laptop and does not travel with the repository. The docs say the first time Claude Code writes the file in a git repository that doesn't already ignore it, it adds **/.claude/settings.local.json to your global git excludes file (core.excludesFile, otherwise $XDG_CONFIG_HOME/git/ignore or ~/.config/git/ignore). Do not edit that global excludes file. Do not create .claude/settings.local.json. Show me the .gitignore diff only. Do not commit unless I ask. Do not rewrite history. If I ask you to rewrite history, stop and repeat that rotation comes first and that LATENT says rewriting history does not remove a secret from forks or other clones.

6. On this computer, open .claude/settings.local.json even if it was never committed. Delete every rule that contains a secret. The Hacker News article says to do that. Do not print the deleted text. Tell me the file name and how many rules you removed. The same article says most misses are passwords typed inside commands, after PGPASSWORD=, sshpass -p, or mysql -p. Look for those. Of the 1,122 files with at least one secret, that article says gitleaks flagged 564, TruffleHog 643, and neither flagged 215. Do not run gitleaks or TruffleHog. Do not treat a scanner result as the check.

7. Where this project's own scripts pass a password or token on a command line, change the command so it names a variable such as $DB_URL. The Hacker News article says to keep secrets out of commands and to refer to them as variables such as $DB_URL, so the saved rule holds the variable name. Use a variable name this project already has. Do not put a secret value in the command. Where an allow rule is one exact command that contains a secret, delete that rule in step 6. The article says to approve patterns such as Bash(npm run:*) instead of single commands. The docs' example approves patterns like "Bash(npm run test *)". If I still need an allow rule for an npm script, write a pattern of that kind, with no secret in it, in .claude/settings.local.json. Show me the script diff. Print variable names only. Do not show a diff of either settings file.

8. The docs' example denies reading env files with the permissions.deny rules "Read(./.env)" and "Read(./.env.*)". If .claude/settings.local.json exists, add those two strings to permissions.deny when they are absent. Do not add any other deny rule. The docs say that in the VS Code extension the approval card lets you pick the destination file, including the project's shared .claude/settings.json, which changes the rule for everyone, and that in the CLI Claude Code writes only to the local file. Do not add an allow rule to .claude/settings.json. If .claude/settings.json contains a rule with a secret, do not print the rule. Tell me the file name, that a rule contains a secret, and to rotate that secret before the rule is deleted. Delete it only after I say the secret is rotated. Do not show a diff of either settings file.

9. If this project publishes an npm package, exclude .claude/ the way LATENT says: via the files field or .npmignore. If .npmignore exists, add .claude/ to it. If package.json has a files field, remove .claude/ from that list if it is there. If neither exists, say so, and do not create a files list. If this project has a Dockerfile, exclude .claude/ via .dockerignore, as LATENT says. If .dockerignore exists, add .claude/. If a Dockerfile exists and .dockerignore does not, create .dockerignore with the single line .claude/. The Hacker News article says the file can also be left inside a zip archive or a synced folder. If a script in this project builds a zip or copies a folder for sync, tell me its path and whether it includes .claude/. Change that script only when it includes .claude/, and show me that diff. Show me diffs for .npmignore, package.json, and .dockerignore when you edit them.

10. In this project only, say whether the folders .cursor/, .gemini/, and .specstory/ exist. The Hacker News article says to treat those folders, and .claude/, as holding secrets, like .env files. Do not print file contents. If a file in one of those folders contains a password, token, or key, print the file name only and tell me to rotate that secret. Do not delete those files unless I ask.

Do not print keys. Do not edit unrelated files.

Paste this into the coding tool that has your own project open.

2-minute self-check

These steps are for an app you own. Do not run them against someone else's project.

  1. In your own repo, run git ls-files .claude. LATENT's article "Claude Code's 'Don't ask again' and secrets in public repositories" (November 8, 2026) lists that command for your own repo. A listed .claude/settings.local.json or .claude/settings.json is tracked. Do not run this in anyone else's repo, and do not search public repositories for copies of the file.
  2. In your own repo, run git check-ignore -v .claude/settings.local.json. LATENT lists that command. The Claude Code docs page "Settings files and precedence" says the first time Claude Code writes the file in a git repository that doesn't already ignore it, it adds **/.claude/settings.local.json to your global git excludes file (core.excludesFile, otherwise $XDG_CONFIG_HOME/git/ignore or ~/.config/git/ignore). The GitLab blog "How to prevent leaks from Claude Code's 'Don't ask again' file" (November 11, 2026) says that protection lives on one laptop and does not travel with the repository. Open this repo's .gitignore and confirm it names .claude/settings.local.json. The Hacker News article "Claude Code's 'Don't Ask Again' File Exposes Passwords and Keys in 1,122 Public Copies on GitHub" (November 7, 2026) says Claude Code never adds the file to the project's own .gitignore. Do not run this in anyone else's repo.
  3. In your own repo, run git log --all --oneline -- .claude/settings.local.json .claude/settings.json. LATENT lists that command. If it prints a commit, the Hacker News article says removing the file does not undo the leak, because older versions stay in git history and forks. That article says older versions hold 734 more secrets across 509 repositories not in any current copy. Rotate every password, token, and key those files ever held before you clean up. LATENT says GitHub's documentation says to revoke or rotate a secret before removing it from history, and that rewriting history does not remove it from forks or other clones. Do not print a secret from a commit, and do not run this in anyone else's repo.
  4. On your own computer, open .claude/settings.local.json even if it was never committed. The Hacker News article says to delete every rule that contains a secret, and that most misses are passwords typed inside commands, after PGPASSWORD=, sshpass -p, or mysql -p. Of the 1,122 files with at least one secret, that article says gitleaks flagged 564, TruffleHog 643, and neither flagged 215. Do not paste the file anywhere, and do not print a secret.
  5. If a rule in your own .claude/settings.local.json or .claude/settings.json contains a database password, a Supabase service-role key, or a Supabase account token, rotate it in a project you own before you delete the rule. LATENT says Apiiro's breakdown of the 1,379 secrets included 122 Supabase service-role keys and 103 Supabase account tokens. The Hacker News article says Apiiro did not test whether they still work, and that one notified company confirmed its key had been live. Those counts are about public copies. They are not a count of secrets in your file. Do not print the key, and do not open a Supabase project you do not own.
  6. If you publish an npm package from this project, confirm .claude/ is excluded via the files field or .npmignore. If you build a Docker image from this project, confirm .claude/ is listed in .dockerignore. LATENT lists those exclusions. The Hacker News article says the file can also be left inside a zip archive or a synced folder. Check archives and synced folders this project publishes. In this project, treat .cursor/, .gemini/, and .specstory/ the same way when those folders exist. That article says to treat agent folders such as .claude/, .cursor/, .gemini/, and .specstory/ as holding secrets, like .env files. Claude Code is not a Cursor feature. Do not inspect a package or a repo you do not own.

Common questions

I chose "Yes, and don't ask again". Did that save my database password?

It can. The Claude Code docs page "Settings files and precedence" says: "When Claude asks permission to run a Bash command and you choose "Yes, and don't ask again", Claude Code saves that permission approval here as an allow rule." That file is .claude/settings.local.json. The Hacker News article "Claude Code's 'Don't Ask Again' File Exposes Passwords and Keys in 1,122 Public Copies on GitHub" (November 7, 2026) says Claude Code can save the command word for word, including the secret. The rule covers only what the prompt offered. Sometimes that is a pattern such as npm test *. Sometimes it is one exact command. When it is the exact command, any password or token typed into it is saved too, in plain text. This applies if you run Claude Code, for example in a terminal while you build. Claude Code is not a Cursor feature.

Claude Code already keeps that file out of git. Why add it to .gitignore?

The docs page "Settings files and precedence" says "Claude Code keeps it out of git when it creates the file; if you create it by hand, add it to .gitignore yourself." The same page says the first time Claude Code writes the file in a git repository that doesn't already ignore it, it adds **/.claude/settings.local.json to your global git excludes file (core.excludesFile, otherwise $XDG_CONFIG_HOME/git/ignore or ~/.config/git/ignore). The GitLab blog "How to prevent leaks from Claude Code's 'Don't ask again' file" (November 11, 2026) says Claude Code keeps the file out of Git through the developer's personal global excludes, not the project's .gitignore, and that protection lives on one laptop and does not travel with the repository. The Hacker News article says that global excludes protection stays in one user's git settings on one computer, it does nothing for a file already committed, and Claude Code never adds the file to the project's own .gitignore. Add .claude/settings.local.json to this repository's .gitignore. If the file is already tracked, that article says to stop tracking it with git rm --cached .claude/settings.local.json, and to rotate every password, token, and key the file ever held before you clean up.

I deleted the file. Do I still have to rotate the password?

Rotate it when the file ever held it, including a copy that was never committed. The Hacker News article says to rotate every password, token, and key the files ever held before cleaning up, and to open the file on your own computer even if it was never committed and delete every rule that contains a secret. That article says older versions of the file hold 734 more secrets across 509 repositories that are not in any current copy. Removing the file does not undo the leak, because older versions stay in git history and forks. LATENT's article "Claude Code's 'Don't ask again' and secrets in public repositories" (November 8, 2026) says GitHub's documentation says to revoke or rotate a secret before removing it from history, and that rewriting history does not remove it from forks or other clones. The Hacker News article also says the file can be left inside an npm package, Docker image, zip archive, or synced folder. Rotate first, on accounts you own. Do not search anyone else's repositories. Apiiro did not test whether the secrets it found still work. One notified company confirmed its key had been live. Of the 1,122 files with a secret, that article says gitleaks flagged 564, TruffleHog 643, and neither flagged 215.

Sources

Same symptom

Same platform