Analysis · AI coding and security

Coding agents and secrets: what Claude Code's 'don't ask again' leak teaches engineering teams

Security firm Apiiro found real passwords and API keys in public copies of a Claude Code settings file, saved there when developers approved commands with "don't ask again". The specific fix is simple. The wider lesson is that coding agents create new files, on every developer's machine, that can hold credentials, and most secret controls were not designed with them in mind.

AnalysisSumanta Mukhopadhyay7 min read6 sources
#news#security#ai#agents
ANALYSIS · ANALYSIS · AI CODING AND SECURITY9 Nov 2026 · 21:20 GST

What happened

Apiiro reported that when a developer chooses "Yes, and don't ask again" for a command in Claude Code, the tool can save the command, word for word, as an allow rule in .claude/settings.local.json in the project1. If the command contained a password or API key, so does the file. Apiiro found 104,185 public copies of the file on GitHub, and real secrets in 1,122 of them13.

Claude Code's documentation describes the local settings file as personal and not checked in, and says Claude Code configures git to ignore it4. Reporting notes that this protection lives in a machine's git settings rather than the repository's own .gitignore, so it does not travel with the repository2. Apiiro's advice: search repositories and their history for these files, stop tracking them and add them to each repository's .gitignore2.

  1. TypeA developer runs a command with a key inline, via the agent
  2. Approve"Don't ask again" saves the exact command as an allow rule
  3. StoreThe key now sits in a project file under .claude/
  4. MissIgnore rules are per machine, so another setup or a forced add tracks it
  5. PublishThe file is pushed; on a public repository the key is exposed
  6. LingerDeleting the file later leaves it in git history
Each step is ordinary developer behaviour. The leak comes from the combination.

The wider lesson: agent files are a new place for secrets

This is not unique to one tool. Coding agents keep settings, approval rules, memory notes, session transcripts and tool configuration on disk, often inside the project directory. Any of them can capture a credential a developer typed or an agent read. Most organisations' secret controls were designed for source code and CI configuration, and do not yet treat agent artefacts as a category.

The underlying habit is also older than AI: pasting a key into a command because it is quicker than setting up proper access. Agents make that habit more expensive, because they record what they are told to do.

Controls that work, in layers

Habit
No secrets in commandsreference variables or a secrets manager
Repository
Agent paths ignoredin every repository's .gitignoreShared templatesnew repositories start safe
Platform
Push protectionblock secrets before they landHistory scanningfind what already leaked
Credentials
Short-lived tokensleaks expire quicklyFast rotationone step, tested
Policy
Managed agent settingsorganisation-wide rulesApproval reviewsprune "always allow" lists
No single layer is enough; together they make a leaked agent file boring rather than dangerous.

Keep secrets out of commands. Teach developers and agents to reference environment variables or a secrets manager rather than pasting values. Approval rules then contain a variable name, not a key.

Ignore agent paths in the repository. Add agent configuration directories to every repository's .gitignore and to the templates new repositories start from, rather than relying on each developer's machine.

Block at push time and scan history. GitHub's push protection blocks recognised secrets before they are pushed, and organisations can choose which patterns it covers5. Pair it with scanning of existing repositories and their history, including agent directories.

Make leaked credentials short-lived. The best defence against any leak is a credential that expires before it is useful. Fetch credentials when needed instead of storing them, the pattern Kubernetes uses for registry access6.

Diagram of the kubelet calling a credential provider plugin with a CredentialProviderRequest for an image, the plugin authenticating to the registry and returning a CredentialProviderResponse with credentials
Fetch credentials on demand rather than writing them down: the same principle keeps agents from collecting secrets. Source: Kubernetes blog, Andrew Sy Kim and Dixita Narang · CC BY 4.0

Govern agent settings centrally. Where your coding agents support organisation-managed settings, use them to set baseline rules, and periodically review the "always allow" lists developers accumulate. See AI coding policy for engineering teams.

Every new tool on a developer's machine is a new place for secrets to hide. Assume agents will write down what they see, and make sure what they see is never a long-lived key.

What to do this week

  • Search your organisation's repositories and their history for .claude/ and other agent configuration files; rotate any secrets found.
  • Add agent paths to repository .gitignore files and templates.
  • Turn on push protection and extend secret scanning to agent directories.
  • Tell developers, plainly, not to paste credentials into agent prompts or commands.

CTO take

The Claude Code finding will be fixed and forgotten, but the pattern will recur with other tools. Coding agents are now part of the software supply chain on every developer's machine, and they generate files, memories and logs that sit outside most security reviews. Treat them like any other privileged tool: managed settings, scanning that covers their files and access through short-lived credentials. Read alongside the 9 November tech news, agentic infrastructure and the AI developer toolchain security case study.

How I can help

I help engineering teams adopt AI coding tools safely: policies, managed settings, secret controls and the identity model behind them. I am based in India, the United States and the UAE, working globally. See fractional CTO work, where I work, or analyse your challenge and bring the result to a call.

References
  1. 1
  2. 2
  3. 3
  4. 4
    Claude Code settingsAnthropic · 2026
  5. 5
    About push protectionGitHub Docs · 2026
  6. 6
FAQ

Common questions

What exactly leaked in the Claude Code case?

When a developer approved a command with 'Yes, and don't ask again', Claude Code could save that command as an allow rule in .claude/settings.local.json. If the command contained a password or key, the secret was saved too, and where the file was committed it became public. Apiiro reported finding secrets in 1,122 public copies of the file.

Is .claude/settings.local.json ignored by git?

Claude Code's documentation says it configures git to ignore the file when it creates it, but reporting notes this relies on a machine's git settings rather than the repository's own .gitignore. Teams should add agent configuration paths to each repository's .gitignore as well.

How do we stop secrets ending up in coding agent files?

Keep secrets out of commands by referencing environment variables or a secrets manager, ignore agent configuration paths in every repository, enable push protection and secret scanning that covers those paths, and use short-lived credentials so any leak expires quickly.

Keep reading

Related

Open to advisory, fractional CTO & select builds

Let's talk about what you're building.

The fastest route is a free 30-minute call. Prefer to write? Send a message and I'll reply personally within two business days.

Start a conversation

How would you like to reach me?

Book a 30-min callFastest. Pick any open slot on my calendar.→ Write in GmailOpens a pre-filled draft in your browser.→ Use my email appOutlook, Apple Mail or your default client.→

I reply personally within two business days. Time zones from the Americas and Europe to the Middle East and Asia-Pacific.