Part 2 of 15 · The House That Diligence BuiltNext: Your Codebase Is the Biggest Prompt →

Fix the Plan Before the Agent Writes the Code

A bad line of code is one bad line. A bad line in a plan becomes a hundred. Review a short plan before an agent builds anything risky.

Clint JohnsonPublished 7 min read

This is the blueprint: the part of the house you agree on before anyone pours concrete. With coding agents, it's the part I skipped for too long.

Here's the ratio I keep in my head. A bad line of code is one bad line. A bad line in a plan can become a hundred lines of code. And a bad line of research, a wrong idea about how the system works, sends the whole run in the wrong direction.

Most of my review effort used to go to the last of those three, the diff. That's where a mistake is cheapest and where I was spending the most attention. I had it backwards.

Two one-sentence mistakes

Two misses on this site made the point for me.

The first was a redirect. I wanted the bare domain to redirect to the www host. The agent did exactly that, for every path, including /api/. It merged, and the next pull request the same day was a fix to keep the API routes off the redirect. The code was fine. The intent was wrong, and nobody looked at the intent.

The second was a cleanup. An agent was asked to prune agent definitions that weren't in use, and it deleted the core ones along with the stale ones. Again, the code did what it was told.

Both mistakes fit in one sentence: "redirect every path on the bare domain," "delete agents not on this list." Either sentence, written in a plan and read for thirty seconds, would have caught it. Reading the diff didn't, because the diff was a faithful implementation of the wrong sentence.

What a plan holds

I don't mean a design doc. I mean two short files an agent writes before it touches the repo.

A research note. What exists, what connects to what, and what the change will touch, with file and line references. No proposals. This is where the agent shows me its model of the system. If the model is wrong, everything downstream is wrong, so this is the highest-leverage thing I read all day.

A plan. Numbered steps. Each step names its files and lines, shows a snippet of the intended change, and gives the command that proves the step worked. It ends with what's out of scope and how to roll back.

Both have to be readable in about five minutes. Longer plans are more reliable and less readable, and past a point nobody reads them, which makes them worthless. I'd rather have a plan detailed enough that the weakest model I use couldn't get it wrong, and short enough that I actually check it.

What I'm looking for in review:

  • Does the research describe the system the way it really works?
  • Does any step's sentence say something broader than I meant? ("every path," "all agents," "any file")
  • Is each step verifiable by a command, not by the agent's opinion?
  • Is the rollback real?

That review takes minutes. Afterward, reviewing the code is quick too, because I'm only checking that it matches the plan. The evidence the agent brings back, tests and screenshots and a recording, does the rest. I wrote about that half in Review the Evidence, Not the Diff.

Not everything needs one

Plans cost time, and a plan for a button color is ceremony. I use a simple trigger:

  • the task is medium or large, or
  • it touches three or more files, or
  • it touches a risky area: redirects and middleware, auth, schema and migrations, anything that deletes, CI config, and the prompts and allowlists my bots run on.

Copy edits and one-line fixes skip it. Most of my small work still goes straight from request to code.

For big or fuzzy tasks there's a step before research: the agent interviews me. One question at a time, each with its recommended answer, walking the branches of the decision until we agree on what "done" means. These sessions surface questions I hadn't thought to ask. Planning is the part that needs a human at the keyboard. Implementation often doesn't.

For a change repeated across many files or repos, I do the first one by hand, or watch closely while one gets done. That reference change shows the hidden constraints, and every later plan cites it and lists where it deviates.

Plans live in the task list, not the repo

My sessions all work from one ranked task list I call Lodestone. A session takes a task, says what it's doing, and when it needs me it asks a question with a recommended answer and stops until I answer.

A plan fits that shape. The session writes the research note and plan to a folder tied to the task, outside every repo, so finished plans never go stale inside a codebase. Then it asks: "Plan ready. Approve?" Until I answer, a hook refuses edits in the repo for any medium or large task without an approved plan. The rule lives in code, not in a rules file that a session can read past.

Plan the work as a graph, not a list

The second thing a good plan does is tell you what can run at the same time.

A ranked list can only be worked from the top. One session, one task after another. Nothing in a numbered list says that tasks three and five don't depend on each other.

So I've started planning bigger work as tasks with three extra fields:

  • Blocked by. Which tasks must finish first. A task is ready when all of its blockers are done.
  • Mode. Either it can run with nobody at the keyboard, or it needs me in the loop: design calls, anything people will see, anything touching sensitive data. Needing me is the default.
  • Done when. The acceptance check, written before work starts. A command that passes, a page that renders.

Take a feature with six tasks: a schema change, a service, copy that I need to approve, wiring it into the UI, a backfill, and QA. As a list, one session works them in order. As a graph, the schema, the service and the copy can start at once. The UI and the backfill open when their blockers finish. QA waits on everything and needs me.

Two rules make the graph work. Tasks are thin slices through every layer, not "do the database, then do the API," because a slice gives feedback on a working system. And each task is designed so a separate session can pick it up alone, in its own worktree, without coordinating with the others.

The "done when" line matters more than it looks. A session that knows the check it's working toward stops when the check passes, not when it feels finished. When it closes the task, it reports what the check showed.

Reviewing the graph is part of the blueprint. I can spot a missing blocker in seconds. I've seen two pull requests that each added the same lint block, conflicting by design, because nobody wrote down that one depended on the other.

How you know it's working

  • Same-day fix-ups drop. Count pull requests whose only purpose is to correct a change merged in the last 48 hours. Those are intent mistakes a plan should have caught.
  • Plan review stays short. If reading a plan takes more than about five minutes, the plans are too long or the tasks are too big.
  • Code review gets faster. When the code matches an approved plan, review is a conformance check. If it isn't getting faster, the plans aren't specific enough.
  • More work runs in parallel. Count how many tasks are ready at once. A plan that's a graph should show more than one.
  • Questions arrive before the code. Questions asked during planning are cheap. The same question discovered in review costs a rewrite.

A plan doesn't replace verification, and it doesn't make the foundation optional. It moves my attention to where one sentence changes a hundred lines, which is the only place a single reviewer can keep up with a fleet of agents.

Next in The House That Diligence Built · Part 3 of 15Your Codebase Is the Biggest Prompt →