Task boundary
The first lines define one outcome and the environment in which it must be achieved.
The interactive tools could not load. Reload this page; the guides and source links are still available.
Refactor / Original task brief
Lock the public contract, restructure in narrow steps, and prove that outputs, errors, side effects, and performance boundaries remain intentional.
Code is hard to extend or review, but changing product behavior is not part of the task.
Task
Refactor {{refactor_target}} to improve {{quality_goal}} without changing the public contract.
Public contract to preserve
{{public_contract}}
Method
1. Enumerate observable inputs, outputs, errors, files, requests, events, and timing-sensitive behavior.
2. Run existing tests and add characterization tests for uncovered contract edges before restructuring.
3. Make one structural change at a time. Keep each step executable and tests green.
4. Remove duplication only after the new boundary is covered. Avoid speculative abstractions and unrelated cleanup.
5. Compare generated artifacts, API shapes, or rendered routes before and after when those are part of the contract.
Evidence to return
- Contract tests added or identified.
- A file-level explanation of the new structure.
- Before/after complexity or duplication evidence that supports {{quality_goal}}.
- Full relevant test and build output.
Stop conditions
Stop if preserving behavior is impossible without a product decision, if a dependency upgrade changes the contract, or if unrelated working-tree changes make the diff unsafe to isolate.Variables
{{refactor_target}}{{public_contract}}{{quality_goal}}Keep unknowns explicit. Remove a section only when it truly does not apply; do not replace evidence requirements with a request for confidence.
Why this prompt is structured this way
The first lines define one outcome and the environment in which it must be achieved.
The method asks the coding agent to inspect and execute rather than jump directly to a plausible patch.
The result must include paths, commands, measurements, or browser observations that another person can check.
The agent is told when not to guess, broaden scope, weaken a guard, or overstate completion.
Related prompts
Inspect the actual diff in repository context and report only actionable defects with severity, evidence, and a concrete failure scenario.
Use when: A branch or working tree is ready for an independent correctness, security, and maintainability review.
Open promptExercise a real user flow with semantic, focus, state, contrast, target-size, and responsive evidence rather than a static checklist alone.
Use when: A web interface has a form, dialog, menu, custom control, upload, or task flow that must work beyond pointer input.
Open prompt