6.4CORE PATH

Secrets, Api Keys, And What Not To Put In A Prompt

This section is short because the rules are short. Read all of them.

A SECRET is any piece of information that, if leaked, gives an attacker access to something they shouldn't have. Secrets include:

  • API keys (Stripe, Twilio, OpenAI, Anthropic, AWS, Google).
  • Database passwords.
  • Personal access tokens for GitHub, etc.
  • Private SSL certificate keys.
  • OAuth client secrets.
  • Anything labeled "secret" or "key" in a config.

THE RULES:

NEVER paste a real secret into a chat with a frontier model. Anthropic, OpenAI, Google may not abuse your data, but their logs exist, and "I'll trust them" is not a security strategy. Use a placeholder (STRIPE_KEY=sk_live_PLACEHOLDER) when discussing config with an agent.

NEVER commit a .env file with real secrets to git. Add .env to your .gitignore immediately, before you ever put a secret in it.

NEVER put secrets in code. Not in Python files. Not in JS files. Not in HTML. Always read them from environment variables.

USE A SECRETS MANAGER for production. AWS Secrets Manager, GCP Secret Manager, Azure Key Vault, Doppler, 1Password CLI, or Infisical. They cost a few dollars a month and they save you from yourself.

ROTATE SECRETS PERIODICALLY. Especially after team changes or when you suspect a leak. Rotation means: generate a new secret, update all places that use it, revoke the old one.

SCAN YOUR REPO FOR LEAKED SECRETS. GitHub does this automatically for major providers — if a Stripe or AWS key gets committed, you'll get an email within minutes. Tools like gitleaks and truffleHog do the same locally.

AGENTS WILL SOMETIMES TRY TO HELP BY HARDCODING SECRETS. They've seen people do it in tutorials. When you spot this in agent output, send it back: "Use environment variables, not hardcoded values."

A practical pattern, in your repo:

.env.example # checked in, with placeholder values .env # NOT checked in, with real values .gitignore # contains the line: .env

In your code: import os STRIPE_KEY = os.environ["STRIPE_KEY"]

Never: STRIPE_KEY = "sk_live_actualKey"

A leaked secret is AFD by default (see §1.4). Even when the secret is "just" yours, leaks ripple: your $20,000 API bill was ours to ignore; the credentials that bill bought may now be in a botnet hitting other people's services. Treat secrets like AFD code, and the discipline mostly takes care of itself.

Curriculum last updated 2026-04-30