
Stop an AI agent from going off-plan by treating the approved plan as a controlled baseline. Set limits on files, interfaces, and change size; require checkpoints; and make replanning an explicit action rather than a silent detour.
Build these controls into the task:
- Scope boundary: List the directories, components, and behaviors the task may change.
- Diff budget: Define when a change has grown enough to require another review.
- Checkpoints: Pause after discovery, interface design, migration work, or another high-risk step.
- Stop conditions: Stop on conflicting requirements, missing access, unexpected schema impact, or repeated test failure.
- Replan rule: Explain what changed, propose a revised plan, and wait for approval before continuing.
Ask the agent to keep a small plan-status table with steps marked pending, active, complete, or blocked. Each progress update should name the current step and evidence produced. This makes drift visible before it becomes a large diff. Repository protections help too: isolated branches or workspaces keep an off-plan experiment away from approved changes.
Do not judge alignment only by whether tests pass. An agent can produce working code that solves the wrong problem or changes an unapproved interface. Compare the final diff against the plan, non-goals, and acceptance criteria. If new information genuinely changes the best path, replan. The objective is controlled adaptation, not rigid execution or invisible improvisation.
Related reading: What makes a good AI coding-agent prompt? and What is Plan Mode in an AI coding agent?.
