A permission prompt looks temporary. A saved permission is not.
In Claude Code, choosing Yes, and don't ask again for a Bash command can create an allow rule in .claude/settings.local.json. Current Claude Code documentation says that rule is saved at the repository root and applies to future sessions throughout that repository. If the command contains a token, password, connection string, or credential-bearing header, the approval file can preserve the secret after the command has finished.
The useful security question is therefore broader than whether an agent may run a command. It is: which representation of that command survives, where can it travel, and what proves that it did not become durable sensitive data?
The permission boundary has a data path
Consider a troubleshooting command:
PGPASSWORD="$DB_PASSWORD" psql -h db.example.internal -U app -c 'select 1'
The safer form still refers to a secret, but the durable command contains a variable name rather than its value. Compare it with a literal password pasted into the command. If that literal is saved as an allow rule, the data can move through several layers:
- The agent proposes a command containing the secret.
- The user grants a standing approval.
- Claude Code writes the command pattern into a local settings file.
- Git, an archive, a container build, a sync tool, or a packaging step copies the file.
- Deleting the current file leaves earlier Git objects, forks, clones, caches, or published artifacts untouched.
This is a repository data-flow problem. The permission decision controls execution; the saved rule also becomes content.
Claude Code's current settings documentation includes an important protection: when Claude Code creates .claude/settings.local.json in a Git repository, it adds **/.claude/settings.local.json to the user's global Git excludes file. That covers the normal creation path on that machine. The same documentation identifies boundaries: a file created manually needs its own ignore rule, and a project-local file is meant to remain personal rather than shared.
A global exclude is useful local state. It is not a repository policy. It does not travel with a clone, remove an already tracked file, clean history, or prevent another build system from copying the directory.
What the November 2026 scan establishes
Apiiro reported scanning 104,185 public copies of .claude/settings.local.json across 103,617 GitHub repositories. Its November 5, 2026 report says 1,122 files, about 1.1%, contained what it classified as a real secret. The report attributes 1,379 distinct secrets to those current files and says another 734 appeared only in earlier versions of files in Git history.
Those are Apiiro's measurements, not an independent reproduction by this article. The report defines its detections as provider-formatted keys or passwords and tokens paired with public hosts. It also reports running Gitleaks and TruffleHog across the 104,185 files: 215 of the 1,122 secret-bearing files were flagged by neither tool.
The mechanism behind that gap is plausible and operationally important. Provider keys often have recognizable prefixes. A normal-looking password embedded after PGPASSWORD=, sshpass -p, mysql -p, or an HTTP header may have no distinctive token format. GitHub's current supported-pattern documentation distinguishes provider patterns, generic patterns, and AI-detected passwords, and notes that capabilities such as push protection and validity checks vary by pattern and plan.
The conclusion should stay narrow: format-aware scanning is necessary, and command-context inspection is a separate control.
Three gates before a secret becomes history
Gate 1: approval-time inspection
Review the exact command that a standing approval will preserve. A good rule passes three checks:
- it refers to secrets through environment variables, files with controlled permissions, short-lived credential helpers, or a secret manager;
- it grants the smallest stable command pattern needed for the task;
- it contains no literal credential, bearer value, connection string, signed URL, private host credential, or copied production output.
Use one-time approval when a command cannot meet those conditions. A long command is not a safe abstraction boundary merely because it came from an agent.
Gate 2: file and index inspection
Treat agent configuration as a secret-bearing artifact class. Check both the working tree and Git's index:
git check-ignore -v .claude/settings.local.json
git ls-files --error-unmatch .claude/settings.local.json
git diff --cached -- .claude/
The desired result is contextual. The local file should normally be ignored and untracked. A shared .claude/settings.json may be intentionally committed, but its permission rules and env entries still need review because sharing is its purpose.
Add repository-owned controls rather than relying only on one developer's global configuration:
.claude/settings.local.json
Then scan agent directories, transcripts, memory files, handoff notes, build contexts, archives, and generated deployment manifests. The pre-install trust boundary protects what enters a developer environment. This audit protects what leaves it.
Gate 3: commit and artifact verification
Run secret detection before a commit becomes shared history and again in CI before packaging or deployment. Include semantic patterns for passwords inside commands, not only provider-key regexes. A useful test corpus contains safe variable references and unsafe literals for the same command shape, so the scanner's false-positive and false-negative behavior is visible.
The release gate should also inspect the actual build context. A clean Git index does not prove a Docker COPY ., source archive, IDE sync, or package publisher omitted local files. This extends the repository data-flow audit: login and telemetry are only two exits; local automation artifacts are another.
If a secret was committed, rotate before cleanup
GitHub's remediation guide advises treating a leaked secret as compromised. Removing the line, adding a later commit, or deleting and recreating the repository does not by itself prevent use of the exposed credential.
The recovery sequence is:
- Identify the credential, owner, scope, repositories, artifacts, forks, and affected services.
- Revoke or rotate it. For a high-risk production credential, limit the exposure window first; coordinate replacement when immediate revocation would break service.
- Check provider and application audit logs for unauthorized use.
- Remove the local rule and stop tracking the file.
- Decide whether history rewriting is justified, then coordinate force-pushes, pull requests, forks, clones, caches, and downstream builds.
- Verify the old credential is invalid and the new one is absent from the same data path.
GitHub's history-removal documentation is explicit about the limits: rewriting a repository cannot clean other people's clones, and secrets can remain in forks, cached views, or pull-request references. History cleanup reduces distribution. Credential rotation closes access.
A verifiable policy for coding-agent permissions
A policy should be testable without trusting memory:
| Control point | Required evidence | Failure action |
|---|---|---|
| Command proposal | No literal secret in the persisted command | Use a variable, helper, or one-time approval |
| Permission file | Local file ignored and untracked; shared file reviewed | Block standing approval or commit |
| Staged change | Agent directories and command contexts scanned | Reject commit |
| Repository history | Current and historical paths searched | Rotate, assess, then clean history |
| Build or package | Final artifact inventory and secret scan | Stop publication |
| Credential provider | Old credential invalid; new scope minimized | Keep incident open |
This follows the same principle as the five-layer sandbox state model: process state, local files, Git history, external artifacts, and provider credentials have different owners and lifecycles. Calling all of them local configuration hides the actual boundary.
The durable lesson is simple. Approval UX is also a persistence interface. Once a command can be saved, permission files belong in the same security inventory as .env, shell history, CI logs, agent transcripts, and deployment bundles. The control is complete only when it can prove what was stored, what was shared, what still works, and what was revoked.
FAQ
Does Claude Code always commit .claude/settings.local.json?
No. Current documentation says Claude Code adds the path to the user's global Git excludes when it creates the file in a repository. Risk remains when the file is manually created, already tracked, moved across environments, copied into an artifact, or retained in history.
Is adding the file to .gitignore enough?
It prevents new tracking in ordinary Git workflows. It does not untrack a file already in the index, erase history, remove forks and clones, or revoke exposed credentials.
Can secret scanning find passwords inside commands?
Some products support generic or AI-detected password patterns, but coverage and validity checks vary. Test the exact command forms your developers and agents use, including ordinary passwords without provider-specific prefixes.
Should teams ban saved permissions?
Not categorically. Saved permissions reduce repeated prompts. Keep them narrow, store no literal secrets, review the persisted rule, and verify the file remains outside shared history and artifacts.
References
- Claude Code Docs, Configure permissions, accessed November 9, 2026.
- Claude Code Docs, Settings files and precedence, accessed November 9, 2026.
- Apiiro, Coding Agents Copy Your Secrets to a Hidden File, November 5, 2026, updated November 8, 2026.
- GitHub Docs, Remediating a leaked secret, accessed November 9, 2026.
- GitHub Docs, Removing sensitive data from a repository, accessed November 9, 2026.
- GitHub Docs, Supported secret scanning patterns, accessed November 9, 2026.