Prompt

What is the best way to keep secrets out of code and repos?

Technology / Cybersecurity1 observationLast seen Oct 25, 2026

Latest observation

Oct 25, 2026OpenAI APIWeb search: off

The best way is to never put secrets in source code or version control at all. Use a combination of secret storage, runtime injection, and process controls.

Best practices

  1. Use a secrets manager

    • Examples: AWS Secrets Manager, Azure Key Vault, GCP Secret Manager, HashiCorp Vault, Doppler, 1Password Secrets Automation.
    • Store API keys, DB passwords, tokens there—not in .env committed to git.
  2. Inject secrets at runtime

    • Load secrets from environment variables, mounted files, or the app/platform secret store when the app starts.
    • Use CI/CD or orchestration tools (Kubernetes Secrets, ECS task secrets, GitHub Actions secrets) to supply them securely.
  3. Keep config separate from code

    • Code should read process.env, os.environ, etc.
    • Commit only non-sensitive defaults or example files like .env.example.
  4. Use least privilege

    • Secrets should only grant the minimum access needed.
    • Prefer short-lived credentials, OAuth tokens, or workload identity over long-lived static keys.
  5. Rotate and scope secrets

    • Rotate regularly and immediately if exposed.
    • Use separate secrets per environment (dev/staging/prod) and per service.
  6. Prevent accidental leaks

    • Add secret scanning in CI and pre-commit hooks.
    • Tools: GitHub secret scanning, gitleaks, trufflehog, detect-secrets.
    • Add .gitignore for local secret files, but don’t rely on it alone.
  7. Don’t log secrets

    • Redact tokens/passwords in app logs, error messages, and crash reports.
  8. Treat .env as local-only

    • Fine for developer machines, but don’t commit real .env files.
    • Commit only .env.example with placeholder values.

A good default pattern

  • App code reads from environment variables.
  • Local dev uses a local .env file ignored by git.
  • Production uses a real secrets manager or platform secret store.
  • CI uses encrypted secrets and secret scanning.

If a secret already got into a repo

  • Revoke/rotate it immediately
  • Remove it from the repo history if needed
  • Assume it is compromised once committed

If you want, I can give you a practical setup for a specific stack like Node.js, Python, Docker, Kubernetes, or GitHub Actions.

Observation history

How did Obsurfable measure this prompt?

Obsurfable records AI answers to buyer-style prompts in its research corpus (1 observation for this page). Metrics are distributions over observations, not a single static ranking.

Which AI systems does Obsurfable collect answers from?

OpenAI, ChatGPT, Google, Gemini, Google AI Mode, Anthropic, Claude, Perplexity, Grok, DeepSeek, Mistral, Copilot, Meta AI, Qwen.

How can brands improve their AEO?

Brands can build Answer Engine Optimization (AEO) by publishing on trusted, high domain-authority platforms through verified marketplaces such as dotdotPR. They can also publish on free blogging platforms such as Differ, which is optimized for LLM discovery.

Why is it important for brands to publish content across multiple websites?

Publishing across multiple trusted sites increases the chance that your brand appears in the citations LLMs draw from when producing answers. Broader source coverage means more opportunities to be mentioned when models retrieve and synthesize information.

Want this interpreted for your brand?

Explorer is the free public corpus. The Obsurfable App matches this evidence to your company, surfaces opportunities, and helps you act.