Build discipline
These rules were paid for with real incidents on a live product. Each one describes a way that work looked finished and wasn't. The point is not ceremony — it is that a few specific failure modes are invisible from the inside, and each has a cheap, mechanical antidote.
The one idea underneath all of them
A check that cannot fail is not a check. Most of what follows is that sentence applied to a different surface: a test, an environment, a measurement, a backup, a sentence in an email.
When you catch yourself about to say "verified", "working", "done", or "passing", ask: what would I have seen if it were broken? If the honest answer is "the same thing", you have not verified anything yet.
1. Break-test every tripwire before you keep it
A guard that greps for a name proves the name exists — not that the behaviour is right.
// This "check" passes even when the code is dead:
assert(source.includes("menu.published"))
// ...against: if (false && menu.published) { ... }
Antidote: before keeping any new assertion, deliberately break the thing it guards and watch it go red. If it stays green, it is decoration. Then restore the code and watch it go green again.
The inverse also bites: an assertion can fire unfairly. A check for
published: true matched text inside a read-only select: {} block, failing a
correct change. Pin the behaviour you care about — the exact write, the exact
conditional — not a string that appears in several roles.
Why it matters more than it sounds: fake tripwires accumulate silently and convert a growing test suite into growing false confidence. The suite gets slower and less informative at the same time.
2. Green for the wrong reason
The most expensive failure in this category: a referer check compared the request's origin against a build-time base URL. Locally, that URL and the request host were identical, so a local production build passed 10/10 and a browser-automation test passed 10/10. On the preview deployment the two differed, and the feature was completely broken — every request looked cross-origin. The owner found it by clicking a link.
Both tests were real. Both were useless, because the environment they ran in could not express the bug.
Antidote: for anything that depends on host, URL, environment variable, timezone, locale, or deployment target, ask where does this value differ? and test there. If local and production agree by coincidence, local proves nothing.
Corollary: "the build succeeded" is not evidence a feature works. Judge by what the feature does, in the place it will actually run.
3. Escaping traps — write files with a file tool, not a shell
Shell quoting, heredocs, regex flags and nested backticks failed five times in a single working session. Each one wasted a cycle and one of them silently corrupted content rather than erroring.
Observed failures:
- A bash heredoc consumed a backslash, turning
\\ninto a real newline. - Nested backticks inside a heredoc broke parsing with a confusing EOF error.
- Inline
-e "..."one-liners broke on inner quotes. - A regex
/sflag needed a newer compile target than the project used.
Antidote:
- Create or rewrite a file with a dedicated write tool, never a heredoc, once the content contains quotes, backslashes, backticks, or non-ASCII text.
- To insert into an existing file, locate the anchor with
indexOf/lastIndexOfon a literal string rather than a regex. - When a heredoc is genuinely the right tool, quote the delimiter (
<<'EOF') so nothing expands, and verify the result rather than assuming.
Verify after writing, cheaply: byte length, absence of a BOM, and whether line endings are what you intended.
4. CRLF: normalise, patch, restore
A scripted edit against a CRLF file fails to match multi-line patterns, and a naive fix rewrites every line ending in the file — producing an enormous meaningless diff.
Antidote: read, split on \r\n and join with \n, apply the patch, then
join back with \r\n before writing. Afterwards, confirm no mixed endings
remain (a lone \n not preceded by \r).
Related trap: in JavaScript, String.length counts UTF-16 units, not
bytes. For non-ASCII text — Greek, accents, emoji — a "size" that suddenly
looks wrong is usually this, not data loss. Compare Buffer.length when you
mean bytes.
5. Windows paths are not what the shell showed you
/tmp in Git Bash is C:\tmp, a real directory that may not exist or may
not be writable. A backup copied to /tmp before a risky edit was not there
when the restore was attempted, and the file stayed broken.
Separately: bash translates /c/Users/... for its own commands, but a program
invoked from bash receives the string unchanged and may resolve it as
C:\c\Users\.... Passing a bash-style path to node -e fails this way.
Antidote: put temporary files in the session scratchpad directory, not
/tmp. When handing a path to another program, give it a form that program
understands (C:/Users/...). And before relying on a backup, confirm it exists
and has a plausible size — a backup you never checked is a wish.
6. Claims that reach a person get checked against the code
A customer email nearly went out saying an unverified address meant the user "cannot log in again". The login path never checked the verification flag, and no scheduled job deleted accounts. The statement was false — and it was the kind of false that the recipient discovers in one click, taking the sender's credibility with it.
Antidote: every sentence in user-facing text that asserts how the product behaves gets traced to the code that implements it, before sending. This applies to emails, ad copy, landing pages, onboarding text, and support replies. Manufactured urgency is the highest-risk category, because it is the most tempting to write and the easiest to disprove.
If a claim cannot be verified, either cut it or rewrite it as a question.
7. When a measurement surprises you, suspect the measurement
Repeatedly, a "finding" turned out to be a broken test rather than a broken
product: counting a currency symbol that the UI never renders; searching for
text in one language on a page rendered in another; measuring an overlay by
page height; and a corrupted-looking data row that was really a naive
split(",") breaking on a quoted comma.
Antidote: before reporting a surprising result, re-derive it a second way — ideally with the project's own parser or helper rather than an ad-hoc one. Say plainly when a previous conclusion was a measurement error; a retracted false alarm costs far less than a decision made on one.
Related: state-dependent false positives. "The event appeared" once came from a stale session left open, not from the action under test. Run against fresh fixtures, and prefer assertions on identifiers you created in this run.
8. Data does not know what it does not record
A database showed a signup that looked, by every available field, like a real lost customer — professional content, full journey, then silence. It was a friend testing. No query could have revealed that.
Antidote: before drawing a conclusion about people from rows, ask whoever has the context that the schema does not store. Separate "what the data shows" from "what I infer", and label the inference as inference.
The same discipline applies to absence: a field that is empty because the feature did not exist yet means nothing at all. Know when instrumentation started before reading anything into a gap.
How to apply this without slowing to a crawl
Not every change earns every rule. Scale it to blast radius:
| Change | What proof looks like |
|---|---|
| Copy, styling, one component | It compiles and you looked at it. |
| New feature, route, or API | Exercised where it will run, not only locally. |
| Anything env-dependent | Tested where the environment actually differs (§2). |
| Schema, payments, auth, limits | Full round trip against a real database, verified by querying it. |
| No UI at all | Local production build plus a data round trip — never the exit code alone. |
| Anything a customer will read | Every behavioural claim traced to code (§6). |
The rules cost minutes. The incidents behind them cost days, and one of them was caught only because a human clicked a link that no test could have clicked.