.claudeignore does not protect your secrets from Claude Code
A .claudeignore or .cursorignore entry looks like a permission boundary. It is not one — it only shapes what the model chooses to read, and testing has shown it does not even reliably do that. The fix that actually holds is not a smarter ignore file: it is never putting a real secret where the agent can find it in the first place.
Last checked December 3, 2026.
A real test, not a hypothetical
A reproducible test against Claude Code v2.1.12 created an .env file with sample secrets, added ".env" and ".env.*" to .claudeignore, then asked Claude to read the .env file — it did, printing the contents straight to the console with only a passing note that the file "contains credentials." Asked how to prevent this, Claude itself recommended adding the file to .claudeignore — the exact thing that had just failed.
This is not an isolated bug report: GitGuardian's secrets-sprawl study (scanning public GitHub and Docker Hub, Jan 2025 through early Nov 2026) found every one of 30 AI coding agents it checked leaked config-file secrets at scale. CLAUDE.md files alone held 6,155 distinct secrets, 2,537 still valid at detection — the highest validity rate of any file type in the study. Claude Code's own settings.local.json held 31,088 distinct secrets across 23,276 repositories.
Sources: The Register: Claude Code ignores ignore rules meant to block secrets, GitGuardian: your AI coding agent just leaked a secret, found on Docker Hub in 8 seconds
Why an ignore file is not a permission boundary
An ignore file is a convention, read and respected only by the tool that chose to implement it that way — a text pattern the model is told not to use, not a filesystem ACL the OS enforces. Claude Code's own documentation now treats .claudeignore as unreliable and recommends permissions.deny rules in settings.json instead (e.g. "Read(./.env)", "Read(./secrets/**)"), which blocks the file from the tool-call path entirely rather than asking the model to self-censor.
Even that stronger mechanism has a hole worth knowing about: a secret already loaded into the shell's own environment (by direnv, a shell profile, or docker --env-file) sits outside any file-read permission check. A command like env or printenv does not go through a Read rule at all. Deny rules protect a file; they do not protect a running process's environment.
Sources: Claude Code docs: Configure permissions (permissions.deny)
The fix that actually holds: nothing worth leaking
Protecting a secret by hiding it better is a losing race against every new agent, every new tool-call path, and every new ignore-file bug report. The fix that holds regardless of what a future Claude Code or Cursor release does: never let a real DATABASE_URL or service-role key sit in a committed .env, CLAUDE.md, or shell profile at all.
On Scribase, the connection an agent uses is a scoped, expiring agent token (default 8 hours, 30 minutes to never, revocable at any time) issued via scribase login or a temporary project — never a static secret you type into a file. If an agent reads that token out of an .env it should not have, the blast radius is one project, one scope, one short window, fully logged, not a standing production credential.
Scribase agent token (scoped to project web, read/write, expires in 8h,
revocable at console.scribase.com/account/tokens). Designed to be read:
scb_agt_1p-rw-sqlw-mig-fn-x2609260412_3f9a...Sources: Scribase docs: Why you never need to paste a secret key, Scribase docs: Temporary databases
Questions people ask
Does .claudeignore actually stop Claude Code from reading an .env file?
A documented test against Claude Code v2.1.12 found it does not: the file was read and its contents printed despite a matching .claudeignore entry. Claude Code's own current documentation has since moved to recommending permissions.deny rules in settings.json instead, which are enforced at the tool-call layer rather than left to the model.
Is this a one-off bug, or a bigger pattern?
Bigger pattern. GitGuardian's Nov 2026 study found secrets leaking from AI coding agent config files at scale across public GitHub and Docker Hub — every one of 30 agents checked leaked, and CLAUDE.md files alone held 6,155 distinct secrets with 2,537 still valid.
If I add a permissions.deny rule, am I safe?
Safer for file reads, not complete: a secret already loaded into the process environment (via direnv, a shell profile, or an --env-file) is invisible to file-read permission rules entirely, since env/printenv never touch the filesystem.
What does Scribase do differently here?
It removes the thing worth leaking rather than hiding it better: an agent connects with a scoped, time-boxed, revocable token (not a static DATABASE_URL or service-role key), issued via scribase login or a temporary project. Reading that token out of a file is a short, logged, single-scope exposure, not a standing production credential.