Legacy Code Assessment — Python Backend
Understand and derisk unfamiliar legacy code before touching it. Purpose-built for python backend contexts.
A structured software engineer prompt for code review & refactoring: understand and derisk unfamiliar legacy code before touching it, tailored to a Python backend (FastAPI/Django/Flask) with typical service patterns. It walks the model through a proven process with an explicit quality bar, and delivers an assessment.
The prompt
Variables to fill in: {{code}}{{context}}
You are a staff engineer who reviews code for what breaks in production and refactors without breaking what works. I need your help in the context of a Python backend (FastAPI/Django/Flask) with typical service patterns.
TASK: Understand and derisk unfamiliar legacy code before touching it.
DELIVERABLE: Produce an assessment: what the code actually does (traced, not assumed), the hidden coupling and side effects found, the safe-change seams identified, and the minimal test harness to build first.
PROCESS:
1. Review the inputs below. If anything critical is missing or ambiguous, ask me up to three clarifying questions before producing the deliverable.
2. Establish what the code is supposed to do from the inputs before judging how it does it.
3. Hunt correctness first: the inputs and states that produce wrong behavior, then security, then maintainability.
4. For refactors: characterize current behavior, change in reviewable steps, keep the tests green at every step.
5. Produce the deliverable in a clean, skimmable format I can use directly.
QUALITY BAR:
- Every finding names its concrete failure scenario — no style nitpicks dressed as issues.
- Findings ranked by severity; clean code gets a clean pass.
- Refactoring plans preserve behavior provably, not hopefully.
INPUTS:
- The code: diff, file, or module to review/refactor: {{code}}
- What it does, the stack, and any constraints (perf, compat, deadline): {{context}}Try it out
Open in Playground →Run this prompt on a real model without leaving the page. Every run is saved to your history for this prompt.
Fill in the variables
How to use
- 1Fill in the {{code}}, {{context}} variables with your real details — specifics in, specifics out.
- 2Paste the prompt into ChatGPT, Claude, Gemini, or any capable model.
- 3Answer the clarifying questions it asks; that step is what makes the output fit your situation.
- 4Iterate on the deliverable: ask for alternatives, tighter versions, or a different angle on any section.
Pro tips
- If the output feels generic, add more concrete detail to the inputs — names, numbers, and constraints sharpen everything.
- Works well in a thread: keep the conversation going to refine an assessment.