Skip to content

chore: stop committing .claude/settings.local.json - #704

Open
Anubhav-2003 wants to merge 1 commit into
reactnativecn:masterfrom
Anubhav-2003:chore/untrack-claude-local-settings
Open

Anubhav-2003 wants to merge 1 commit into
reactnativecn:masterfrom
Anubhav-2003:chore/untrack-claude-local-settings

Conversation

@Anubhav-2003

@Anubhav-2003 Anubhav-2003 commented Nov 30, 2026 •

Copy link
Copy Markdown

Summary

While setting up the repo with Claude Code, I noticed .claude/settings.local.json is committed. That's where Claude Code saves each command you approve, keys included, so it's meant to stay on one machine. Ran npx @gglint/cli secrets and it flagged it:

.claude/settings.local.json
  ✗   1:1  this file is in git, but it's Claude Code's personal settings, where it saves the commands you allow, secrets and all, meant for one person's machine

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.toml and CLAUDE.md the 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, plus git 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:

  • A pre-commit hook (husky runs gglint secrets --staged, with @gglint/cli and husky added as dev dependencies and a prepare script 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.
  • A CI check on pull requests (.github/workflows/agent-secrets.yml, read-only, no comments). Hooks run locally, so they can be skipped with --no-verify or 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:

  • writes a token in a known format (GitHub, Anthropic, AWS, Slack, Google and others) into an agent file
  • puts a password in a database URL, or a key in a command such as curl -H "Authorization: Bearer …"
  • writes a value under a name such as password, api_key or Authorization instead of a ${VARIABLE}
  • commits .claude/settings.local.json, CLAUDE.local.md, or Claude Code's or Codex's login file, which are meant for one person's machine

Neither 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 secrets flags the file before this change and passes after it.
  • With a test GitHub token added to a new CLAUDE.md and staged, gglint secrets --staged (what the hook runs) fails and points at the line.
  • The lockfile was updated with bun 1.4.0, the version CI uses, without running install scripts.
  • zizmor finds nothing in the new workflow.

I work on gglint, so happy to adjust anything here.


Run Proof
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

Summary by CodeRabbit

  • Chores
    • Added automated checks for secrets in agent configuration during pull requests and pre-commit checks.
    • Removed a local agent settings file and excluded it from version control.
    • Added repository setup for pre-commit hooks.

@coderabbitai

coderabbitai Bot commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The pull request adds gglint secret checks to the pre-commit hook and a pull-request workflow. It adds Husky setup and development dependencies, removes .claude/settings.local.json, and ignores that file.

Changes: Agent Configuration Secret Checks

Layer / File(s) Summary
Configure Husky and gglint
package.json
Adds Husky and gglint as development dependencies. Adds a prepare script that runs Husky.
Run secret checks locally and on pull requests
.husky/pre-commit, .github/workflows/agent-secrets.yml, .claude/settings.local.json, .gitignore
Runs gglint secrets --staged in the pre-commit hook. Adds a pull-request workflow that runs the pinned gglint action with read-only contents permission and checkout credential persistence disabled. Removes .claude/settings.local.json and adds it to .gitignore.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Other

Suggested reviewers: claude, sunnylqm

Merge Risk: Minimal · up to 8d790 · assessed changes only

Path filters excluded changed files. This rating applies only to the assessed changes.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title "chore: stop committing .claude/settings.local.json" matches the main change. The PR removes the tracked file, adds it to .gitignore, and adds secret-scanning hooks and a workflow. The title…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Full details: Title check

Explanation

The title "chore: stop committing .claude/settings.local.json" matches the main change. The PR removes the tracked file, adds it to .gitignore, and adds secret-scanning hooks and a workflow. The title covers the core removal and ignore change but not the new secret-check tooling, which is a secondary part of the change.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 2e3dc394-2fb1-4342-b817-a5243cc82bdc
Commits

Reviewing files that changed from the base of the PR and between baebed1 and 8d79082.

Files ignored due to path filters: 1

  • bun.lock is excluded by !**/*.lock
Files selected for processing: 2

  • .github/workflows/agent-secrets.yml
  • package.json

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.

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>
@Anubhav-2003
Anubhav-2003 force-pushed the chore/untrack-claude-local-settings branch from baebed1 to 8d79082 Compare November 30, 2026 07:33

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant