Back to library
DevelopmentGPT-5Code ReviewWorkflowArchitecture

Legacy Refactor Scope

Scope legacy refactors with boundaries, risks, acceptance criteria, and incremental paths.

Legacy Refactor Scope

Prompt

# Role
You are a senior tech lead who turns risky refactors into deliverable increments.

# Use Case
I want to refactor legacy code while controlling scope, risk, and business impact.

# First collect these inputs
1. Pain points, code location, call graph
2. Business-critical paths and non-interruptible flows
3. Test coverage, monitoring, release method
4. Team capacity and deadline

# Task
Based on the information I provide, complete "Legacy Refactor Scope". If critical information is missing, ask up to five clarifying questions first; otherwise produce the result directly.

# Output Structure
1. Goals and non-goals
2. Risk map: business, technical, testing, release
3. Phased plan: wrap, replace, migrate, clean up
4. Acceptance criteria, rollback, stop conditions

# Quality Bar
1. Stabilize boundaries before moving internals
2. Every phase must be independently verifiable and reversible
3. Do not sacrifice delivery for aesthetic architecture

# Avoid
1. Do not recommend a big-bang rewrite
2. Do not ignore data migration
3. Do not write refactor goals as abstract wishes

# Final Deliverable
End with a concise copy-ready version that preserves key constraints and removes explanatory commentary.

Curated by the editorial team · Updated 07/09/2026 · Model: GPT-5

Usage guide

How to use this prompt

This template is designed for development tasks. Replace the sample details with real constraints before running it in GPT-5.

  1. Step 1

    State the stack, runtime, inputs, outputs, and existing constraints.

  2. Step 2

    Ask for the approach and risks before requesting the smallest verifiable change.

  3. Step 3

    Run tests, type checks, and critical scenarios locally before merging.

Details to replace or add

Specific inputs produce more useful results. Do not submit passwords, private information, or confidential business data.

  • Language, framework, and versions
  • Current code and error output
  • Expected inputs and outputs
  • Compatibility and performance constraints
  • Acceptance test cases

Output checklist

  • The code runs on the specified versions
  • Edge cases and errors are handled
  • Existing project patterns are reused
  • Tests cover critical behavior
  • No new security or performance risk appears

Common adjustments

Provide the directory structure and interfaces when the answer drifts from the project.

Limit files and request staged changes when the proposal is too broad.

Ask for runnable test commands and expected output when verification is unclear.

This prompt separates Development, Code Review, Workflow, Architecture requirements into context, constraints, and output format. Keep the objective fixed and revise only the conditions that failed before rewriting the whole template.

Related prompts

Explore more templates in Development.