Chapter 4: Reading and debugging

Debugging by halving

Also called Binary search

Finding a fault by checking the middle. If things are still right there, the bug is in the later half, and if not, the earlier half. Each check rules out half of what is left, so a thousand places takes about ten checks.

It needs no understanding of the code, only a way of telling good from bad, so it still works when you are lost and the agent is too. Checking in order is the natural thing to try, and the slow one.

Say it to your agent

“Run git bisect between v1.4 and HEAD, using git bisect run bun test tests/checkout.test.ts as the check. Tell me which commit it finds and show me its diff.”

The workshop

Name a word, or describe what you mean in everyday language.