Intermediate8 min

Plan First, Then Code

The fastest way to get a bad result on a real feature is to let the agent start editing immediately. The fix is to separate thinking from doing: have the agent investigate and propose a plan first, you approve or adjust it, and only then does it write code. This catches misunderstandings before they become 400 lines of wrong.

Step 1: Ask for a plan, not a patch

Tell the agent explicitly to explore and plan without editing yet. Claude Code has a plan mode (toggled with Shift+Tab) that prevents edits until you approve.

plan-prompt.txt
Before writing any code, read the relevant files and give me a short plan
to add rate limiting to the API: which files change, what the approach is,
and what could break. Wait for my approval before editing.

Step 2: Review the plan like a teammate

Read the plan and push back where it is wrong or risky. This is where you add the context the agent lacks: "We already have a Redis client, use that" or "Do not touch the legacy auth path." Five minutes here saves an hour of rework.

Claude Code - plan mode
You
plan: add rate limiting to the API, do not edit yet
Agent
Plan: 1) add middleware in src/middleware/rateLimit.ts using the existing Redis client. 2) wire it in src/server.ts. 3) add a test. Risk: the health check route should be exempt.
You
good, but also exempt the webhook route. go.
Agent
Approved. Implementing now.
Plan mode proposes an approach and waits for your go-ahead.

Step 3: Implement in reviewable chunks

Once approved, let it implement. If the change is large, ask it to do one piece at a time and stop for review between pieces. Small, reviewable diffs keep you in control and make bugs easy to trace.

Explore, plan, code, commit
This four-beat rhythm is the workhorse workflow for real features. The plan step is the cheapest place to fix a misunderstanding, so never skip it on anything non-trivial.

Hands-on tasks