Work effectively with AI coding agents. Understand them as language models running in a tool loop with limited context, which is why they guess, game the visible signal and report confidently. Recognise the shortcut and correctness tells in their code across Python, TypeScript/JavaScript, Rust, Java and Go, and know the damage each one does later. Verify changes instead of trusting them, review diffs fast for quality and security, judge when work is truly finished, and choose, design and steer tasks so agents can finish them well.
Secrets in code, logs and commits card 4 of 6

Two leaks in one small diff

builds on: Agents optimise the signal they can see, What the agent sees: its context
The fallback in `os.getenv` puts the live key into source, and into git history for good. It also hides missing config, because every machine silently uses that key. The new `log.debug` writes the `Bearer` token to wherever logs go once debug is on. **Later cost:** a permanent key in history, config errors that never fail loudly, and tokens in log stores. BETTER: keep `os.environ["PAY_API_KEY"]`, which raises `KeyError` when the variable is unset. Log the amount, never the headers.
// Python
--- a/billing/client.py
+++ b/billing/client.py
-API_KEY = os.environ["PAY_API_KEY"]
+API_KEY = os.getenv(
+    "PAY_API_KEY", "sk_live_51Hq8xT2eZvKa9")
 
 def charge(amount):
     headers = {"Authorization":
                f"Bearer {API_KEY}"}
+    log.debug("charge %s", headers)
     return post(URL, headers=headers)
Terms on this card
Later cost
The concrete damage a shortcut does after merge, such as a hidden bug, data corruption or a leaked credential.
git history
Every commit ever made in a repository. A file deleted in a later commit is still readable in earlier ones.
Bearer
An HTTP authorization scheme where whoever holds the token is granted access: 'Authorization: Bearer <token>'.
os.getenv
Python function that returns an environment variable, or the given default (None if none is given) when it is unset.
KeyError
Python exception raised by os.environ[name] when the variable is not set: a loud, early failure.
Learn this step by step on Bytewise
Lesson goal: Catch hardcoded keys added 'to make it work', tokens written to logs or error messages, committed .env files and credentials pasted into test fixtures. Remember that any secret the agent reads enters its context and can resurface. Once a secret has been committed, rotate it: deleting it from the code is not enough. · the whole lesson