Repository navigation
chore: stop committing .claude/settings.local.json - #704
Anubhav-2003 wants to merge 1 commit into
Conversation
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
Claude Code saves each command you approve, keys included, in .claude/settings.local.json, so the file is meant for one person's machine. Remove it from git and ignore it (gglint secrets --fix), and run gglint secrets before each commit and on pull requests so it doesn't come back. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
baebed1 to
8d79082
Compare
Summary
While setting up the repo with Claude Code, I noticed
.claude/settings.local.jsonis committed. That's where Claude Code saves each command you approve, keys included, so it's meant to stay on one machine. Rannpx @gglint/cli secretsand it flagged it:Coding agents' config files have become a common place for secrets to leak. When you approve a command in Claude Code, it saves the command, keys and all, in
.claude/settings.local.json, and GitGuardian found about 31,000 secrets in those files on public GitHub (report). Keys end up in.mcp.json,.codex/config.tomlandCLAUDE.mdthe same way.Nothing in this repo's copy is a secret today, so there's nothing to rotate. Fixed with
npx @gglint/cli secrets --fix, which added it to.gitignore, plusgit rm --cached .claude/settings.local.json, as gglint suggests, so it leaves git but stays on disk.So it doesn't come back, this adds two checks:
gglint secrets --staged, with@gglint/cliandhuskyadded as dev dependencies and apreparescript that sets the hook up on install). This is the one that actually prevents a leak: it stops the commit on the contributor's machine, before the key exists anywhere else. Once a key reaches GitHub it's in the history, and has to be rotated even if the commit is reverted..github/workflows/agent-secrets.yml, read-only, no comments). Hooks run locally, so they can be skipped with--no-verifyor never set up on a new clone; this catches whatever gets past them. If you'd rather not have it, I'm happy to drop it and keep just the hook.Both fail, and point at the line, when a change:
curl -H "Authorization: Bearer …"password,api_keyorAuthorizationinstead of a${VARIABLE}.claude/settings.local.json,CLAUDE.local.md, or Claude Code's or Codex's login file, which are meant for one person's machineNeither prints a secret's value.
One heads-up: pulling this deletes your local copy of
.claude/settings.local.json, so copy it aside first if you want to keep your approved commands.Testing
npx @gglint/cli secretsflags the file before this change and passes after it.CLAUDE.mdand staged,gglint secrets --staged(what the hook runs) fails and points at the line.zizmorfinds nothing in the new workflow.I work on gglint, so happy to adjust anything here.
Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.Summary by CodeRabbit