I don’t let Cursor/Claude “refactor freely” anymore.
I add cheap guardrails: type-level checks + runtime assertions.
I catch the dumb bugs: undefined envs, wrong shapes, silent 200s.
You can copy my 4-file setup in 10 minutes.
Context
I build small SaaS apps. Usually solo. Usually fast.
AI-assisted coding makes me faster. Also makes me sloppy.
My recurring failure mode: I ask for a “cleanup refactor”. Cursor applies a wide diff. Claude rewrites helpers. Tests don’t exist yet. Then I ship. Then prod logs say something like TypeError: Cannot read properties of undefined (reading 'split') .
Brutal part? The code looks cleaner. The bug hides in the seams.
So I stopped arguing with my own workflow. I added guardrails that are boring, loud, and hard to accidentally remove.
1) I start by making config impossible to “kind of work”
My favorite bug.
Missing env var. Code still boots. Then it fails 12 minutes later.
I used to do this:
// ❌ Don't do this const baseUrl = process . env .…