# Ask For The Diff, Not The File

> Requesting a whole rewritten file is how silent regressions get into your codebase.

- **Author:** [Abhay Pratap Mishra (@abhay)](https://www.promptabide.com/abhay)
- **Published:** 2026-08-22
- **Updated:** 2026-08-24
- **Tags:** `prompt-engineering`, `code-review`, `developer-workflow`
- **Views:** 31800
- **Likes:** 1962

## Prompt

````
I lost an afternoon to this and I would like nobody else to.

I asked for a fix to one function in a 300-line file. I got back the whole file, fix included, plus three lines of unrelated "tidying" that quietly changed a default from `false` to `true`. It reviewed clean, because I was reading for the fix rather than for everything else.

**The prompt that stopped it happening:**

```
Return your change as a unified diff against the file I gave you.
Use 3 lines of context. Do not include unchanged hunks.
If a change requires touching more than the function I named, stop and
tell me why instead of making it.
```

**What each line buys you:**

*Unified diff* - you review the change, not the file. A three-line fix is three lines on screen.

*3 lines of context* - enough to apply the patch by hand, not so much that the diff becomes the file again.

*No unchanged hunks* - stops the "here is the diff" preamble that is then followed by the whole file anyway.

*Stop and tell me why* - this is the important one. It converts scope creep from a silent edit into a visible question. Roughly one time in five it comes back with a genuinely good reason the fix cannot be local, and that is a conversation worth having before the code exists rather than after.

**Caveat:** models are noticeably worse at producing *applyable* diffs than at producing correct code. Line numbers in the hunk headers are often off by one or two. Do not pipe the output straight into `git apply` - read it, then make the edit yourself. The point is the review surface, not the automation.
````

## Output

*Produced by Claude · claude-opus-4.*

````
```diff
@@ -142,7 +142,11 @@ export async function resolveSession(req: Request) {
   const token = req.cookies.session
   if (!token) return null

-  const payload = verify(token, SECRET)
+  let payload: SessionPayload
+  try {
+    payload = verify(token, SECRET)
+  } catch {
+    return null
+  }

   return loadUser(payload.sub)
```

One note before you apply this: loadUser can still throw if the user row was deleted while the cookie is live. That is outside the function you named, so I have not touched it - but it is the same class of bug and you probably want it in the same pass.
````

---

Canonical HTML: https://www.promptabide.com/bides/ask-for-the-diff-not-the-file
Agent guide: https://www.promptabide.com/llms.txt · https://www.promptabide.com/agent-instructions.md
Sitemap: https://www.promptabide.com/sitemap.xml
