Prompt
Give a coding assistant a behavior-preserving refactor brief
An original prompt for stating invariants, allowed files and review evidence before an assistant reorganizes an existing codebase.
THE SHORT ANSWER
A refactor brief should describe the behavior to preserve and the evidence needed to review the change.
Use the demonstration carefully
Lee Robinson’s archived post describes a refactoring session involving dependency upgrades, codemods, file changes and manual work. The video was not reviewed for this resource. Anthropic’s current coding guidance recommends explicit verification criteria. Neither source proves that a particular refactor is safe; the reader still needs a contract for the behavior and scope of their own change.
State the invariants first
Pick one boundary, such as a parser’s accepted inputs or a page’s existing routes. List the outputs and failure behavior that must remain stable. Name the files the assistant may edit and the adjacent changes that require a separate decision. If a dependency upgrade is necessary, make that dependency visible instead of allowing a cleanup request to absorb an unrelated migration.
Review a complete return
Ask for the diff, the checks actually run and any unresolved behavior difference. Include one representative failure case in the verification plan; a formatting-only comparison will not protect a parser’s error handling. The downloadable prompt is original and should be adapted to repository instructions. No code was changed or tested for this resource, and a completed prompt is not evidence that the resulting patch is correct.
Put it to work.
- List observable invariants.
- Bound the editable scope.
- Separate dependency migrations.
- Review diff and check output.
Take the template.
Original CooScope text for your own working notes. Fill in the blanks with evidence from your task.
CooScope — Refactor brief prompt Original template informed by the linked coding guidance. Refactor [component] for [specific readability/structure goal]. Preserve [inputs, outputs, error behavior, public routes/API]. Allowed files: [list]. Read [repository instructions and relevant context] first. Propose separately any dependency upgrade or behavior change. Verify using [existing checks plus representative failure case]. Return the diff summary, actual commands/results and unresolved concerns. Stop if preserving [invariant] requires a product decision. Limit: this prompt does not replace code review or meaningful checks. Evidence context: https://code.claude.com/docs/en/best-practices
Go to the source.
Original material, with its own scope and publication date. This note is an explanation, not a CooScope performance test.
Source published · Editorial review
Archived English post text; primary sources reviewed separately. Generated annotations, media and missing replies are outside the evidence scope.
- @leerob — archived X post (2025-08-25)
- Anthropic — Claude Code best practicesLink / source review: 2026-10-15