← Back to all posts

Hacker Laws for Agentic Software Engineering: Kernighan's Law

Law 8 of 12. Kernighan's Law says debugging is twice as hard as writing the code in the first place. The ASE key insight: if the agent writes clever code, the system must debug it — keep agent output boring and make the verifier the smarter half.

hacker-lawsagentic-software-engineeringserieskernighans-lawdebuggingverificationsimplicity

Law 8 of 12 in the Hacker Laws for Agentic Software Engineering series — read the index. Previous: Hofstadter's Law · Next: Parkinson's Law.

The Law

Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it. (Brian Kernighan, via hacker-laws)

The Key Insight for Agentic Software Engineering

Kernighan's Law was written for human programmers; agentic software engineering makes it worse, because the writer and the debugger are different systems. The model writes the code; the model cannot debug it — an agent asked to evaluate its own work "tend[s] to respond by confidently praising the work" (Anthropic's harness) — so the debugging burden falls on the system: the verifiers, the tests, the reviewers, and eventually the humans. This is the same finding Fowler's retreat made the headline of the agentic era: "code generation is no longer the bottleneck — verification is" (Verification Is the Bottleneck). Kernighan's Law names why: the generation half is now nearly free, so the debugging half — always twice as hard — is where all the cost went.

The law's prescription survives verbatim: don't let the agent write clever code. If the agent produces the most intricate solution it can, the system — which must debug it — is "by definition, not smart enough." The harness-level translation is the whole boring-output discipline: schema-enforced, conventional, simple output that the verifier can actually check; and the verifier must be built to be the smarter half — the evaluator with hands that uses the artifact instead of reading it, the ensembles that cross-check instead of self-praise. The 79% self-review datum from the mob post is Kernighan's Law in review form: most agent PRs were reviewed by the same developer who prompted the agent — the writer debugging its own work, which the law says is impossible (mob programming remastered).

The ASE reading of Kernighan's Law: if the agent writes clever code, the system must debug it — keep agent output boring and make the verifier the smarter half. The model generates; the harness verifies; and the division is structural, because the writer can never be trusted to debug what it wrote.

References