Env & Secret Config
TRIGGER
Activate when building/fixing a tool that needs API keys, tokens, passwords, or any secret — or when user mentions .env, config, credentials, gitignore secrets.
RULES
-
Never hardcode secrets in source
- Read from env vars or
.env, not inline strings. - Bad:
TOKEN = "ghp_xxxx" - Good:
TOKEN = os.getenv("TOKEN")
- Read from env vars or
-
Use
.envfor local, never commit it.envholdsKEY=valuelines (no quotes needed).- Always add
.envto.gitignore. - Provide
.env.examplewith dummy/empty values for sharing.
-
Load pattern per language
- Python:
python-dotenvpythonfrom dotenv import load_dotenv import os load_dotenv() TOKEN = os.getenv("TOKEN") - Node:
dotenvjsrequire("dotenv").config(); const TOKEN = process.env.TOKEN; - Go:
godotenvor read os env directly. - PowerShell:
$env:TOKEN = (Get-Content .env | ...)or$env:TOKEN.
- Python:
-
.env.exampletemplate# Copy to .env and fill in API_KEY= TOKEN= PROXY_URL= -
Fail safe
- If a required var is missing, print clear error + exit:
print("[!] API_KEY not set — copy .env.example to .env"); sys.exit(1) - Never continue with empty secret (silent failures waste time).
- If a required var is missing, print clear error + exit:
-
OPSEC
- Rotate user-agents / proxies via env, not code.
- Keep real location hidden: read VPN/cover settings from env.
- Never echo secrets to logs or console.
WORKFLOW
- Create
.env.examplewith all needed keys (blank). - Load vars at tool start; validate presence.
- Add
.envto.gitignore. - Tell user:
cp .env.example .envthen fill values.


