The prompt
You are reading unfamiliar code that I have to modify. Your job is to tell me what it does and what will bite me, not to rewrite it. **1. One-paragraph summary** What this code is for, in the language of the problem domain rather than the implementation. **2. Control flow** The main path through it, and every early return, guard clause and exception path. Which conditions are actually reachable? **3. Implicit assumptions** The most important section. What does this code assume that is not checked or documented? Input shape, ordering, non-emptiness, timezone, encoding, single-threadedness, a specific caller. These are what break when you change something nearby. **4. Side effects** Everything it touches beyond its return value — mutated arguments, module state, I/O, logging, caches, globals. **5. Suspicious details** Anything that looks deliberate but unexplained: a magic number, an off-by-one that may be load-bearing, a swallowed exception, a commented-out line, a sleep. For each, say whether it looks like a bug or a fix for one. Do not assume it is a mistake. **6. Before you change it** The three questions I should answer, or the three tests I should write, before modifying this. Say "I cannot tell from this code" where that is the honest answer. A confident guess about a load-bearing assumption is worse than no answer. --- Code: [PASTE YOUR CODE HERE]
Replace everything in [SQUARE BRACKETS] before you run it. The bracketed fields are not optional — they are what the output is built from.
Why this prompt is built this way
The framing is unusual and deliberate: tell me what it does and what will bite me, not how to rewrite it. Asked about unfamiliar code, models reach immediately for improvements, and improvements are precisely what you must not act on before you understand why the code is the way it is.
Section 3 on implicit assumptions is where the value concentrates. Code rarely breaks because of what it says; it breaks because of what it quietly relies on — that the list is non-empty, that the caller already validated, that timestamps are UTC, that this only ever runs on one thread. None of that is in the source, and all of it breaks when you change something nearby.
Section 5 is the one that saves incidents. Its instruction — do not assume it is a mistake — inverts the usual disposition. A magic number, a swallowed exception, an off-by-one that looks wrong: in legacy code these are often scars from a production failure, and removing them reopens the wound. Asking whether something looks like a bug or a fix for one is a genuinely different question from asking whether it looks wrong.
The closing instruction to say "I cannot tell from this code" matters because the failure mode here is a confident guess about exactly the load-bearing assumption you were trying to find.
What to use it for
- Onboarding to a codebase
- Pre-refactor investigation
- Debugging unfamiliar code
- Writing missing documentation
Adapting it to your situation
- Include the callers. Roughly half of the implicit assumptions are only visible from the call site, and this is the highest-value addition you can make.
- Add the test file if one exists. Tests encode the intended contract and often explain a strange branch.
- Add git blame context — "this line was changed in a hotfix" turns a suspicious detail into an explained one.
- Ask for the three questions in section 6 first if you are short of time; they are the actionable part.
Where this goes wrong
Everything in section 3 is inference, not fact. The model is reading one file and guessing at a system. Treat each stated assumption as something to verify against the rest of the codebase, not as documentation.
And resist acting on section 5 immediately. The right response to an unexplained magic number is to find out why it is there — in git history, in the issue tracker, from whoever wrote it — not to clean it up because a model found it suspicious.
Which model to run it on
Cursor has a real advantage here, because it can read the surrounding files and find the callers itself. Claude is strong on the reasoning when you paste the context in manually.
Practical tips
Include the callers if you have them — half the implicit assumptions are only visible from the call site. The "suspicious details" section is where the value is: an unexplained magic number is often the scar from a production incident, and removing it reopens the wound.