Review any coding agent’s diff
Every coding agent that works in your repository ends the same way: files on disk that differ from what git last saw. That’s a git diff, whichever agent wrote it. Run npx diffhub@latest in the checkout the agent changed, read every changed file in one browser tab, comment on lines, then paste one prompt back into Codex, Cursor or Claude Code.
npx diffhub@latestWhat does the review loop look like?
Four steps, and the agent does the fixing. Read the whole diff. Comment on the lines that are wrong, saying what you expect instead. Press Copy & clear. Paste the prompt into the agent. When it’s done, refresh and read the diff again.
Try it here. This is a real hunk from DiffHub’s own history. Click the plus beside a line, write a note, and watch the prompt underneath change.
Preserve diff side in agent review prompts #52
Openmainfix/review-comment-side
apps/cli/lib/export-comments.ts−1+2
6 unmodified lines
const lines = comments.map((c) => { const tag = c.tag ? `${c.tag} ` : ""; const loc = c.lineNumber > 0 ? `:${c.lineNumber}` : "";Removed: return `- ${tag}**${c.file}${loc}**: ${c.body}`;Added: const side = c.lineNumber > 0 ? ` (${c.side === "left" ? "old" : "new"} side)` : "";Added: return `- ${tag}**${c.file}${loc}**${side}: ${c.body}`; }); return `## Code Review Comments\n\nPlease address the following:\n\n${lines.join("\n")}`;};Agent prompt · 1 comment
## Code Review Comments Please address the following: - **apps/cli/lib/export-comments.ts:10** (new side): Should file-level comments name a side too?
Which diff scope matches how your agent works?
Pick the scope by what the agent did with its changes, not by which agent it is.
| If the agent | Use |
|---|---|
| Edits files and leaves them uncommitted | Touched, the default |
| Commits as it goes, on a branch | All, or Committed for just the commits |
| Stages the changes it wants you to see | Staged |
All is the whole-branch view: everything since the branch left its base, committed or not, plus untracked files. It’s the one to read before you push. DiffHub finds the base from origin/main, master, develop or dev, and --base <branch> overrides it.
What about agents in separate worktrees?
Review each worktree on its own. Start DiffHub from inside it, or point at it with --repo:
npx diffhub@latest --repo ../feature-worktreeA linked worktree has its own git directory, so its comments stay separate from the main checkout’s. If port 2047 is taken, DiffHub uses the next free one up to 2056, so a few can run side by side. Starting it again for the same checkout replaces the one already running.
Keep each prompt with the checkout you reviewed. Two worktrees can hold the same filename with different code in it.
What if the agent opened a pull request?
If it’s on a public GitHub repository, paste its URL into the live demo and read it in the same viewer, no install. Comments need the local CLI, because they’re saved in your repository, so for a full review check the branch out and run DiffHub with the All scope.
What does the agent receive?
Plain Markdown: a heading, one line of instruction, then a bullet per comment with the file, the line, the side of the diff and your note. A comment on a removed line and one on an added line come out like this:
## Code Review Comments
Please address the following:
- **app/routes/users.ts:31** (old side): The old guard returned early on an empty id. Keep it.
- **app/routes/users.test.ts:24** (new side): [must-fix] This test now expects a 500 for an empty id. It should still be a 400.Any agent that takes text can act on that. For what to look for before you write a single comment, read how to review AI-generated code. For Claude Code specifically, reviewing Claude Code’s changes covers the details.
What are the limits?
- It reads one checkout at a time. Two agents in two worktrees mean two tabs and two prompts.
- It only sees git. An agent that writes outside the repository, or into ignored files, won’t show up.
- It needs Node 20.11+ or Bun 1.0.23+ and runs on your machine only.
- It doesn’t review anything itself. The notes are yours.
What else do people ask about reviewing agent diffs?
Does DiffHub work with Codex, Cursor and Claude Code?
Yes. DiffHub reads git, not the agent, so it works with any tool that edits files in your repository.
Can DiffHub send the prompt to the agent for you?
No. DiffHub never talks to an agent. Copy & clear puts the prompt on your clipboard and you paste it wherever the agent is running.
Why does a comment in the prompt say old side?
The comment is on a removed line. Its line number points into the old version of the file, so it may not exist in the file on disk now. Ask the agent to read the diff before it edits.
Do comments survive closing the browser?
Yes. They’re saved in diffhub-comments.json in the repository’s git directory and stay there until you copy and clear them or delete them.
Can you review two agents at once?
Yes, if each works in its own checkout or worktree. Start DiffHub in each one. The second takes the next free port after 2047.
Should file-level comments name a side too?
L10 · new side