Agents
Back

Plan first, then build

Workflows,

For anything bigger than a quick fix, I don't let a coding agent start writing code right away. I tell it to plan first, show me the plan, then build. I read the plan, answer its questions, and only after that does it touch any files. Here's how that actually goes, using a real session where I updated ryancuff.com.

My reasoning is pretty simple. A plan is cheaper to fix than code. If the plan is wrong, fixing it is one reply. If the code is wrong, I'm undoing work.

It matters more now than it used to. Since version 2.1.283, auto mode is the default for interactive Claude Code sessions in the terminal and in VS Code. So the agent doesn't stop and ask before every edit anymore. If I want a checkpoint before it starts changing files, I have to ask for one.

How to get better results from a coding agent

It starts with one line in the prompt. I don't use plan mode for this, just plain words. Here's how the request for my site started.

prompt
Update my personal site (ryancuff.com). Plan first, show me the plan, then build.

Say what has to stay the same

The same request also said what it wasn't allowed to change.

prompt
KEEP: the current minimal visual style exactly as it is. This is a content and structure update, not a redesign.

That line does a lot of work. The Claude Code docs say Claude tends to read a request conservatively. They also say that if you name the file, describe the symptom and say what "fixed" looks like up front, you usually save yourself a round of corrections later. Saying what stays the same is the same idea. It tells the agent where the edges are before it starts.

Answer the plan's open questions

The plan came back with a few open questions. Should it keep the project icons? Should the meta description just be the tagline? A meta description is the short summary a search engine shows under a page title.

I answered them and said go ahead. Nothing got built until then.

The Claude Code best practices page suggests a stronger version of this, where Claude asks the questions.

prompt
Interview me until you could write the spec, then write it to SPEC.md.

Correct it while it builds

Once it's building I don't just sit and wait. If I notice something I send it right away. Partway through the site update I sent this.

prompt
i removed x so remove that please

Then I asked for a longer tagline. Then I told it to take Go and Django off my skills, because I don't know either of them well enough to list them.

Each one landed in the same turn. In Claude Code, pressing Enter while it's working queues your message, and Claude gets it as soon as its current tool calls finish. A tool call is one action, like reading a file or running a command. Esc stops it mid-action and keeps the work so far. Pressing Esc twice on an empty prompt, or running /rewind, opens the rewind menu.

If I'm correcting the same thing over and over, that's a sign the prompt was the problem. The docs say that after two failed corrections, run /clear and write a better prompt instead of trying a third. /clear wipes the conversation so it starts fresh.

Make it check its work and list the files it changed

At the end I asked it to run the dev server, check the pages at desktop and phone width, confirm all the links work, and list every file it changed. The dev server is the local copy of the site running on my machine while I work on it.

It listed twelve files. That list tells me exactly where to look.

The docs explain why this step is there. Claude stops when the work looks done, so give it a check that comes back pass or fail. Then ask for evidence, "the command it ran and its output, or the screenshot." Hearing "all tests pass" on its own doesn't tell you much.

Don't let it push until you confirm

When I started a second site I told it this.

prompt
dont push until i confirm

That works, with a catch. The permission modes docs say a boundary you state in chat is "not stored as rules" and "can be lost if context compaction removes the message that stated it." Context compaction is when a long conversation gets summarized to make room, and older messages can drop out.

So for anything that really matters, the firm version is an ask rule for git push in .claude/settings.json. That's a permission rule that makes it ask before it pushes, whatever happened earlier in the chat.

What is plan mode in Claude Code?

Plan mode is the built-in version of all this. Here's how the docs describe it. "Claude reads files, runs shell commands to explore, and writes a plan, but does not edit your source." Edits stay blocked until you approve the plan.

One thing that's easy to get wrong. Shell commands still run while it plans. It can look around and run things, it just can't change your source files.

You can turn it on a few ways. Press Shift+Tab to cycle through the modes until the status bar shows plan mode is on. Start a prompt with /plan to plan just that one prompt. Or launch it with claude --permission-mode plan.

When the plan is ready you get three choices. Yes and use auto mode. Yes, and manually approve edits. Or no, keep planning. Keep planning is what I'm doing when I answer the open questions in my prompt version. Ctrl+G opens the plan in your editor so you can change it before you approve.

How to get out of plan mode without approving

This is the gotcha. At the approval prompt, Shift+Tab approves the plan. It's the same key that got you into plan mode, so it's easy to press it thinking it'll cycle you back out. If you just want out, press Esc first.

When I skip the plan

Small fixes go straight in with no plan.

Anything bigger than that gets the plan first.