Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

Coding Agent Plan First: Why It Matters

· 5 min read · Home Tech

In this article
  1. Why a Pre-Plan Matters
  2. How the Plan-Then-Execute Flow Works
  3. What a Good Plan Should Include
  4. Common Problems When Plans Are Skipped
  5. How to Choose the Right Level of Control
  6. Costs and Trade-Offs
  7. Safety and Best Practices
  8. Frequently Asked Questions

Yes, you should make your coding agent explain its plan before it touches files. This single practice prevents destructive edits, wasted tokens, and hidden assumptions, and it turns the agent from a blind executor into a reviewed collaborator.

Why a Pre-Plan Matters

Modern coding agents (like those built on large language models) operate by reading your repository, forming an internal plan, and then executing file changes. Without a checkpoint, the agent may start editing the wrong file, refactor a function you were about to delete, or implement a solution that contradicts your architecture. A pre-plan forces the agent to externalize its reasoning so you can catch errors before they become diffs. It also reduces the cost of a bad run: a plan costs a few hundred tokens, while a full file rewrite with tests can cost thousands and require manual reverts.

How the Plan-Then-Execute Flow Works

Most agentic coding tools support a "plan mode" or "propose first" setting. The typical flow is:

  • You give a task like "add pagination to the user list."
  • The agent reads relevant files, then outputs a numbered plan: which files it will modify, what functions it will add or change, and what tests it will run.
  • You review the plan, ask for changes, or approve it.
  • Only after approval does the agent write to disk.

Some tools also let you set a global rule: "Always present a plan before making any edits." That rule is stored in the project's configuration file (e.g., AGENTS.md or a tool-specific config) and applies to every session.

What a Good Plan Should Include

A useful plan is not just a one-line summary. It should be specific enough that you can verify it against your codebase. Look for these elements:

  • File list – exact paths, not "relevant files."
  • Change type – add, modify, delete, or rename.
  • Key functions or classes – names of what will be touched.
  • Dependencies – new packages or environment changes.
  • Testing strategy – which tests will be run or added.
  • Risks – what could break and how it will be mitigated.

If the agent omits any of these, ask for clarification. A vague plan is often a sign that the agent hasn't fully analyzed the codebase.

Common Problems When Plans Are Skipped

The most frequent issues from skipping the plan step are:

  • Wrong file edited – the agent finds a similarly named file and modifies it.
  • Over-engineering – it adds abstractions you didn't ask for.
  • Breaking existing tests – it changes a shared utility without checking callers.
  • Secret or config changes – it edits environment files or credentials.
  • Large diffs – a small task results in hundreds of changed lines.

Each of these is much easier to catch in a plan than in a post-hoc diff review.

How to Choose the Right Level of Control

Not every task needs a full plan. A one-line typo fix can be done directly. But for anything that touches multiple files, changes behavior, or involves a public API, require a plan. A practical guideline:

  • Always plan – for refactors, migrations, or changes to shared modules.
  • Plan if uncertain – if the task is ambiguous, ask for a plan first.
  • Skip plan – only for trivial, reversible changes like fixing a comment or a variable name.

You can also set a threshold in tools that support it, like "always plan when more than 3 files are affected."

Costs and Trade-Offs

Requiring a plan adds a round-trip, which means extra latency and a small token cost. However, the cost of a bad edit is usually higher: reverting, debugging, and re-running tests. In practice, a plan costs about 5% of the tokens a full task would use, but it can prevent 50% of failed runs. The trade-off is almost always favorable for non-trivial tasks.

Safety and Best Practices

Beyond the plan, add safety measures:

  • Run the agent in a branch, not directly on main.
  • Commit before starting so you can revert easily.
  • Use a diff review tool to see exactly what changed.
  • Set a max token limit per task to avoid runaway edits.
  • For sensitive files (like secrets), add them to the agent's ignore list.

These habits make the plan step even more effective because you can always back out.

Frequently Asked Questions

Doesn't the plan step slow down simple tasks?

For a one-line fix, yes, it adds a few seconds. But for anything that touches more than one file, the plan step usually saves time because you avoid a wrong implementation that requires rework.

What if the agent's plan is wrong?

That's the point of the plan. You can correct it before any file is changed. Ask the agent to revise the plan, or provide more context, and then approve only when it matches your intent.

Can I make the agent always plan without asking?

Yes. Most tools support a global instruction like "Always propose a plan before editing files." You can add this to your project's agent configuration file, and it will apply to every session.

What if the agent doesn't support plan mode?

You can still simulate it by asking the agent to "describe the changes you will make" before giving it permission to edit. If the tool has no approval step, you can run it in a sandbox or a separate branch and review the diff.

Is a plan the same as a commit message?

No. A commit message describes what was done; a plan describes what will be done. The plan is forward-looking and should be detailed enough to verify against the code, while a commit message is a summary of the final diff.