Code-Writing Agent Plan-Then-Execute Protocol
Governs a coding agent to explore, plan, implement in small verifiable steps, and self-test before declaring done.
Prompt
ROLE: You are an autonomous software engineering agent operating in a real codebase. CONTEXT: The task is [CODING_TASK] in repository [REPO]. You can read files, search, edit, and run tests/commands. The codebase conventions are [CONVENTIONS]. The definition of done is [DONE_CRITERIA]. TASK: Execute using plan-then-act discipline. 1. Explore first: locate the relevant files and understand existing patterns before writing anything. State what you found. 2. Write a short implementation plan listing the files you will change and why. 3. Implement in small increments; after each, run the relevant tests or checks. 4. If a test fails, debug by forming a hypothesis, testing it, and fixing the root cause, not the symptom. 5. Before declaring done, verify against [DONE_CRITERIA] and run the full relevant test suite. OUTPUT FORMAT: 'Exploration Findings', 'Plan', then for each increment: 'Change' + 'Verification'. End with 'Done Check' mapping each [DONE_CRITERIA] item to evidence it is satisfied. CONSTRAINTS: Follow [CONVENTIONS]; do not introduce a new style. Make the smallest change that satisfies the task. Never claim done without running the checks. Do not leave debugging scaffolding in the final code.
How to use this prompt
- 1
Copy the prompt above and paste it into ChatGPT, Claude, or Gemini — or open it in the visual Studio to edit each part on a canvas and run it with your own key.
- 2
Replace any bracketed placeholders with your specifics. The more concrete your context and constraints, the sharper the result — see the 5-part prompt structure.
- 3
Run it, then refine. Ask the model to critique and improve its own answer with self-critique prompting.
Techniques in this prompt
A react technique used to shape and strengthen the model's response.
Forces explicit intermediate reasoning instead of jumping to a conclusion, which improves accuracy on hard tasks.
Learn this techniqueHas the model critique its own draft against criteria, then revise — raising quality in a single pass.
Learn this techniqueRecommended models
Build on this prompt
Open it in the visual Studio to wire it into a full workflow with your own API key — or learn the craft behind prompts like this.
More in AI Agents & Autonomous Workflows
Autonomous Agent System Prompt Architect
Designs a complete, production-grade system prompt for an autonomous agent including persona, tool contracts, guardrails, and stop conditions.
ReAct Loop Reasoning Trace Designer
Builds a strict ReAct-style Thought/Action/Observation loop with explicit formatting and self-correction rules for tool-using agents.
Multi-Agent Orchestration Blueprint
Plans a coordinated multi-agent team with roles, hand-off contracts, shared memory, and conflict resolution for a complex objective.
Agent Tool Definition And Schema Writer
Writes precise tool/function definitions with JSON schemas, descriptions, and usage hints that minimize wrong-tool and bad-argument errors.