promptgarten 🌱
🌍 ES
Prompt pattern●●○3 min Β· +40 XP

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:

  1. Describe the goal and requirements
  2. Ask the AI to produce a step-by-step plan (no code yet)
  3. Read the plan, correct wrong assumptions, answer open questions
  4. 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.

  1. Write: β€œFirst create a plan in 3–5 steps. No code yet.”
  2. Read the plan critically. Cut one step that is too big, or make it more precise.
  3. 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

RELATED TOPICS

Pattern: Feed Context Instead of Asking Vaguely ●○○Vibe Coding: When It Works, When It Bites You ●○○What Is a Prompt? ●○○