Skip to content
Source
Sign inSign up

Review a pull request

Issues and pull requests / Pull requests

Review a pull request

Someone asked you to review a pull request. You want to know why the change exists, comment on the lines that need work, and send your decision as one review.

11 min read

You need write access to approve or to request changes. Without it, you send a Comment review.

1. Find the pull requests that wait for you

Run:

src pr status

The pull requests that wait for your review are under Requesting a code review from you.

To see which open pull requests are easy to merge or change the most, see Find the pull requests to handle first.

2. Read why the pull request exists

A diff shows what changed, but not why. When the author's coding agent uploads its transcripts, read the Intent card before the diff.

  1. Open the pull request. The Intent card is at the top of the Conversation tab.
  2. Read the start of the intent summary, and the number of transcripts that you can read.
  3. If the summary is longer than the card, click Show more to read all of it. Click Show less to make it short again.
  4. To read the full summary and the transcripts, click Open the Intent tab.

In a terminal, run src transcripts intent 7.

Note

While the forge writes the summary, the card and the Intent tab show Writing the summary. with a spinner. The card shows only when there is a summary, or while the forge writes one. You see the card when you see the Intent tab: with write access, as the author, or as a reader when the repository lets readers read transcripts.

In the CLI, update your installed src before using the new summary format. Older binaries expected the diff and commit list in every PR read.

src pr view 7
src pr view 7 --json number,title,changedFiles,headRefOid
src pr view 7 --json files,additions,deletions,commits,headRefOid
src pr diff 7

The first two commands read stored summary facts. Unknown counts stay unknown. Fork and GitHub heads can lag. The third command requests file and commit details and reports the head that was actually compared. src pr diff 7 --name-only requests files; normal diff output requests the patch. --web does not request details.

The CLI stops with an error when requested details are unavailable. When details are truncated, it prints what it has and writes a warning to stderr. The diff marks each file that is too large with (diff too large to show). Details are truncated when a file changes in more than 2,000 lines (an added or a deleted file has no line limit) or is over 512 KB, or when the diff passes 20,000 lines or 8 MiB of files. To see a file that is too large, check out the pull request with src pr checkout 7 and run git diff locally. If the base or head changes between file and commit reads, run the command again. Review the returned files and commits before merging. Pass that detail response's headRefOid to src pr merge 7 --match-head-commit <reviewed-sha>. A clean stored merge status is not a new conflict check.

To see in one call whether the pull request is ready to merge, as gh gives it:

src pr view 7 --json reviewDecision,mergeStateStatus,statusCheckRollup
  • reviewDecision is APPROVED or CHANGES_REQUESTED, from the last approve or request-changes review of each reviewer, or "" when nobody decided. Source has no rule that requires a review, so it is never REVIEW_REQUIRED.
  • mergeStateStatus is CLEAN, UNSTABLE (a check that is not required failed or still runs), BLOCKED (the branch rules refuse the merge), BEHIND (a rule needs it up to date), DIRTY (conflicts), DRAFT or UNKNOWN. src ci checks 7 says why a merge is blocked.
  • statusCheckRollup lists the checks of the head commit.

Each of these fields is one more read, so ask only for the fields that you use.

3. Read the results of the workflows

Some CI workflows write their results on the pull request, for example a bundle size table or a test report. Each such workflow has a card on the Conversation tab, under the description.

  • The card shows the workflow, the state of its run, the commit and a View run link. Then it shows each section of results.
  • The card changes live while the jobs run.
  • From commit abc1234. The head is newer. means that the results are from an older commit.
  • From a fork, not trusted means that a run from a fork wrote the card. Read its links with care.
  • To fold the card, click the workflow name. Your browser remembers it.

A card can also have buttons. See Use the buttons of a workflow card.

4. Comment on lines

  1. Click the Files changed tab.
  2. Move the pointer over a line, then click the + at its start.
  3. Write the comment, then click Start a review.
  4. For each next comment, click Add review comment.

Only you see your pending comments until you submit the review. A review holds at most 100 comments.

Is the fix a few lines? Write it as a suggestion block in the comment, and the author commits it with one click. See Suggest a change in a review.

Does the pull request change many files? Mark each file that you read. See Track the files you read.

Tip

Does the pull request change the UI? Its Media tab shows all its screenshots and videos. See See every image and video of a pull request.

5. Submit the review

You send the review from the Files changed tab, so you do not go back to the Conversation tab.

  1. At the right end of the diff toolbar, click Review changes. If you have pending comments, the button shows how many.
  2. Optional: in Review summary, write a comment on the whole pull request.
  3. Under Your decision, pick Comment, Approve or Request changes.
  4. Click Submit review.
The Review changes panel on the Files changed tab, with the summary box, the three decisions and Submit review
  • The toolbar stays at the top of the window while you scroll. You can click Review changes from anywhere in the diff.
  • Approve and Request changes show only if you can review: you have write access, the pull request is open, and you are not its author. Other people send a Comment review.
  • A Comment review needs a summary or at least one pending comment.
  • While you have pending comments, the other tabs show a Pending review card above the tabs, with the same form.

In a terminal:

