Graphite Reviewer is now Diamond

How to turn comments into suggested fixes on GitHub

Greg Foster
Greg Foster
Graphite software engineer
Try Graphite

GitHub’s suggested changes feature lets reviewers transform inline comments into actionable code suggestions. By clicking a special button in a pull request’s diff view, you can generate a code block that outlines the proposed changes. Once the suggestion is made, maintainers (or reviewers with write access) can accept suggested edits with a single click. In modern development workflows, tools like Graphite have built on this capability by integrating AI code reviewer functions. This guide will show you how to change comments into actionable code suggestions on GitHub and explore how Graphite Reviewer's AI-suggested fixes can accelerate PR reviews.

Before you begin, ensure that you have:

  • A GitHub repository with an open pull request.
  • Write access to the repository (or a workflow where contributors can apply changes).
  • Familiarity with GitHub’s code review process.
  • (Optional) Graphite Reviewer enabled in your repository.
  1. Open the pull request in your repository.
  2. Navigate to the "Files changed" tab.
  3. Hover over the line of code you want to fix. A blue plus icon will appear.
  1. Click on the blue plus icon. The standard line comment form appears.
  2. Next to the comment text area, click on the button that looks like a plus/minus symbol to enter suggestion mode.

screenshot of Reviewer comment

  1. GitHub automatically wraps the current code in a suggestion block. The block is formatted like this:
    Terminal
    // original code here
  2. Modify the code inside the block to create your suggested fix.

Suppose the original code in the pull request is:

Terminal
function greet() {
var message = 'hello, world!'
console.log(message)
}

A reviewer might comment:

Instead of using var, you can use let for block scoping.

To suggest the fix, the code block becomes:

Terminal
function greet() {
let message = "hello, world!";
console.log(message);
}

Once a suggested change is added:

  1. The pull request author or a reviewer with write access sees a notification that there is a suggestion.
  2. They can accept suggested edits by clicking the “Commit suggestion” button next to the comment.
  3. Alternatively, if multiple suggestions are pending, you can "add to batch":
    • Click “Add suggestion to batch” for each change you want to include.
    • After reviewing all changes, click “Commit suggestions” to apply them all in a single commit.

Graphite enhances this workflow by:

  • Automatically generating code based on GitHub comment context. For instance, if a reviewer leaves a comment that says, “Replace var with let for proper scoping,” Graphite Reviewer can auto-generate the suggested code change.
  • Allowing users to review these AI-generated changes and accept suggested edits with one click.

In busy repositories, there may be several small fixes recommended in a single review. Here’s how to handle them:

  1. As you add each suggested change, choose the "add to batch" option.
  2. This queues all suggestions without immediately committing them.
  3. Once every change is queued, click on the “Commit suggestions” button.
  4. This creates a single commit that contains all the changes, making it easier to track and revert if needed.

GitHub’s suggested changes feature makes code reviews more efficient by transforming feedback into actionable commits. By combining manual suggestions with the power of an AI code reviewer like Graphite Reviewer’s AI suggested fixes, development teams can accelerate the review process and improve code quality. This guide has shown you how to:

  • Turn comments into suggested fixes.
  • Generate code based on GitHub comment suggestions.
  • Accept suggested edits.
  • Add to batch for bulk commits.

Built for the world's fastest engineering teams, now available for everyone