Explore → Plan → Code → Verify Loop for Coding Agents
A phase-gated workflow prompt for coding agents: read before planning, plan before coding, verify before claiming done — with explicit rules for what each phase may and may not do.
Prompt variables
2 variables detected — fill them and Copy inserts your values (0/2 filled).
Work on the task below using four gated phases. Do not blend phases — the failure mode this prevents is writing plausible code for a codebase you have not actually understood.
## Phase 1 — EXPLORE (no code changes allowed)
- Read the files relevant to the task. Follow the data: find where the behavior lives, who calls it, what tests cover it.
- Identify the conventions in play: error handling style, test patterns, naming, how similar features are structured. Your change must look like the codebase wrote it.
- Find the verification commands (test/lint/typecheck) from CI config or package scripts — record the exact commands.
- Output of this phase: a short map — relevant files and their roles, the 2–3 things that surprised you, and any discrepancy between the task description and what the code actually does. If the task is based on a wrong assumption about the code, STOP and say so.
## Phase 2 — PLAN (still no code changes)
- List the files you will change and what changes in each, in order.
- State how you will verify each change and the task overall — which tests exist, which you will add, what manual check proves the behavior.
- Name the risks: what could this break, what are you least sure about.
- Keep it under 20 lines. {{plan_approval_rule}} (e.g. "Wait for my approval before Phase 3" or "Proceed directly").
## Phase 3 — CODE
- Implement in the planned order, smallest coherent steps. After each step, run the fast verification (typecheck/affected tests).
- When reality contradicts the plan (it often will), update the plan explicitly — one line: "Plan change: X because Y" — rather than silently drifting.
- Write nothing the plan does not cover; new discoveries become plan changes or follow-up notes, not drive-by edits.
## Phase 4 — VERIFY
- Run the FULL verification suite (the exact commands from Phase 1) and read the output — do not pattern-match on "looks green".
- Re-read your complete diff hunk by hunk as a reviewer would: leftover debug code, accidental changes, missing edge case from the task?
- Report: what changed per file · verification commands run with actual results · plan changes made and why · assumptions and follow-ups. Never report done with failing or unrun verification — a blocked honest report beats a false success.
Task: {{task_description}}
Comments (0)