Published Engineering
Shit Code
Why bad code happens, who is really responsible for it, and what to do about it when you are the one who has to live with the result.
The reason your AI agent is producing shit code is simple: You've stopped being the architect and started being a spectator.
If you're just "vibe coding" and hoping for the best, you're just building technical debt at 10x speed. You've got to move the "thinking work" upstream.
Here is how to get rid of the slop and get production-ready output:
- Force a "Thinking Phase": I never let Claude write a line of logic until I've seen a /plan. Use it as your digital pen and paper. If the plan is a shambles, the code will be too.
- Govern with Contracts: Define your Interfaces and DTOs before the AI touches the implementation. The "plumbing" needs to be signed off before the typing starts. This keeps AI focused on fulfilling a contract rather than making up data structures on the fly.
- Strict Domain Boundaries: AI loves spaghetti. Enforce Bounded Contexts to force isolation. If an agent needs logic from another domain, it has to go through a defined "front door." This prevents "spaghetti" imports and keeps the system modular enough for a human to actually manage.
- The 200-Line Ceiling: This is my hard limit for files. Anything bigger is too complex for the AI to "reason" about properly. Once a file (especially a component) gets too large, the AI's reasoning starts to drift. By enforcing a strict ceiling, you force the agent to modularize. It makes the code easier for you to review and ensures the AI can hold the entire logic in focus.
- Adversarial Review: Don't just check if it works. Tell the agent to "attack" its own plan from a security and performance perspective before you approve it.
AI is a massive force multiplier, but only if you provide the guardrails.
Stop chatting with your tools and start governing them.
If you've inherited a codebase and want an honest assessment of what you're dealing with, I offer code quality audits and architecture reviews.
Related posts
- 10 Mar 2026From Vibe Coding to ProductionThe gap between prototyping with AI and shipping to production, and what it actually takes to close it before real users depend on the result.
- 27 Feb 2026I Built an AI Coding Flow That Doesn't Go Rogue (Part 2): Why Context MattersA detailed look at the context management and workflow setup behind disciplined Claude Code usage, and why context matters so much.
- 20 Feb 2026I Built an AI Coding Flow That Doesn't Go Rogue (Part 1)Exploring disciplined AI-assisted development with Claude Code - building an autonomous workflow that actually stays on track.