← Brakes: coding with AI agents

Brakes: coding with AI agents · Part 5

Your agent can't test the discount without a database

· by Tony Tang

The pricing rule lives inside the database handler, three lines of math between two queries, so its only test needs a Postgres container, migrations and seed data. Nobody runs it before pushing, not you, not the agent. Pull the rule out: a core that knows nothing about databases, talking through ports like CartRepository. Postgres plugs in from outside; in tests an in-memory adapter does, and a thousand runs take seconds. Rules in the middle. Machines at the edges.

Comment below: Can you test your core without a database?

Brakes: a series on the checks that let an AI coding agent go fast without shipping bugs. Every best practice shortens the time between writing a bug and finding it. Brakes are why race cars go fast. All code is real TypeScript on Node 24, typechecked and tested before it went on screen.

More from this series