Read Anthropic’s case study about Graphite Reviewer

How to use GitHub Codespaces for reviewing pull requests

Sara Verdi
Sara Verdi
Graphite software engineer
Try Graphite

GitHub Codespaces provides a cloud-powered development environment accessible through a web browser or Visual Studio Code. This makes it ideal for reviewing pull requests (PRs) as it allows you to quickly spin up a fully-configured workspace tailored to the repository under review. You can leverage GitHub Codespaces for pull request review to ensure consistency across environments and streamline collaboration, especially when dealing with complex codebases or dependencies. In this guide, we’ll walk through a practical example of using GitHub Codespaces to review pull requests, explore the Codespaces code review workflow, and demonstrate how to integrate tools like the Graphite VS Code extension to optimize your review process.

  • Access to GitHub Codespaces (ensure it’s enabled for your repository or organization).
  • A GitHub repository with open pull requests.
  • Visual Studio Code installed on your local machine, or access to the browser-based editor.
  • (Optional) Install the Graphite VS Code extension for enhanced PR review functionality.
  1. Navigate to the Pull Requests tab in your GitHub repository.
  2. Select the pull request you want to review.
  3. Click on the Codespaces dropdown in the PR view and select New Codespace on Main (or the branch associated with the PR).

screenshot of opening a codespace

  1. GitHub will launch a pre-configured Codespace environment with the branch already checked out.

Once the Codespace is launched:

  • The editor will open with the branch tied to the pull request loaded.
  • All dependencies (defined in your repository’s configuration files, such as Dockerfile or .devcontainer.json) will be automatically installed.
  • The Source Control tab will show all changes in the PR, allowing you to navigate through commits, diffs, and inline comments.
  1. Use the Source Control tab or file explorer to open a changed file.
  2. Select a line of code and click the plus icon to leave an inline comment.
  3. Optionally, use Markdown formatting for clear feedback. For example:
    Terminal
    **Suggestion:** Refactor this function to reduce cyclomatic complexity.

Codespaces provides a full development environment, making it easy to:

  • Run tests: Use the integrated terminal to execute npm test, pytest, or equivalent commands.
  • Build the application: Ensure the PR doesn’t break the build using commands like make or yarn build.
  • Debug changes: Leverage the built-in debugger to step through the code.

The Graphite VS Code extension enhances the PR review experience in Codespaces by providing additional features like visual stack management and simplified Git workflows.

  • Stack visualization: View and manage stacked pull requests directly within your editor, ideal for complex repositories.
  • Git simplification: Perform Git operations like rebasing, committing, and branching from an intuitive UI.
  • Seamless integration: Control Graphite workflows using the command palette or UI widgets, reducing context switching.
  1. Open the Extensions tab in your Codespace.
  2. Search for "Graphite" and install the Graphite VS Code extension.
  3. Authenticate with your Graphite account using the provided login flow.
  4. Access features like stack visualization and Git commands from the Graphite sidebar.

By combining the power of GitHub Codespaces and the Graphite extension, you can achieve a streamlined and efficient code review process.

Codespaces provides built-in support for resolving merge conflicts:

  1. Open the conflicted file in the editor.
  2. Use the inline conflict markers (<<<<, ====, >>>>) to select and merge changes.
  3. Save the file and commit the resolution using the Source Control tab.

While reviewing, you can trigger CI/CD workflows to validate the pull request:

  • Use the terminal to run GitHub Actions locally via the act CLI.
  • Alternatively, navigate to the PR in GitHub and view the workflow status under the Checks tab.
  • Use the built-in Live Share feature in VS Code to review PRs collaboratively in real-time.
  • Share feedback directly in GitHub or through Codespaces’ commenting tools.

GitHub Codespaces simplifies the code review workflow by providing a consistent, pre-configured environment. When paired with tools like the Graphite VS Code extension, it offers unparalleled efficiency and clarity in reviewing pull requests, especially for complex or stacked changes. Whether you’re debugging, testing, or discussing changes with teammates, Codespaces is a powerful tool for developers.

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