Skip to content
Back to articles

Artificial Intelligence (AI)

I Let AI Agents Write My Code. Here's Why It Didn't Turn Into a Mess

An AI agent writes a first draft in minutes. Whether that becomes a speed-up or a mess depends on the workflow around it: a plan, the right context, structured prompts, and a real review.

2 min read

AI agents are now part of how I build software. They write a first draft quickly, explore unfamiliar code, and handle repetitive changes. But speed is only useful if the result is correct, readable, and safe to ship. This is the workflow I use to keep it that way.

Plan before you prompt

The most expensive mistakes happen when an agent starts coding on a vague request. Before asking for code, I write a short plan: what should change, which files are involved, what must not break, and how I will verify it. Often the agent drafts the plan and I correct it. That conversation is cheaper than reviewing the wrong implementation.

Meme: asking an AI to make the login better, and it rewrites 47 files

Give the agent the right context

An agent only knows what it can see. I keep project knowledge organized so the relevant pieces are easy to provide:

  • Conventions and commands in a project instructions file.

  • Reusable agent skills for recurring tasks, such as design reviews or release steps.

  • MCP tools for live context: documentation, the database schema, or the browser.

Good context reduces guessing, and less guessing means less code to throw away.

Write structured prompts

A structured prompt states the goal, the constraints, and the definition of done. For example: "Add a category filter to the project index. Keep the existing URL structure, support keyboard users, and do not add dependencies. Done means typecheck, lint, and build pass."

Review everything that ships

Generated code is a draft. I read every diff with the same questions I ask in a human code review:

  • Does it solve the actual problem, or only the one in the prompt?

  • Does it follow the existing patterns and naming in the codebase?

  • Are edge cases, errors, and accessibility handled?

  • Would I be comfortable maintaining this in six months?

Meme: merging an AI diff with LGTM versus reading every diff and running the checks

The agent writes the first draft. I stay responsible for what reaches production.

Verify, do not assume

Every change ends with real checks: type checking, linting, tests, and running the app. For UI work I look at the result in a browser on desktop and mobile. An agent saying "done" is not the same as the feature working.

Used this way, AI agents do not replace engineering judgment. They give me more time for it.