Skip to main content

Pull Requests and Reviews

Module: Git Integration | Lesson: 3 of 4 | Time: ~10 minutes

What You Will Learn

  • How to create pull requests using the gh CLI through Claude
  • How to review pull requests with Claude's help
  • How to use /pr-comments to address feedback

Prerequisites

What Is a Pull Request?

In the previous lessons, you learned how to make commits and track your project's history with Git. But what happens when you want someone else to review your changes before they go into the main project? That is where pull requests come in.

A pull request (often shortened to PR) is a way of saying: "Hey, I made some changes on a separate branch. Can you review them before we add them to the main project?"

Think of it like submitting a draft essay to your teacher. You do not want the draft to replace the final version — you want feedback first. A pull request lets you:

  • Show exactly what you changed.
  • Get feedback and suggestions from others (or from Claude).
  • Make adjustments based on the feedback.
  • Merge the changes into the main branch only when they are ready.
Pull requests live on GitHub

Pull requests are a feature of GitHub (and similar platforms like GitLab and Bitbucket), not Git itself. Git handles the branching and merging; GitHub provides the pull request interface where people can review and discuss changes.


Prerequisites: The GitHub CLI (gh)

To create pull requests from Claude Code, you need the GitHub CLI — a command-line tool called gh that lets you interact with GitHub from your terminal.

Install the GitHub CLI

  1. Go to https://cli.github.com.
  2. Download and install the Windows version.
  3. After installation, open a new terminal and verify it works:
    gh --version

Authenticate with GitHub

You need to log in so gh can access your GitHub account:

gh auth login

Follow the prompts:

  • Choose GitHub.com.
  • Choose HTTPS as the preferred protocol.
  • Choose to authenticate via a web browser (the easiest method).
  • A code will appear in your terminal. Open the link in your browser, enter the code, and authorize access.
One-time setup

Like Git configuration, you only need to authenticate once per computer. After that, gh remembers your login.


The Pull Request Workflow

Here is the complete workflow for creating a pull request through Claude Code:

Step 1: Create a Branch

Before making changes, create a new branch. This keeps your changes separate from the main branch.

You: Create a new branch called add-contact-form

Claude will run git checkout -b add-contact-form, creating the branch and switching to it.

Step 2: Make Your Changes

Work on your feature as usual — ask Claude to create files, edit code, etc.

You: Create a contact form in contact.html with name, email, and message fields

Step 3: Commit Your Changes

Commit your work on the branch:

You: Commit these changes

Step 4: Push the Branch to GitHub

Your branch only exists on your computer so far. You need to push it to GitHub:

You: Push this branch to GitHub

Claude will run git push -u origin add-contact-form to upload the branch.

Step 5: Create the Pull Request

Now ask Claude to create a pull request:

You: Create a pull request for this branch

Claude will use the gh CLI to create a PR. It will:

  1. Analyze all the commits on your branch.
  2. Write a title and description summarizing the changes.
  3. Create the PR on GitHub.
  4. Give you a link to view it.

You can also provide specific instructions:

You: Create a pull request with the title "Add contact form page" and mention
that it includes form validation

Reviewing Pull Requests with Claude

Claude can help you review pull requests — both your own and other people's.

Review Your Own PR

You: Review my current pull request

Claude will look at the changes in your PR and provide feedback, just like the /review command.

Review Someone Else's PR

If you have a PR URL or number, you can ask Claude to review it:

You: Review pull request #15

Claude will fetch the PR details, examine the changes, and give you a summary with feedback.


Using /pr-comments to Address Feedback

After someone reviews your pull request and leaves comments, use the /pr-comments command to fetch and address that feedback efficiently:

/pr-comments

Claude will:

  1. Fetch all review comments from your open PR.
  2. Show you each comment along with the code it refers to.
  3. Help you make the requested changes one by one.
  4. Commit and push the fixes.

This saves you from switching back and forth between GitHub and your code editor.

Example workflow:

You: /pr-comments
Claude: I found 3 review comments on your PR:

1. reviewer said: "Add input validation for the email field"
On file: contact.html, line 15

2. reviewer said: "Missing error handling for the form submission"
On file: contact.js, line 8

3. reviewer said: "Add a placeholder text to the message field"
On file: contact.html, line 20

Would you like me to address these one at a time?

You: Yes, address all three

Claude: [Makes the changes, commits, and pushes]

Merging a Pull Request

Once your PR is approved and all feedback is addressed, you can merge it:

You: Merge my pull request

Claude will use gh pr merge to merge the PR. You may be asked which merge strategy to use:

  • Merge commit: Keeps all individual commits and adds a merge commit. Best for detailed history.
  • Squash and merge: Combines all commits into one. Best for clean history.
  • Rebase and merge: Replays commits on top of main. Best for linear history.

For beginners, squash and merge is usually the simplest option.

After merging, clean up by switching back to the main branch and deleting the feature branch:

You: Switch to the main branch and delete the add-contact-form branch

Try It Yourself

Requires a GitHub repository

This exercise requires a GitHub account and a repository on GitHub. If you do not have one yet, you can create a free account at github.com and create a new empty repository.

  1. Create a new GitHub repository (or use an existing one). Clone it to your computer:

    You: Clone the repository https://github.com/yourusername/your-repo
  2. Start Claude Code in the cloned folder.

  3. Create a branch:

    Create a new branch called add-readme
  4. Create a file:

    Create a README.md file that describes this project
  5. Commit and push:

    Commit this change and push the branch to GitHub
  6. Create a pull request:

    Create a pull request for this branch
  7. Review the PR — click the link Claude provides to see it on GitHub. Then ask:

    Review my pull request
  8. Merge the PR:

    Merge the pull request using squash and merge
  9. Clean up:

    Switch to main, pull the latest changes, and delete the add-readme branch

What You Learned

  • A pull request is a way to propose changes and get feedback before merging into the main branch.
  • The GitHub CLI (gh) lets Claude create and manage pull requests from the terminal.
  • The PR workflow is: branch, change, commit, push, create PR, review, merge.
  • /pr-comments fetches review feedback and helps you address it without leaving Claude Code.
  • After merging, clean up by switching to main and deleting the feature branch.

Help Us Improve

How was this lesson? Take 2 minutes to share your feedback — it helps us make the tutorials better for everyone.

Give Feedback →

Next Up

Next: Resolving Merge Conflicts