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.