← Back

Reviewing Pull Requests as Uncommitted Changes

The hardest part of code review for me is seeing how the changes fit together. The GitHub UI shows a diff, file by file, and I lose the bigger picture.

I want to review a PR as if it were uncommitted changes in my own editor, so I can use the LSP to go to definitions, find references, and check types. I can also point a coding agent at the changes in read-only mode and ask questions about them.

Git makes this quite simple: check out the PR, then use git reset without --hard to reset to the merge base, leaving the code in place and the changes uncommitted.

I do this in a separate worktree so it doesn’t interfere with whatever I’m working on. Since I use Worktrunk to manage worktrees, I added a few aliases to its config:

1
2
3
4
5
6
7
8
9
# ~/.config/worktrunk/config.toml
# Each alias starts with a "# ..." line: completion shows that line as the description.
# Completion cuts the description at about 55 characters.
[aliases]
review = "# Open commit <sha> as uncommitted changes\nwt switch --create review-{{ args }} --base {{ args }} --no-cd --yes -x git -- reset --quiet HEAD~1"
review-pr = '''# Open PR <number> as uncommitted changes
wt switch --create review-pr-{{ args }} --base pr:{{ args }} --no-cd --yes -x sh -- -c 'base=$(gh pr view "$1" --json baseRefName -q .baseRefName 2>/dev/null) && git fetch --quiet origin "$base" && git reset --quiet "$(git merge-base FETCH_HEAD HEAD)"' sh {{ args }}'''
review-done = "# Remove the review worktree of commit <sha>\nwt remove --force --force-delete --yes review-{{ args }}"
review-pr-done = "# Remove the review worktree of PR <number>\nwt remove --force --force-delete --yes review-pr-{{ args }}"

The review-pr alias creates a worktree from the PR and resets it to the merge base, so I only see the PR’s changes, even if more commits have landed on the base branch since.

For a single commit, review resets to its parent (HEAD~1), while the -done aliases remove the worktree and its branch when I’m finished.

Now I can use:

1
2
3
4
5
wt review-pr 123       # open PR #123 as uncommitted changes
wt review-pr-done 123  # clean up

wt review <sha>        # open a single commit
wt review-done <sha>

I just open the worktree in my editor and review the changes with the same tools I use when writing the code.