How-Tos

How-To: Keep AI Agent Permission Files and Secrets Out of Git

Leave a comment

After the Claude Code settings leak, I went through my own agent setups. Here’s the routine I landed on. Nothing in it is specific to any one machine.

  1. Ignore per-project: add .claude/settings.local.json (and any other local agent state) to each repo’s .gitignore, not just your global excludes, so the rule travels with the repo.
  2. Check history: git log --all --oneline -- .claude/ shows whether it was ever committed.
  3. Scan: run gitleaks and TruffleHog, then grep agent files by hand. Neither tool caught everything in the research.
  4. Rotate before rewriting: if a secret ever landed in git, rotate it first. Rewriting history doesn’t help forks or clones.
  5. No secrets on the command line: load them from env files or a secrets manager so the approved command never has the value in it.
  6. Prefer patterns: approve rules like npm test * instead of one-off commands with tokens in them.

God Bless, and Happy hacking!

References & Further Reading

Subscribe (RSS) Follow How-Tos via RSS

Leave a note

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.