# Your Claude Code approvals can hold your API keys. Check your repo today

> Source: <https://dev.to/paxtechnologyservices/your-claude-code-approvals-can-hold-your-api-keys-check-your-repo-today-4g47>
> Published: 2026-12-05 17:05:42+00:00

**Recommendation:** Run git ls-files and git log --all on .claude/settings.local.json in every repo, scan with gitleaks, then untrack the file and add it to .gitignore.
More in the playbook "Securing agents and AI tools": <https://wpnews.pro/playbooks/agent-security>

You have clicked "Yes, and don't ask again" in Claude Code more times than you can count. Me too. It feels like a tiny productivity win.

Here is what happens next. Per the [Claude Code permissions docs](https://code.claude.com/docs/en/permissions), when you pick that option on something like a Bash command, Claude Code saves the rule to `.claude/settings.local.json` at the root of your git repository. If the command you approved had a token in it, the rule can have the token too.

That is not a theory. [Ars Technica reported on Nov 9, 2026](https://arstechnica.com/ai/2026/11/claude-code-settings-files-expose-thousands-of-secrets-on-github/) that researchers at Apiiro found over 100,000 Claude Code local settings files uploaded to public GitHub repos. Only about 1,100, from 63 organizations, held secrets such as API tokens, database passwords and private keys. Small share, real damage. And 215 of those secrets were not flagged by two popular scanners, gitleaks and TruffleHog.

Per the same report, a Claude Code team member said these files should pretty much never be checked into git, and that the team was looking into improvements. Behavior may have changed since, so check your version. In the meantime, here is a five-minute check you can run today.

In each repo where you use Claude Code:

```
git ls-files .claude/settings.local.json
```

If it prints the path, git is tracking it. No output is what you want. Then check history, because a file you deleted last month can still be in old commits:

```
git log --all --oneline -- .claude/settings.local.json
```

Scan the file with [gitleaks](https://github.com/gitleaks/gitleaks). The `--redact` flag keeps the secret itself out of your terminal output:

```
gitleaks dir --redact -v .claude
gitleaks git --redact -v .
```

The first scans the folder as it is now. The second scans every commit.

I tested this on a throwaway repo where I committed a fake GitHub-style token inside an approved `curl` command. gitleaks flagged it as `github-pat` in `.claude/settings.local.json` on line 1. That is the happy path. The Apiiro numbers above are why you should not stop here. Scanners know patterns, and 215 secrets slipped past two of them.

So also read the file yourself. Open it and look at every `Bash(...)` rule for anything that looks like a key, a password or a URL with credentials in it. It is usually short.

Point this at the folder where you keep code:

```
find ~/code -path '*/.claude/settings.local.json' -not -path '*/node_modules/*' 2>/dev/null |
while read -r f; do
  repo=$(git -C "$(dirname "$f")" rev-parse --show-toplevel 2>/dev/null) || continue
  if git -C "$repo" log --all --oneline -- .claude/settings.local.json | grep -q .; then
    echo "IN HISTORY  $repo"
  fi
done
```

Every line it prints is a repo where that file is, or once was, in git. Repos it does not list are fine on this check.

```
git rm --cached .claude/settings.local.json
echo '.claude/settings.local.json' >> .gitignore
git add .gitignore
git commit -m "Stop tracking local Claude Code settings"
```

`/permissions`.
Claude Code's own docs add one more reason to keep the file out of git: if `.claude/settings.local.json` is tracked, it is treated as repository-supplied instead of your own, and its rules are held until you trust the folder. A tracked file is not how it is meant to be used.

If the thing that leaked was a **wallet private key or seed phrase**, moving funds comes before anything else, and the rotation advice above does not apply, because a key cannot be rotated the way an API token can. If you hold crypto and want the scam side covered too, the free [Don't Get Drained guide](https://paxtechservices.gumroad.com/l/dont-get-drained?utm_source=devto&utm_medium=article&utm_campaign=claude-approvals-secrets) is a short read on spotting fake support DMs and claim links.

`curl -H "Authorization: Bearer $API_TOKEN" ...` and keep the value in your environment. Since the command text is what gets saved, the rule then holds the variable name, not the token.`Read(./.env)` deny rule, plus patterns like `Read(./secrets/**)`. They are also clear that these rules are not a complete block, for example they do not stop a script that opens files itself. For a hard limit, turn on the `.pre-commit-config.yaml`, then run `pre-commit install`:

```
repos:
  - repo: https://github.com/gitleaks/gitleaks
    rev: v8.24.2
    hooks:
      - id: gitleaks
```

Run `pre-commit autoupdate` to bump that version. You can also use `gitleaks git --staged --redact .` as a manual check.

| Control | Helps with | Does not help with | 
|---|---|---|
| `.gitignore` for the file | Accidental `git add .` | Files already committed earlier | 
| gitleaks `dir` /`git` | Known token formats, in files and history | Secrets in formats it does not know (the 215 above) | 
| Pre-commit hook | Catching it before the commit exists | Anyone who skips the hook | 
| GitHub push protection | Known secret types at push time | Unknown formats, and pushes where someone bypasses it | 
| Env vars instead of inline values | Keeping values out of saved rules | A key you already typed in | 
| Rotation | Any exposed API token or password | Wallet keys, and leaks you do not know about yet | 

Start with the free [Agent Blast Radius Checklist](https://paxtechservices.gumroad.com/l/agent-blast-radius?utm_source=devto&utm_medium=article&utm_campaign=claude-approvals-secrets). It is 9 pages for seeing what your coding agent can read, run and reach, then cutting it down.

If your agents also touch wallets, API tokens or signing power, [Agent Security When Agents Hold Keys](https://paxtechservices.gumroad.com/l/agent-security-keys-signing?utm_source=devto&utm_medium=article&utm_campaign=claude-approvals-secrets) ($12) is the plain-English playbook for shrinking the blast radius. All ten PTS AI + blockchain guides are in one [$39 bundle](https://paxtechservices.gumroad.com/l/ai-blockchain-guides-bundle?utm_source=devto&utm_medium=article&utm_campaign=claude-approvals-secrets), and there is a free [AI + Blockchain Map](https://paxtechservices.gumroad.com/l/ai-blockchain-map?utm_source=devto&utm_medium=article&utm_campaign=claude-approvals-secrets) if you want a 10-minute start.

The newsletter is at [https://paxtechservices.substack.com](https://paxtechservices.substack.com) if you want more notes like this.

*I'm PTS, an IT and security consulting shop. Corrections welcome in the comments. Not affiliated with Anthropic or GitHub. Educational only, not legal or financial advice.*
