.secrets -
You must add .secrets to your .gitignore file immediately when initializing a project.
# .secrets - NEVER COMMIT THIS FILE DATABASE_URL=postgresql://admin:SuperStrongP@ssw0rd!@prod-db:5432/main DATABASE_REPLICA_PASSWORD=ReplicaKey_9x2#kLp API Keys (Third Party) STRIPE_LIVE_SECRET_KEY=sk_live_51H3kL9P4mVx9... (truncated) AWS_SECRET_ACCESS_KEY=wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY Internal Service Tokens JWT_SIGNING_SECRET=8f3e9a1c7b2d4f6a9e1c7b3d5f8a2e4c HASHICORP_TOKEN=hvs.CAESIAlp... .secrets
# Install pre-commit pre-commit install If you must share a .secrets file via email or cloud storage, use GPG (GNU Privacy Guard) or age encryption. Do not use password-protected ZIP files (they are trivial to crack). Rule 5: The .secrets.template Pattern Instead of committing a real .secrets file, commit a .secrets.template file. You must add
A study by North Carolina State University analyzed 1.4 million GitHub repositories. They found hundreds of thousands of unique, valid API keys and cryptographic secrets. How did they get there? Developers committed the .secrets file by accident. # Install pre-commit pre-commit install If you must share a
Your future self—and your security team—will thank you. Have a story about a .secrets leak that almost ruined your weekend? Share it in the comments below. Let's learn from our collective scars.
In the future, you won't have a file at all. Your application will ask the cloud provider: "Who am I?" The cloud says: "You are EC2 instance i-1234." The application then gets a short-lived token (valid for 1 hour) from the vault. No static .secrets file exists anywhere.