Refactor / Original task brief

Refactor code while preserving observable behavior

Lock the public contract, restructure in narrow steps, and prove that outputs, errors, side effects, and performance boundaries remain intentional.

Use when

Code is hard to extend or review, but changing product behavior is not part of the task.

Ready to adapt
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.

Replace these fields before you run it.

{{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.

Task boundary

The first lines define one outcome and the environment in which it must be achieved.

Method

The method asks the coding agent to inspect and execute rather than jump directly to a plausible patch.

Evidence to return

The result must include paths, commands, measurements, or browser observations that another person can check.

Stop conditions

The agent is told when not to guess, broaden scope, weaken a guard, or overstate completion.

Continue from the next engineering decision.

ReviewOriginal brief

Review a change set before merge

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 prompt
ReviewOriginal brief

Audit a web task for keyboard and screen-reader access

Exercise 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