src review-draft add 7 --path src/app.ts --line 40 --body "This value can be null."
src pr review 7 --approve
src pr review 7 --request-changes --body "Handle the null value first."
src pr review 7 --comment --body "See the comments."

An agent's token can review only with --comment.

Caution

Discard review in the panel deletes all your pending comments, after you confirm. You cannot undo it.

Done

Submit review sends your summary, your decision and all your pending comments at once, as one review. Your review request ends. The page opens the Conversation tab, where you can merge, and where the review shows in the timeline as one line:

  • Approve: a check mark and "approved these changes".
  • Request changes: an X and "requested changes".
  • Comment: an eye and "reviewed".

If you wrote a summary, it shows in a card under that line. The line comments that you sent show under the summary.

An approval also shows in the merge box in the right column, as a green row under Ready to merge or Not ready to merge: "approved these changes" with your name. An approval does not unblock a merge. The merge box still waits for the checks, the conflicts and the branch rules.

The author answers and resolves your comments. See Answer and resolve review comments.

Track the files you read

A big pull request changes many files. You lose track of the files that you read, and you do not know how many are left. Mark each file as viewed, and the page counts them for you.

  1. On the Files changed tab, read a file. Then select Viewed in its header, or press V. The file folds.
  2. Look at the diff toolbar. It shows how many files you viewed and how many are left, with a progress bar. For example: "3 of 12 viewed, 9 left".
  3. Use the file tree in the sidebar to find the files that are left. A viewed file has a green check. A folder gets the same check when you viewed every file in it.
  4. To show only the files that are left, turn on Hide viewed in the sidebar.
  5. To mark many files at once, open the Mark as viewed menu in the sidebar. Pick a category, or mark all the files that match your filters. Unmark all removes every mark.

When you viewed every file, the toolbar shows "All 12 files viewed". The sidebar shows the same progress.

Note

Your browser keeps the marks. They do not go to the forge, so you do not see them in another browser, and other people do not see them. When a push changes a file, its mark goes away, so you read the new version.

When a renamed file shows as deleted and added

A big pull request moves files and edits them. On Files changed, you see the old path as deleted and the new path as added, where you expected one renamed file.

The forge pairs an edited file with its old path as git diff -M does: the new file must be at least 50% the same. It compares the text of the files only when the pull request deletes 300 files or fewer and adds 300 files or fewer, and when the text of those files is 4 MiB or less. In a larger pull request, only a file with the same content shows as renamed, as git does past its rename limit. The limit keeps one page load from making the repository slow for everyone else.

  1. Find the deleted file and the added file in the file tree of the sidebar. Read the two diffs side by side.
  2. To see which files git pairs as renamed, run git diff -M --stat <base>...<head> on your computer.

To copy the link of the whole pull request, click the copy button next to its title. Its label is Copy link to this pull request. It is on a phone too. An issue has the same button, Copy link to this issue.

You want a person to read one comment, and not search the page for it. Each saved comment has its own link.

  1. Find the comment. Its header shows who wrote it and when, for example "commented 3 hours ago".
  2. Click the copy button next to the time. Its label is Copy link to this comment.
  3. Paste the link where you want, for example in a chat or in another comment.

The time is a link too: click it, then copy the URL from your browser.

The link opens the Conversation tab and scrolls to the comment. This is also true when you copy it on the Files changed tab. If the comment is in an older round that is folded, the page opens that round first. A link to a reply opens the round of its thread, and opens the thread when it is resolved. Comments on issues have links too.

When the pull request changes while you read

The author can push while you read the diff. The Files changed tab does not change under you. It shows a bar: This pull request changed. The bar also shows for a new comment, review or label change.

  1. Finish the comment that you write.
  2. Click Show them.

The tab loads the new diff. Your scroll position and your draft comments stay. The other tabs load a push by themselves. See See changes without a reload.

Use the buttons of a workflow card

A workflow card can have buttons:

  • A button with a URL opens that page in a new tab. The host of the URL shows next to the label.
  • Any other button starts a workflow on this pull request. Click it, and the card shows the state of the new run and a link to it. You need write access, and the pull request must be open.

In a terminal:

src pr surface 7
src pr surface click 7 bundle-size write-blog-post

src pr surface prints each card, with the id of each button. src pr view 7 lists the workflows that have a card. To write a card from your own workflow, see Show results on a pull request.

Later: REST and MCP

An agent or a script does the same work over REST or MCP, with the same rules. The REST paths are under /api/v1/repos/{owner}/{repo}.

You want toRESTMCP tool
Add a line comment to your pending reviewPOST /pulls/{n}/review/draftsadd_review_draft
Submit a review, with your pending commentsPOST /pulls/{n}/reviews, with { "verdict", "body", "comments" }submit_pull_request_review
Commit the suggestions of line comments, in one commitPOST /pulls/{n}/suggestions/apply, with { "commentIds", "message" }apply_suggestions
Read the cards of the CI workflowsGET /pulls/{n}/surfacesget_pull_surfaces
Click a workflow button on a cardPOST /pulls/{n}/surfaces/{workflow}/buttons/{button}/clickclick_surface_button

For a review, verdict is commented, approved or changes_requested. Agents can only use commented.