Pattern: Plan First, Then Code
Have the AI write a plan before it starts coding β it prevents expensive wrong turns.
The problem with "just do it"
If you tell an agent "build this" directly, it starts acting immediately β and often makes silent assumptions that turn out wrong. You usually only notice once something's already half-built the wrong way.
The pattern
Ask the AI for a plan before any code gets written:
- Describe the goal and requirements
- Ask the AI to produce a step-by-step plan (no code yet)
- Read the plan, correct wrong assumptions, answer open questions
- Only then: "Now implement the plan"
Why this works better
A plan is cheap to read and correct β code is more expensive to read and correct. Catching a mistake in the plan ("you forgot we already have auth middleware") takes a minute. Catching the same mistake in finished code takes much longer.
When it matters most
- Multi-step or unclear tasks
- When multiple files or systems are involved
- When mistakes would be costly (production code, database migrations)
For small, unambiguous changes ("change this color"), an explicit planning step is usually overkill.
What it looks like
You: Before you write any code, give me a plan for adding rate limiting to the API.
Agent: Plan:
1. Add a rate-limit middleware in app.js using a sliding-window counter
2. Apply it to all /api routes, return 429 on limit exceeded
3. Add config for limits per route in config.js
You: Looks good. Just do step 1 for now, I'll review before we continue.
Agent: Starting with step 1 β the middleware in app.js.
EXAMPLE
Prompt: 'First create a plan (no code changes) for a login feature with email+password. I'll confirm the plan before you start.'
π οΈ EXERCISE β TRY IT YOURSELF
Take a small real feature from your project (or: βBuild a function that converts CSV rows to JSONβ) and make the AI plan first, build second.
- Write: βFirst create a plan in 3β5 steps. No code yet.β
- Read the plan critically. Cut one step that is too big, or make it more precise.
- Only then: βImplement step 1.β β and work through the plan step by step.
β SELF-CHECK
- β Did the AI really write NO code in the first step? (If it did: sharpen your prompt)
- β Did at least one plan step need correcting? (Almost always β that is exactly what the plan is for)
- β Did the result come together in smaller, checkable pieces than usual?
QUICK QUIZ
Why is a planning step before coding worthwhile?
SOURCES
- Anthropic: Claude Code best practices β www.anthropic.com
- Anthropic docs: Claude Code common workflows β docs.anthropic.com
- Anthropic docs: Prompt engineering overview β docs.anthropic.com