How to prevent leaks from Clau... Note
GitLab

How to prevent leaks from Claude Code's 'Don't ask again' file

This guide explains how to find and remove sensitive information accidentally committed to GitLab repositories, specifically concerning the Claude Code tool. Claude Code can save approved shell commands, including secrets, to a local settings file that is then inadvertently committed to repositories. This issue is significant as it has led to many copies of this file appearing in public repositories, some containing secrets. To prevent this, it is recommended to add .claude/settings.local.json to the project's .gitignore file. GitLab Premium and Ultimate users can further enforce this by setting up push rules to block the file name. Ultimate users can leverage Secret Push Protection to scan content for known token formats and use scan execution policies for comprehensive secret detection. To assess current and past exposure, GitLab Duo can be used to query project history for the presence of the file. Alternatively, code search, available in Premium and Ultimate, can find current copies, while commit history checks are available across all tiers. Forks of projects need separate verification. The remediation process involves rotating any exposed secrets first, then removing the file from current branches and adding it to .gitignore. GitLab Duo can automate the creation of merge requests for this cleanup. Finally, purging the content from repository history is crucial to fully remove the leaked secrets.