Claude Code's "Yes, and don't ask again" saves approved shell commands verbatim to .claude/settings.local.json; if a command contained a token, the secret is in the file. Claude Code excludes the file only via the developer's global git excludes, not project .gitignore, so it can be committed. Apiiro found ~104,185 copies in public repos (Nov 2026), 1,122 with at least one secret.
Prevent (GitLab):
- Add
.claude/settings.local.json to .gitignore (via group file templates on Premium/Ultimate).
- Add a push rule with prohibited filename
(^|/)\.claude/settings\.local\.json$ — applies to new files only, and group rules don't retroactively cover existing projects (use the push rule API per project).
- Enable Secret Push Protection (Ultimate) and a group-level scan execution policy running Secret Detection, optionally with
SECRET_DETECTION_HISTORIC_SCAN: 'true' for full history.
Assess: Ask GitLab Duo Agentic Chat to check all projects including deleted/non-default-branch copies; otherwise use code search (exact or advanced search, exclude_forks=false via API) and the commits API (GET /projects/<id>/repository/commits?path=.claude/settings.local.json&all=true&follow=false — follow=false is required for correct path-filtered paging). Check forks separately.
Mitigate: Rotate secrets first, treat them as public from the first commit date; then remove the file (Duo can open cleanup MRs group-wide, or git rm --cached + .gitignore), then purge history via Settings > Repository > Remove blobs plus housekeeping. Note: forks share object pools, so detach forks before rewriting; MRs may need rebasing and users must re-clone.