Agentic Workflows: Plan, Act, Verify
Prompt agents to work in a plan-act-verify loop with scope limits and a feedback signal so they self-correct instead of drifting.
TL;DR
- Agents work best in a loop: plan, act, then verify against a real signal like tests.
- Give the agent a way to check itself (tests, type-check, lint) so it self-corrects.
- Set scope and a stopping condition, then review the final diff before accepting.
The Loop
PlanHave the agent lay out its approach before it acts.
"Plan the steps and files first;
wait for my go."ActIt edits files and runs commands to execute the plan.
Agent edits + runs build/tests.VerifyIt checks the result against a signal and iterates if needed.
"Run tests; if red, fix and
repeat until green."Give It A Signal
TestsA test suite is the clearest pass/fail feedback.
"pnpm test must pass before you
call it done."Types & LintType-check and lint catch invented APIs and style drift.
"tsc --noEmit and lint must be
clean."Run ItFor UI or scripts, actually running it is the real check.
"Start the app; confirm the route
renders without errors."Bound The Agent
ScopeName the files or directories it may change.
"Only edit src/export/**.
Do not touch config or CI."Stop ConditionState exactly when the task is complete.
"Stop when the 4 acceptance tests
pass."Pause For RiskHave it check in before destructive or irreversible actions.
"Ask before deleting files or
running migrations."Close It Out
Review The DiffRead the full change for correctness and scope creep.
git diff # is this minimal and
correct?Check The GapsLook at what the tests did not cover before trusting green.
Green != complete. What's untested?SummarizeAsk the agent what it changed and why, as a record.
"Summarize the changes and any
assumptions you made."Tips
- Tell the agent to run the test suite after each change and keep iterating until it is green.
- Bound the blast radius: name the directories it may touch and forbid the rest.
Warnings
- Without a verification signal, an agent declares success on code that does not work.
- An unscoped agent wanders across the repo and makes sweeping, hard-to-review changes.
In Practice
A prompt that sets up a plan-act-verify loop with a test signal, a scope limit, and a stopping condition, so the agent self-corrects to a working state and you review a minimal, bounded diff.
- The agent plans first and waits, so you catch a wrong approach early.
- The test suite is the verification signal it must satisfy.
- Scope and a stopping condition bound the change to a reviewable size.
- A pause-for-risk rule keeps destructive actions under your control.
Task: implement the CSV export per the spec in
docs/export-spec.md.
Work in a loop:
1. Plan the steps and the files you'll change. Show me
the plan and wait for my approval.
2. After I approve, implement it.
3. Run `pnpm test` and `pnpm lint`. If anything fails,
fix it and re-run until both are clean.
Scope: only edit src/export/** and its tests. Do not
touch config, CI, or other features.
Stop when the 4 acceptance tests in the spec pass.
Ask me before deleting any file or running a migration.
When done, summarize what changed and any assumptions.FAQ
An agent can act: read files, edit them, run commands, and observe the results, in a loop. That power means your prompt must supply what a human reviewer would, scope, a definition of done, and a way to check the work, or the agent optimizes for its own guess of success.
It is the feedback that closes the loop. With a failing test or a type error, the agent knows objectively whether it is done and can self-correct. Without one, it has nothing to check against and will confidently report success on broken code.
Scope it. Name the directories or files it may change and say the rest is off-limits. Give a clear stopping condition (for example, 'stop when the new tests pass'). For risky actions, ask it to pause for approval rather than proceed.
Always. The loop gets the agent to a plausible, test-passing state; it does not guarantee the approach is sound or the change is minimal. Review the final diff for correctness, scope creep, and anything the tests did not cover.