Skip to content
Source
Sign inSign up

Suggest changes

Issues and pull requests / Pull requests

Suggest a change in a review

You review a pull request and see a small fix, such as a typo or a wrong name. When you only describe the fix, the author must type it into the code by hand. A suggestion holds the exact new lines. The author commits it with one click, or collects many suggestions and commits them in one commit.

5 min read

  • Anyone who can comment on a line can write a suggestion.
  • To commit a suggestion, you need write access to the head branch. The author of the pull request has it, and so do people with write access to the repository. On a pull request from a fork, they have it only when the author allows edits from maintainers.

1. Write a suggestion

  1. On the Files changed tab, click the + at the start of the line that you want to change.

  2. In the comment, write a suggestion block with the full new text of the line:

    Use a name that says what the value is.
    
    ```suggestion
    const retryLimit = 3
    ```
  3. Click Add single comment, or click Start a review to send it with your review. See Review a pull request.

The comment shows the block as a small diff: the lines of the thread removed, your lines added. The block replaces the whole line. An empty block deletes the line.

To change more than one line:

  1. Click the line number of the first line.
  2. Hold Shift and click the + of the last line. The comment is on all the lines from the first to the last.
  3. Write one suggestion block with the new text of all those lines.

Keep to these rules, or nobody can commit the suggestion:

  • Put the comment on lines of the new version of the file, not on deleted lines.
  • Write one suggestion block in each comment. For two changes, write two comments.

2. Commit one suggestion

You are the author of the pull request, or you have write access to the head branch.

  1. Find the suggestion on the Conversation tab or the Files changed tab.
  2. Under it, click Commit suggestion.
  3. Optional: write a commit message. Without one, the message is "Apply suggestion from code review".
  4. Click Commit changes.

The commit goes on the head branch, and CI runs on it. The suggestions of the factory's review agent work the same way. See The pull request steps.

Note

On a pull request from GitHub, the commit goes to GitHub with your own GitHub token. Connect GitHub before you commit a suggestion there.

3. Commit many suggestions in one commit

A review often has many small suggestions. One commit for each makes a long history. Collect them in a batch, and commit them all at once.

  1. Under each suggestion that you want, click Add to batch. A bar at the bottom of the page counts them, for example "3 suggestions in your batch".
  2. In the bar, click Commit suggestions.
  3. Optional: write a commit message. Without one, the message is "Apply suggestions from code review".
  4. Click Commit changes.
  • To take a suggestion out, click Remove from batch under it. Clear in the bar empties the batch.
  • Your browser keeps the batch of each pull request, also after a reload.
  • One commit holds at most 100 suggestions.

4. From a terminal or an agent

An agent or a script commits suggestions with src, REST or MCP. The same rules apply. An agent commits only to a branch that its token can push to. On a pull request from GitHub, only a person can commit a suggestion.

  1. Find the id of the comment. Run src pr-comment list 7. The ID column is the id of the first comment of each thread. A comment link also ends in its id: #comment-31.

  2. Commit the suggestions of one or more comments:

    src pr suggestion apply 7 31
    src pr suggestion apply 7 31 32 35 -m "Apply the review suggestions"

    src prints the new commit.

To write a suggestion from a terminal, put the comment in a file, for example suggestion.md, then send it:

src pr-comment add 7 --path src/retry.ts --line 12 --body-file suggestion.md
src pr-comment add 7 --path src/retry.ts --start-line 12 --line 14 --body-file suggestion.md

Over REST, send the ids of the comments:

curl -X POST -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \
  -d '{"commentIds": [31, 32], "message": "Apply the review suggestions"}' \
  https://source.tanstack.com/api/v1/repos/<owner>/<repo>/pulls/7/suggestions/apply
  • 200 answers {"sha": "<the new commit>"}. message is optional.
  • 422 answers {"error": "<the reason>"} when the forge refuses a suggestion.
  • 403 means that you do not have write access to the head branch.

Over MCP, call the tool apply_suggestions with owner, repo, number and comment_ids, and an optional message.

When the forge refuses

The forge commits all the suggestions that you picked, or none. It tells you why:

  • The lines changed. A push changed the lines after the comment, so the suggestion is outdated. Write a new suggestion on the new lines.
  • The thread. The thread is resolved: reopen it first. Or the comment waits for a maintainer to review it.
  • The comment. It is on deleted lines, or it has more than one suggestion block.
  • The file. The head of the pull request does not have the file any more, or the file is not UTF-8 text.
  • The batch. Two suggestions change the same lines, or the batch has more than 100 suggestions.

Done

  • The suggestions are one commit on the head branch, and CI runs on it.
  • You are the author of the commit.
  • Each other person whose suggestion is in the commit gets a Co-authored-by: line in the commit message, so the commit credits them too.