Skip to main content
Prompt

Plan Before Code Prompt

A planning prompt that covers business, domain, tech design and steps, then lists the decisions it needs from you.

By Matthews WongUpdated

Key takeaway

Paste this before a non-trivial change. The agent reads the code the change touches, then plans it from four points of view: business, domain, tech design verified in the real code, and numbered steps with a check for each. It lists every assumption and every decision that is yours, and it writes no code until you reply approved.

1 file

The file

Exactly what the download contains. Read it first, then copy or download.

plan-before-code-prompt.md
Plan this change with me before any code is written. Do not create or edit files until I reply "approved".

The change: [WHAT I WANT BUILT OR CHANGED]
Who it is for: [THE USERS, OR THE TEAM THAT ASKED FOR IT]
Constraints: [DEADLINE, STACK, THINGS THAT MUST NOT CHANGE, OR "NONE"]

## First, read

Read the code this change touches: the files, their callers, their tests, and one existing feature of the same kind so you can follow its patterns. Read any project instruction file (CLAUDE.md, AGENTS.md, README). Name the files you read.

## Then write the plan from four points of view

Keep each one short. Write only what this task needs.

1. **Business.** Who the users are, the journey they take, what they need at each step, and the screens or outputs they expect. End with acceptance criteria I can check.
2. **Domain.** How this domain works in general, independent of this system: the usual process, roles and terms. For a warehouse that is goods receipt, putaway, picking, packing and goods issue. Mark anything you are unsure about.
3. **Tech design.** The components, data and interfaces this change adds or alters, and how it fits the code that exists. Verify every claim in the real code and cite the file. Name the one alternative you rejected, and why.
4. **Instructions.** Numbered steps. Each step says what to do, where (file path or tool), and how to verify it: the command to run and the result to expect. Order them so each step can be tested and committed on its own.

## Then list what you need from me

- **Assumptions:** every assumption you made, numbered, each with what changes if it is wrong.
- **Decisions:** every decision that is mine to make, each with the options and the one you recommend.
- **Out of scope:** what this plan deliberately leaves out.

## Rules

- When a view is missing and the code cannot answer it, do not guess. Ask whether I have that context or want you to draft it.
- Do not invent requirements, business rules, table names or APIs. If you did not read it, write "not verified".
- Plan only what was asked. No speculative features.
- No code in this reply, beyond a short signature or schema sketch where it makes the design clear.

Stop after the plan and wait. Once I approve, work one step at a time, run each step's check, show the real output, and tell me as soon as the work contradicts the plan.
How to use it

From download to working

Use it when

  • The change touches more than one module, or data that is hard to change back.
  • The request is one sentence and you can already see three ways to read it.
  • The feature sits in a domain with its own rules, such as warehouse, finance or approvals.
  • An agent built the wrong thing last time and you paid for it in review.
  1. Fill the three placeholders

    Write the change you want, who it is for, and the constraints: a deadline, the stack, or things that must not change. Paste the ticket text if you have one. Write none where there is no constraint.

  2. Check what it read

    The plan starts by naming the files the agent read. If the list misses the module you know is involved, say so before you read further. A plan built on the wrong files is wrong in every section.

  3. Answer the assumptions and decisions

    Go through the numbered assumptions and correct the wrong ones. Pick an option for each decision. This list is the main output: every item is something the agent would otherwise have decided silently.

  4. Approve, then build one step at a time

    Reply approved once the plan is right. The agent then works through the numbered steps, runs each step's check and shows the real output. It is told to speak up as soon as the work contradicts the plan.

What is inside

Why it is written this way

Four points of view, each short

Business, domain, tech design and instructions. Most plans an agent writes are only the last two. Without the first two it designs a clean solution to a problem nobody has. The prompt asks for only what the task needs, so the plan stays readable.

The domain view is separate from the system

It asks how the domain works in general: the usual process, roles and terms. A feature that ignores how goods receipt or an approval chain really works compiles, passes its tests and is still rejected by the people who use it.

Tech design is verified in the real code

Every design claim cites a file, and anything unread is marked not verified. This is the guard against a plan that calls a function, table or endpoint the project does not have.

Each step carries its own check

A step says what to do, where, and which command proves it worked. Steps are ordered so each can be tested and committed alone, which keeps a failure small and easy to locate.

Ask instead of guessing

When a view is missing and the code cannot answer it, the agent asks whether you have that context or want it drafted. Assumptions, decisions and out of scope are listed apart, so nothing is settled without you seeing it.

Watch for

What goes wrong

  • It is too much for a small change. For a one-file fix with an obvious cause, the plan costs more than the work.
  • The domain section comes from the model's general knowledge. Your company's process may differ, so correct it before you approve.
  • Approving without reading the assumptions throws away the point of the prompt. A wrong assumption you skipped becomes code you have to remove.
  • In a chat window with no access to the code, the tech design cannot be verified. Paste the relevant files, or expect that section to be marked not verified.
Questions

Frequently asked

Short answers before you download it.

How do I make an AI coding agent plan before it writes code?

Tell it what the plan must contain and when it may start. This prompt forbids creating or editing files until you reply approved, asks for four sections plus assumptions and decisions, and ends with an instruction to stop and wait.

What are the four points of view in the plan?

Business: the users, their journey and what they need. Domain: how the field works in general, apart from this system. Tech design: components, data and interfaces, checked against the real code. Instructions: concrete steps with paths and a way to verify each one.

Do I still need this if my agent has a plan mode?

They do different jobs, and they work together. A plan mode controls whether the agent may edit files. This prompt decides what the plan contains: the business and domain views, verified design claims, and the list of assumptions and decisions.

When is a plan not worth writing?

When the change is small, local and easy to undo: a typo, a one-line fix, a renamed label. Use the prompt when a wrong guess is expensive, such as a change across modules, a data migration or a feature with business rules.

Go deeper

Learn what this file packages

Free lessons and articles on this site that explain the ideas behind it.

More from the toolkit

Take these too

PromptFree

Codebase Onboarding Prompt

A read-only prompt that maps an unfamiliar repository: what it does, how to run it, how a request flows, what is risky.

  • Claude Code
  • Cursor
  • Claude.ai

1 file2.3 KB.md

PromptFree

Debugging Prompt: Reproduce First

A debugging prompt that makes the agent reproduce the bug and prove the cause before it touches any code.

  • Claude Code
  • Cursor
  • Claude.ai

1 file2.3 KB.md

PromptFree

Code Review Prompt: Correctness First

A review prompt that reports bugs with file, line, a failure scenario, severity and a fix, and skips style nitpicks.

  • Claude Code
  • Cursor
  • Claude.ai

1 file2.3 KB.md

All toolkit items