secrets — .env, api keys, and what not to commit8 / 9
.env, os.getenv, and the leak recovery you'll do at least once
Build a config loader. Write load_config(env) that:
- Reads
ANTHROPIC_API_KEYfromenv. If missing or empty, raiseRuntimeError("ANTHROPIC_API_KEY missing"). - Reads
MODELwith a default of"claude-sonnet-4-6". - Reads
DEBUGwith a default of"false", normalizes it to a real bool by lowercasing and comparing to"true". - Returns a dict with keys
api_key,model, anddebug.
Then call it on the provided env and print one line per key.
Expected output:
api_key=sk-ant-test
model=claude-sonnet-4-6
debug=True
⌘↵ runs the editor.
Booting Python…
Output
[promptdojo:~]$ _