If the history audit turns up a real credential, rotate it immediately. A key that appeared in any git commit should be treated as compromised even if the repository is private.

Harden Your Prompts, Not Just Your Code

You can reduce the frequency of AI-generated credential leakage by changing how you write prompts. Be explicit:

This works because language models follow instructions. The model will still default to the training-data pattern if you do not specify otherwise, but an explicit instruction overrides it most of the time.

Gate Secrets at the Repository Level

Prompt hygiene and manual audits are not enough on their own. Add tooling that prevents the commit from happening:


# Install pre-commit and the detect-secrets hook
pip install pre-commit detect-secrets

# .pre-commit-config.yaml
repos:
  - repo: https://github.com/Yelp/detect-secrets
    rev: v1.4.0
    hooks:
      - id: detect-secrets
        args: ['--baseline', '.secrets.baseline']

This hook scans every staged file before the commit lands. It catches the pattern before it enters history.

Key Takeaways

\n\n\n

If the history audit turns up a real credential, rotate it immediately. A key that appeared in any git commit should be treated as compromised even if the repository is private.

\n\n

Harden Your Prompts, Not Just Your Code

\n\n

You can reduce the frequency of AI-generated credential leakage by changing how you write prompts. Be explicit:

\n\n\n\n

This works because language models follow instructions. The model will still default to the training-data pattern if you do not specify otherwise, but an explicit instruction overrides it most of the time.

\n\n

Gate Secrets at the Repository Level

\n\n

Prompt hygiene and manual audits are not enough on their own. Add tooling that prevents the commit from happening:

\n\n
\n# Install pre-commit and the detect-secrets hook\npip install pre-commit detect-secrets\n\n# .pre-commit-config.yaml\nrepos:\n  - repo: https://github.com/Yelp/detect-secrets\n    rev: v1.4.0\n    hooks:\n      - id: detect-secrets\n        args: ['--baseline', '.secrets.baseline']\n
\n\n

This hook scans every staged file before the commit lands. It catches the pattern before it enters history.

\n\n

Key Takeaways

\n\n"}