[Feature] Add fileHistoryExclude config option to prevent secret-bearing files from being snapshotted

Resolved 💬 3 comments Opened Apr 18, 2026 by NBBorislavMalinov Closed May 27, 2026

Problem

Claude Code automatically records edit snapshots of every file it touches in ~/.claude/file-history/. This means every .env, .env.local, or other secret-bearing file that Claude ever reads or edits gets copied to persistent local storage.

During a security audit of our installation (NEBA Token project), we found:

  • 6 789 files in ~/.claude/file-history/ (196 MB)
  • 20 of them contained a live EVM signer private key (plaintext) — because .env was edited over the past weeks.

These snapshots are never purged unless the user manually deletes them, and they live outside the user's regular workflow (no git tracking, no explicit listing, hidden dir).

Proposal

Add a fileHistoryExclude option to Claude Code settings (~/.claude/settings.json and project-local .claude/settings.local.json):

{
  "fileHistoryExclude": [
    ".env",
    ".env.*",
    "*.env",
    "*.env.local",
    "**/secrets/**",
    "*.gpg",
    "*.kdbx",
    "*.pem",
    "*.key"
  ]
}

When a file path matches any pattern, Claude Code should:

  1. Not write an entry to ~/.claude/file-history/.
  2. Ideally also surface a warning so the developer knows the edit wasn't snapshotted (no silent failure of undo).

Why this matters

  • Security: keeps production secrets out of persistent unencrypted storage.
  • Compliance: helps customers who need to run hardening audits (our audit flagged this as HIGH severity).
  • No workaround exists today: users either have to rm -rf ~/.claude/file-history/ periodically (loses undo for all files) or accept the secret leak.

Related patterns

  • Git's .gitignore — pattern-based exclusion.
  • VS Code's files.exclude — similar user-facing model.
  • ESLint's .eslintignore — convention already familiar to devs.

Alternatives considered

  1. Per-edit opt-out via special file marker — high friction for developers.
  2. Global "disable file history" — loses undo for ALL files, too blunt.
  3. Periodic cron to purge file-history/ matching secret patterns — race condition + requires user setup.

Acceptance criteria

  • Glob patterns honoured via standard micromatch / minimatch semantics.
  • Both global (~/.claude/settings.json) and workspace (.claude/settings.local.json) settings merged.
  • Documented in Claude Code settings reference.

Source

Discovered during external security audit of a NEBA Token dev workstation running Claude Code, 2026-04-18. Full finding:

  • Path: ~/.claude/file-history/
  • Files with live SIGNER_PRIVATE_KEY plaintext: 20/6789 (0.3%)
  • Total storage consumed: 196 MB
  • Cleanup required manual intervention.

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