Skip to content
mentoor

Topic 1 of 5 · 5 min read

Planning before the agent edits

Goal: Run a read-only exploration and planning step and approve, edit or reject the agent's plan before any file changes.

Make the agent read and plan before it writes: a wrong plan costs a minute to fix, a wrong diff costs an hour. Planning is the cheapest place to catch a misunderstanding.

Check yourself · 1 of 3

You want an agent to understand a module before changing it. Which setting fits best?

Choose one answer

Why it matters

Coding agents such as Claude Code, Codex and Cursor will start editing the moment you give them a task. If they misread it, you only find out after many files have changed. A plan is a short text you can read in a minute. It shows which files the agent thinks matter, which approach it picked and what it plans to leave alone.

How to do it

  1. Use a read-only mode. Claude Code has plan mode, Cursor has a plan mode in its agent, and Codex can run with a read-only sandbox. In all of them the agent can read files and run searches but cannot edit.
  2. Ask for exploration first. "Read the checkout code and tell me how coupons are applied. Do not change anything."
  3. Ask for a plan with a fixed shape. Goal, files to change, ordered steps, how each step is checked, and what is out of scope.
  4. Read the plan against your own picture of the task. Are the right files named? Is a step missing, such as migrations or tests? Did it add work you did not ask for?
  5. Edit, then approve. Reply with corrections ("do not touch the pricing module; reuse applyDiscount") and ask for the plan again. Only approve when you could explain each step to a colleague.

Before and after

Weak: "Add rate limiting to the API."

The agent plans a new middleware, a Redis dependency and changes to all 40 routes.

Better: "Read src/api and src/middleware. Propose a plan to rate limit only POST /login, using the limiter helper that already exists. List files, steps and checks. Do not edit."

The plan is now three steps in two files, and you can check it against the repo.

What goes wrong

  • Approving a plan you skimmed. A plan that sounds sensible can still name the wrong file or invent an API.
  • Planning without exploring. If the agent did not read the code, its plan is guessed from names and general habits.
  • Plans with no checks. A step with no way to verify it is a wish. Ask how each step will be proven.
  • Plan mode forgotten. The agent leaves read-only mode, or you do, and edits begin before approval.

Examples

A plan that was cut down

The agent proposes a new RateLimiter class, a Redis client and edits to every route. You reply: "Reuse limiters/token-bucket.ts, apply it only to POST /login, no new dependencies." The second plan has three steps and one new test.

The missing step

A plan for renaming a database column lists the model and the API handler. It never mentions the migration or the nightly export script that reads the old name. Asking "what else reads this column?" before approval finds both.

Key points

  • Explore and plan in a read-only mode before any edit, so mistakes show up as text, not as a diff.
  • Ask for a plan with a fixed shape: goal, files, ordered steps, a check per step and what is out of scope.
  • Read the plan against your own picture of the task and the repo, not just for whether it sounds sensible.
  • Edit the plan with specific corrections, such as files to avoid and helpers to reuse, then ask for it again.
  • Approve only a plan whose every step you could explain and verify.

Common mistakes

  • Letting the agent start editing straight from a one-line task.
  • Approving a long plan after reading only its first and last lines.
  • Accepting a plan that has no check for any step.
  • Treating the plan as final when later code reading shows it was wrong.

Check yourself · 2 of 3

An agent's plan lists the files to change and the steps, but nothing about how to test them. What is the best reply?

Choose one answer

Check yourself · 3 of 3

A plan for adding rate limiting touches 40 routes, but you only wanted to protect login. What should you do before approving?

Choose one answer

Practice items, not counted towards your mastery.

Start here