Yeda AI Tips · #064

Español

The SMIG Rule: Situation, Mechanism, Implication, Gotcha

Stop writing docs that just say "this function adds two numbers." A comment or walkthrough step that narrates the code adds zero information — the reader is already looking at the code. Nobody re-reads what the code already shows. Good onboarding spends its words on the parts you cannot see: why it's built this way, what breaks if you touch it wrong. The SMIG rule is a checklist that forces every doc step to earn its space.

The four parts

Write every step of a doc, code tour, or onboarding guide against four questions:

PartQuestion it answersExample line
SituationWhat are we looking at?"This is the retry loop that wraps every outbound payment call."
MechanismHow does it work?"It backs off exponentially: 1s, 2s, 4s, capped at 30s."
ImplicationWhy does it matter?"Without the cap, a dead gateway would stall checkout for minutes."
GotchaWhat bites you?"The retry is NOT idempotent-safe — never wrap charge() calls in it."

Situation and Mechanism should be short — one line each is usually enough, because the code carries most of that load. Implication and Gotcha are where the invisible knowledge lives, so that's where the word count goes.

Why "adds two numbers" docs fail

Code already answers what and (mostly) how. What it can never answer:

A useful smell test: if you deleted the code and kept only your doc, would the doc still say anything? "Adds two numbers" says nothing. "Rounds half-cents toward the merchant per the 2019 billing audit" survives.

Google's technical writing course frames the same idea as an equation: good documentation is the knowledge your audience needs minus the knowledge they already have. For a reader with the code open, Situation and Mechanism are mostly "already have" — Implication and Gotcha are the gap.

Budget your words like a reviewer budgets attention

If a step ends up 80% Situation and Mechanism, either the code needs a rename more than a doc — or you're narrating.

Power user: SMIG is a prompt, too

The rule doubles as an instruction for AI coding assistants. Ask your assistant to "write a code tour of this module where every stop covers Situation, Mechanism, Implication, and Gotcha" and you get structurally better output than "document this code" — because the model, like a junior engineer, defaults to narrating what it sees. The rubric forces it to reason about consequences and edge cases instead.

And keep it minimal: Google's documentation best-practices guide calls this "minimum viable documentation" — a small set of fresh, accurate docs beats a sprawling assembly of docs in various states of disrepair.

Resources

Building an AI feature? Yeda AI designs, audits, and ships production LLM systems.

Talk to us · Read the blog