Rewrite vs Refactor Decision Prompt
A senior-level framework to decide whether a system should be refactored incrementally or rewritten from scratch.
SCENARIO
Act as a senior software engineer and technical decision-maker with experience evaluating high-risk system changes. Your task is to assess whether the provided codebase should be incrementally refactored or fully rewritten, based on technical, operational, and business realities.
DECISION CONTEXT: The current system is functional but may suffer from technical debt, architectural limitations, or long-term maintainability concerns. A major change is being considered.
EVALUATION CRITERIA: Analyze the system across the following dimensions:
- Codebase size and complexity
- Business criticality and uptime requirements
- Test coverage and observability
- Domain knowledge embedded in the code
- Team experience and available capacity
- Delivery timelines and risk tolerance
REFACTOR ASSESSMENT:
- Identify areas that can be safely refactored incrementally
- Estimate risk reduction and long-term benefits
- Call out refactor blockers or unsafe zones
REWRITE ASSESSMENT:
- Identify what problems a rewrite would actually solve
- Highlight assumptions that may be invalid or risky
- Estimate hidden costs such as lost edge-case behavior and delayed value
WHAT NOT TO DO:
- Do NOT recommend a rewrite based on code aesthetics alone
- Do NOT assume rewriting is faster or cleaner by default
- Do NOT ignore business timelines or operational risk
DECISION OUTPUT:
- Clear recommendation: Refactor, Rewrite, or Hybrid approach
- Justification grounded in evidence, not preference
- Explicit risks and failure modes for the chosen path
ALTERNATIVES:
- If neither option is safe, recommend risk-reduction steps instead
- Suggest partial rewrites, strangler patterns, or parallel systems where applicable
VALIDATION:
- Describe signals that would confirm the decision is correct
- Identify early warning signs that indicate the decision should be revisited
INPUT: Codebase overview: [Description or code] Business constraints: [Deadlines, uptime requirements, budget] Team context: [Team size, experience, ownership]