Stop prompting and praying: how I ship real code with AI agents
AI agents don't fail because the model is weak. They fail because the process around them is. The four-step workflow I use to build Zode and BoltDocs.
- AI
- Engineering
- Process
- Agents
Most developers use AI coding agents wrong. Not because they pick the wrong model or write bad prompts, but because they treat the agent like an oracle: you ask, you wait, you pray, and then you paste whatever comes back into your codebase.
I use agents every day to build Zode, the platform behind BoltDocs. That means auth, billing, background jobs, integrations and a UI that has to stay coherent while three features move at the same time. Over time I’ve learned that the difference between a demo and production code has almost nothing to do with the prompt. It has to do with engineering discipline.
An agent is not a senior engineer. It’s an amplifier. If your process is weak, it will produce garbage very fast. If your process is strict, it gives you leverage you didn’t have before.
This is the workflow I use. Four steps, no magic.
1. The task file is the blueprint
Before a single line of code exists, I write a TASK.md.
Not a prompt. A file. Something the agent can re-read when it inevitably loses the thread. Long conversations drift: the context gets summarized, old instructions fall out of the window, and the agent starts optimizing for the last message instead of the actual goal. A file on disk doesn’t drift. It’s persistent memory the agent can go back to at any point.
What goes in it:
- The goal, one paragraph, in plain language.
- Constraints: stack, patterns to follow, files it must not touch.
- Phases, each with a checkpoint and a clear definition of done.
- Acceptance criteria you can actually verify.
- Out of scope. Explicitly.
Here’s a trimmed version of one I used recently:
# TASK: Add invoice PDF export
## Goal
Users can download a PDF for any invoice from the billing page.
## Constraints
- Follow the existing `InvoiceService` pattern in `src/billing`.
- No new dependencies without approval.
- Do not modify existing tests.
## Phases
1. Rendering layer + unit tests for totals and taxes.
2. Endpoint and permissions check.
3. UI button + loading and error states.
## Done when
- `pnpm test billing` passes.
- A user without access gets a 403, covered by a test.
- No changes outside `src/billing` and `src/pages/api`.
That last section matters more than people think. An agent without explicit boundaries will “improve” files you never asked it to touch, and suddenly your diff is three times bigger than the feature. The task file also gives you a natural unit of work: one phase, one review, one commit.
If you’d rather not write it by hand
Writing a good TASK.md is ten minutes of thinking, and thinking is exactly
what you don’t want to do at midnight with the feature half-designed in your
head. So I let the agent draft it. I paste the raw idea plus the constraints and
it returns the file:
You are planning a feature with me. Do not write code yet.
Feature: <WHAT I WANT TO BUILD, ONE OR TWO SENTENCES>
Stack and conventions: <FRAMEWORK, LANGUAGE, PATTERNS TO FOLLOW>
Files or modules involved: <PATHS>
Out of scope: <WHAT MUST NOT CHANGE>
Write a TASK.md containing:
- A goal in one paragraph, plain language, no marketing.
- Constraints: patterns to follow, files not to touch, dependencies to avoid.
- 3 to 5 phases, each with a verifiable definition of done.
- Acceptance criteria that can be checked (commands, HTTP codes, UI states).
- An explicit out-of-scope section.
Do not invent requirements. If something is ambiguous, ask me before writing.
Return only the file content.
The placeholders in <ANGLE BRACKETS> are the part only you can fill in. The
rest is the structure the agent tends to skip.
And then — this is the part people skip — read the file before you approve it. Not skim it. Read it. The phases decide what gets built, what gets tested and what you’ll review later. If phase two is wrong, the implementation and the tests inherit the mistake, and you find out three hours later in a diff you don’t recognize. The feature starts in that file, not in the first prompt.
If the draft invents a requirement you never asked for, delete it. If it splits the work into “implement backend, implement frontend, done”, rewrite the phases until each one has a test you can actually run.
2. The loop: implement, then test
Then I let it write the feature. Then I run the tests myself.
Not “the agent says it ran the tests”. I run them, I read the output, and if something fails, the failure goes back to implementation. Same phase, same task file, fix the cause.
And here’s the rule I never break: the agent does not get to touch the tests to make them pass.
Agents cheat. Not maliciously — they’re optimizing for the success signal you
gave them. If green tests are the goal, the cheapest path to green is often to
change the test: relax an assertion, delete the failing case, mock the thing
under test, wrap the block in a try/catch, add a .skip. I’ve seen every one
of those. All of them are a bug wearing a passing test suite.
So I guard the tests. Two things help:
- Write the tests first and commit them. After that, any change to a test shows up in the diff and I can ask why it was necessary.
- Treat a test change as a code change. It needs a justification, not “cleanup”.
Passing tests mean the behavior you specified is protected. If you let the agent edit them, they mean nothing.
3. Code review is the filter
Green tests are necessary. They are not sufficient.
Once a phase passes, I don’t merge. I ask for a review of the entire diff, and then I read the diff myself. The questions I care about:
- Does this follow the architecture we already have, or did it invent a parallel one? Isolated islands are the most common failure mode: a new helper that duplicates an existing service and is wired into nothing.
- Did it connect to the real logic, or only to the happy path?
- Are errors handled where they happen, or swallowed to keep the output clean?
- Did it add a dependency, a config flag or an env var that nobody asked for?
- Is there dead code, commented-out experiments, or “just in case” abstractions?
Here’s the prompt I actually paste:
Review the full diff of this change against TASK.md. Do not modify code.
Report only problems, with file and line references:
- Places where the implementation does not follow the existing architecture.
- Logic that duplicates something that already exists.
- Dead code, commented-out code or abstractions with no caller.
- Errors that are swallowed or not handled where they happen.
- New dependencies, config flags or env vars that were not requested.
- Behavior that is not covered by a test.
If something is correct, don't mention it.
I also run the review in a separate session, ideally with fresh context and sometimes with a different model. A reviewer that already spent an hour writing the code is not a reviewer — it’s a co-author defending its work.
And then I check the review. “Looks good” from an agent is not a merge approval. The diff is the source of truth.
4. Release
Only when the tests pass and the review is clean, I commit.
One phase per commit. A message that explains the why, not the what. If something breaks in production, I want to revert one phase, not an afternoon of work. And I don’t let the agent push: it can propose, I decide.
The uncomfortable conclusion
None of this is prompt engineering. A task file, tests, diffs, commits — this is just software engineering, applied to a new kind of contributor that types faster than you, has no ego and no memory.
That’s the part people skip. They want the leverage without the discipline, and then they conclude that AI doesn’t work for “real” projects. It does. It just doesn’t replace your process. It exposes it.
AI is an amplifier of your own discipline. Weak process gives you garbage at speed. Strong process gives you a team of one that ships like a team of five.
I know which one I’m choosing.