1
0
mirror of synced 2025-12-19 18:10:59 -05:00
Files
docs/content/copilot/how-tos/use-copilot-agents/coding-agent/create-a-pr.md
Felicity Chapman 2bd736cd06 [DO NOT MERGE] 🔥 Ignite 2025 megabranch (#58448)
Co-authored-by: Jenni C <97056108+dihydroJenoxide@users.noreply.github.com>
Co-authored-by: Anne-Marie <102995847+am-stead@users.noreply.github.com>
Co-authored-by: Steve Ward <steveward@github.com>
Co-authored-by: hubwriter <hubwriter@github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Tina Heidinger <tinaheidinger@github.com>
Co-authored-by: mc <42146119+mchammer01@users.noreply.github.com>
Co-authored-by: Melanie Yarbrough <11952755+myarb@users.noreply.github.com>
Co-authored-by: Nhu Do <nhu-do@github.com>
Co-authored-by: Sarita Iyer <66540150+saritai@users.noreply.github.com>
Co-authored-by: Vanessa <vgrl@github.com>
Co-authored-by: Siara <108543037+SiaraMist@users.noreply.github.com>
2025-11-18 17:20:04 +00:00

31 KiB

title, shortTitle, intro, product, versions, topics, redirect_from, contentType, category
title shortTitle intro product versions topics redirect_from contentType category
Asking GitHub Copilot to create a pull request Create a PR You can ask {% data variables.product.prodname_copilot_short %} to create a pull request from many places, including {% data variables.product.prodname_github_issues %}, the agents panel, {% data variables.copilot.copilot_chat_short %}, the {% data variables.product.prodname_cli %}, and agentic coding tools and IDEs with Model Context Protocol (MCP) support. {% data reusables.gated-features.copilot-coding-agent %}<br><a href="https://github.com/features/copilot/plans?ref_product=copilot&ref_type=purchase&ref_style=button&utm_source=docs-web-copilot-agents-create-pr&utm_medium=docs&utm_campaign=ghignite25" target="_blank" class="btn btn-primary mt-3 mr-3 no-underline"><span>Sign up for {% data variables.product.prodname_copilot_short %}</span> {% octicon "link-external" height:16 %}</a>
feature
copilot
Copilot
/copilot/using-github-copilot/using-copilot-coding-agent-to-work-on-tasks/asking-copilot-to-create-a-pull-request
/copilot/using-github-copilot/using-copilot-coding-agent-to-work-on-issues/asking-copilot-to-create-a-pull-request
/copilot/using-github-copilot/coding-agent/asking-copilot-to-create-a-pull-request
/copilot/how-tos/agents/copilot-coding-agent/asking-copilot-to-create-a-pull-request
/copilot/how-tos/agents/copilot-coding-agent/create-a-pr
/copilot/how-tos/agents/coding-agent/create-a-pr
/copilot/using-github-copilot/using-copilot-coding-agent-to-work-on-tasks/using-copilot-to-work-on-an-issue
/copilot/using-github-copilot/using-copilot-coding-agent-to-work-on-issues/using-copilot-to-work-on-an-issue
/early-access/copilot/coding-agent/using-copilot-coding-agent
/copilot/using-github-copilot/coding-agent/using-copilot-to-work-on-an-issue
/copilot/how-tos/agents/copilot-coding-agent/using-copilot-to-work-on-an-issue
/copilot/how-tos/agents/copilot-coding-agent/assign-copilot-to-an-issue
/copilot/how-tos/agents/coding-agent/assign-copilot-to-an-issue
/copilot/how-tos/use-copilot-agents/coding-agent/assign-copilot-to-an-issue
how-tos
Author and optimize with Copilot

Note

For an overview of {% data variables.copilot.copilot_coding_agent %}, see AUTOTITLE.

Introduction

You can ask {% data variables.product.prodname_copilot_short %} to create a new pull request from:

{% data variables.product.prodname_copilot_short %} will start working on the task, raise a pull request, then request a review from you when it's finished working. For more information, see AUTOTITLE.

Assigning an issue to {% data variables.product.prodname_copilot_short %}

You can ask {% data variables.product.prodname_copilot_short %} to start working on an issue by assigning the issue to {% data variables.product.prodname_copilot_short %}.

You can assign an issue to {% data variables.product.prodname_copilot_short %}:

Assigning an issue to {% data variables.product.prodname_copilot_short %} on {% data variables.product.prodname_dotcom_the_website %}

{% data reusables.repositories.navigate-to-repo %} {% data reusables.repositories.sidebar-issues %}

  1. Open the issue that you want to assign to {% data variables.product.prodname_copilot_short %}.

  2. In the right side menu, click Assignees.

    Screenshot of the right sidebar of an issue. A header, labeled "Assignees", is outlined in dark orange.

  3. Click Copilot from assignees list.

    Screenshot of "Assignees" window on an issue. Copilot is available in the list.

    Additional options are displayed.

    Screenshot of "Assign to Copilot" dialog showing options for target repository, starting branch, custom agent, and additional instructions.

  4. In the Optional prompt field you can add specific guidance for {% data variables.product.prodname_copilot_short %}. Add any context, constraints, or specific requirements that will help {% data variables.product.prodname_copilot_short %} to understand and complete the task.

    For example, you might include instructions about specific coding patterns or frameworks to use, testing requirements, code style preferences, files or directories that should or shouldn't be modified.

    In addition to the details you supply here, {% data variables.product.prodname_copilot_short %} will use any custom instructions that have been configured for the target repository. See AUTOTITLE.

  5. You can use the dropdown menus in the dialog to change the repository that {% data variables.product.prodname_copilot_short %} will work in and the branch that it will branch off from.

    All repositories where you have at least read access will be displayed in the repository dropdown menu. However, you can only select a repository if you have write access to it, and if {% data variables.copilot.copilot_coding_agent %} is enabled for that repository.

    If you select a repository in a different organization than the issue's source organization, or if you select a public repository when the issue is in a private repository, a warning will be displayed.

    If you don't specify a repository, {% data variables.product.prodname_copilot_short %} will work in the same repository as the issue. If you don't specify a branch, {% data variables.product.prodname_copilot_short %} will work from the default branch of the selected repository.

    Tip

    When you assign an issue to {% data variables.product.prodname_copilot_short %}, it gets sent the issue title, description, any comments that currently exist, and any additional instructions you provide. After assigning the issue, {% data variables.product.prodname_copilot_short %} will not be aware of, and therefore won't react to, any further comments that are added to the issue. If you have more information, or changes to the original requirement, add this as a comment in the pull request that {% data variables.product.prodname_copilot_short %} raises.

{% data reusables.copilot.optional-select-custom-agent %}

You can also assign issues to {% data variables.product.prodname_copilot_short %} from other places on {% data variables.product.prodname_dotcom_the_website %}:

  • From the list of issues on a repository's {% octicon "issue-opened" aria-hidden="true" aria-label="issue-opened" %} Issues page.
  • When viewing an issue in {% data variables.product.github %} {% data variables.projects.projects_v2_caps %}.

Assigning an issue to {% data variables.product.prodname_copilot_short %} on {% data variables.product.prodname_mobile %}

  1. In {% data variables.product.prodname_mobile %}, navigate to the repository that contains the issue you want to assign to {% data variables.product.prodname_copilot_short %}.
  2. Click Issues.
  3. Open the issue that you want to assign to {% data variables.product.prodname_copilot_short %}.
  4. Tap the {% octicon "info" aria-label="information" %} icon.
  5. Beside "Assignees", tap Edit.
  6. Beside "{% data variables.product.prodname_copilot_short %}", click the plus sign.
  7. Click Done.

Assigning an issue to {% data variables.product.prodname_copilot_short %} via the {% data variables.product.github %} API

You can assign issues to {% data variables.product.prodname_copilot_short %} using the GraphQL API.

Creating and assigning a new issue

  1. Make sure you're authenticating with the API using a user token, for example a {% data variables.product.pat_generic %} or a {% data variables.product.prodname_github_app %} user-to-server token.

    Note

    If using a {% data variables.product.pat_v2 %}, it needs the following permissions to assign {% data variables.product.prodname_copilot_short %} to an issue:

    • Read access to metadata
    • Read and write access to actions, contents, issues and pull requests

    If using a {% data variables.product.pat_v1 %}, it needs the repo scope to assign {% data variables.product.prodname_copilot_short %} to an issue.

  2. Verify that {% data variables.copilot.copilot_coding_agent %} is enabled in the repository by checking if the repository's suggestedActors in the GraphQL API includes {% data variables.product.prodname_copilot_short %}. Replace octo-org with the repository owner, and octo-repo with the repository name.

    query {
      repository(owner: "octo-org", name: "octo-repo") {
        suggestedActors(capabilities: [CAN_BE_ASSIGNED], first: 100) {
          nodes {
            login
            __typename
    
            ... on Bot {
              id
            }
    
            ... on User {
              id
            }
          }
        }
      }
    }
    

    If {% data variables.copilot.copilot_coding_agent %} is enabled for the user and in the repository, the first node returned from the query will have the login value copilot-swe-agent.

  3. Make a note of the id value of this login.

  4. Fetch the GraphQL global ID of the repository you want to create the issue in, replacing octo-org with the repository owner, and octo-repo with the repository name.

    query {
      repository(owner: "octo-org", name: "octo-repo") {
        id
      }
    }
    
  5. Create the issue with the createIssue mutation. Replace REPOSITORY_ID with the ID returned from the previous step, and BOT_ID with the ID returned from the step before that.

    mutation {
      createIssue(input: {repositoryId: "REPOSITORY_ID", title: "Implement comprehensive unit tests", body: "DETAILS", assigneeIds: ["BOT_ID"]}) {
        issue {
          id
          title
          assignees(first: 10) {
            nodes {
              login
            }
          }
        }
      }
    }
    

Assigning an existing issue

  1. Make sure you're authenticating with the API using a user token, for example a {% data variables.product.pat_generic %} or a {% data variables.product.prodname_github_app %} user-to-server token.

  2. Verify that {% data variables.copilot.copilot_coding_agent %} is enabled in the repository by checking if the repository's suggestedActors in the GraphQL API includes {% data variables.product.prodname_copilot_short %}. Replace octo-org with the repository owner, and octo-repo with the repository name.

    query {
      repository(owner: "monalisa", name: "octocat") {
        suggestedActors(capabilities: [CAN_BE_ASSIGNED], first: 100) {
          nodes {
            login
            __typename
    
            ... on Bot {
              id
            }
    
            ... on User {
              id
            }
          }
        }
      }
    }
    

    If {% data variables.copilot.copilot_coding_agent %} is enabled for the user and in the repository, the first node returned from the query will have the login value copilot-swe-agent.

  3. Fetch the GraphQL global ID of the issue you want to assign to {% data variables.product.prodname_copilot_short %}, replacing monalisa with the repository owner, octocat with the name and 9000 with the issue number.

    query {
      repository(owner: "monalisa", name: "octocat") {
        issue(number: 9000) {
          id
          title
        }
      }
    }
    
  4. Assign the existing issue to {% data variables.product.prodname_copilot_short %} using the replaceActorsForAssignable mutation. Replace ISSUE_ID with the ID returned from the previous step, and BOT_ID with the ID returned from the step before that.

    mutation {
      replaceActorsForAssignable(input: {assignableId: "ISSUE_ID", actorIds: ["BOT_ID"]}) {
        assignable {
          ... on Issue {
            id
            title
            assignees(first: 10) {
              nodes {
                login
              }
            }
          }
        }
      }
    }
    

Asking {% data variables.product.prodname_copilot_short %} to create a pull request from the agents tab or panel

You can ask {% data variables.product.prodname_copilot_short %} to open a pull request from either the agents tab or the agents panel. The only difference is the entry point - once you see the "New agent task" form, the steps are the same.

{% data reusables.copilot.open-agents-panel-or-page %} {% data reusables.copilot.coding-agent.new-agent-task-form-instructions %}

Asking {% data variables.product.prodname_copilot_short %} to create a pull request from the dashboard

You can ask {% data variables.product.prodname_copilot_short %} to open a pull request from the {% data variables.product.prodname_copilot_short %} prompt box in the dashboard. The dashboard is your personalized overview of your activity on {% data variables.product.github %}, seen when you visit https://github.com while logged in.

  1. Navigate to the dashboard at https://github.com.

  2. Click the {% octicon "agent" aria-label="The Agents icon" %} Task button.

  3. Using the dropdown menu in the prompt field, select the repository you want {% data variables.product.prodname_copilot_short %} to work in.

  4. Type a prompt describing your request.

    For example, Implement a user friendly message for common errors.

  5. Optionally, select a base branch for {% data variables.product.prodname_copilot_short %}'s pull request. {% data variables.product.prodname_copilot_short %} will create a new branch based on this branch, then push the changes to a pull request. {% data reusables.copilot.optional-select-custom-agent %}

  6. Click {% octicon "paper-airplane" aria-label="Send now" %} Send now or press Return.

    You will be taken to the agents tab, and {% data variables.product.prodname_copilot_short %} will start a new session, which will appear in the "Recent sessions" list below the prompt box. {% data variables.product.prodname_copilot_short %} will work on the task and push changes to its pull request, then add you as a reviewer when it has finished, triggering a notification.

    Note

    If you have enabled the New Dashboard Experience in feature preview, the new session will appear in "Agent sessions" under the prompt box in your dashboard. For more information, see AUTOTITLE.

Asking {% data variables.product.prodname_copilot_short %} to create a pull request from {% data variables.copilot.copilot_chat_short %} in {% data variables.product.prodname_vscode %}

  1. Install the {% data variables.product.github %} Pull Requests extension for {% data variables.product.prodname_vscode %}.

  2. Open {% data variables.copilot.copilot_chat %} in {% data variables.product.prodname_vscode %}.

  3. Type a prompt explaining what you want {% data variables.product.prodname_copilot_short %} to do.

    For example, Put backticks around file names and variables in output

    Tip

    To help {% data variables.product.prodname_copilot_short %}, you can select the relevant line(s) of code before submitting your prompt.

  4. Submit your prompt by clicking the Delegate this task to the GitHub Copilot coding agent button, next to the Send button

  5. If you have local changes, a dialog will be displayed asking if you want to push those changes so {% data variables.product.prodname_copilot_short %} can start from your current state. Click Include changes to push your changes, or Ignore changes to ask {% data variables.product.prodname_copilot_short %} to start its work from your repository's default branch.

    {% data variables.product.prodname_copilot_short %} will start a new session and respond with a link to the pull request it creates. It will work on the task and push changes to the pull request, and then add you as a reviewer when it has finished, triggering a notification.

Asking {% data variables.product.prodname_copilot_short %} to create a pull request from {% data variables.copilot.copilot_chat_short %} in JetBrains IDEs

Note

{% data variables.copilot.copilot_coding_agent %} in JetBrains IDEs is in {% data variables.release-phases.public_preview %}, and subject to change.

  1. Open {% data variables.copilot.copilot_chat %} in your JetBrains IDE.

  2. Type a prompt explaining what you want {% data variables.product.prodname_copilot_short %} to do

    For example, Put backticks around file names and variables in output

  3. Click the Delegate to Coding Agent button next to the Send button.

    {% data variables.product.prodname_copilot_short %} will start a new session and respond with a link to the pull request it creates. It will work on the task and push changes to the pull request, and then add you as a reviewer when it has finished, triggering a notification from {% data variables.product.github %} and in the IDE.

Asking {% data variables.product.prodname_copilot_short %} to create a pull request from {% data variables.copilot.copilot_chat_short %} in Eclipse

Note

{% data variables.copilot.copilot_coding_agent %} in Eclipse is in {% data variables.release-phases.public_preview %}, and subject to change.

  1. Open {% data variables.copilot.copilot_chat %} in Eclipse.

  2. Type a prompt explaining what you want {% data variables.product.prodname_copilot_short %} to do.

    For example, Put backticks around file names and variables in output

  3. Click {% octicon "agent" aria-label="The Agents icon" %} next to the Send button.

  4. In the dialog box that opens, select the repository you want {% data variables.product.prodname_copilot_short %} to work in, then click Continue.

    {% data variables.product.prodname_copilot_short %} will start a new session and respond with a link to the pull request it creates. It will work on the task and push changes to the pull request, and then add you as a reviewer when it has finished, triggering a notification from {% data variables.product.github %} and in the IDE.

Asking {% data variables.product.prodname_copilot_short %} to create a pull request from {% data variables.copilot.copilot_chat_short %} in {% data variables.product.prodname_vs %}

  1. Open {% data variables.copilot.copilot_chat %} in {% data variables.product.prodname_vs %}.

  2. Type a prompt, starting with @github, asking {% data variables.product.prodname_copilot_short %} to create a pull request, and giving details of what you want {% data variables.product.prodname_copilot_short %} to change.

    For example, @github Create a PR to put backticks around file names and variables in output.

    Tip

    • To help {% data variables.product.prodname_copilot_short %}, you can select the relevant line(s) of code before submitting your prompt.
    • From {% data variables.copilot.copilot_chat_short %}, you can ask {% data variables.product.prodname_copilot_short %} to open a pull request using a specific branch as the base branch by including it in your prompt.
  3. Submit your prompt.

    {% data variables.product.prodname_copilot_short %} asks you to confirm that you want to use the coding agent to create a pull request.

  4. Click Allow.

    {% data variables.product.prodname_copilot_short %} will start a new session and respond with a link to the pull request it creates. It will work on the task and push changes to the pull request, and then add you as a reviewer when it has finished, triggering a notification.

Asking {% data variables.product.prodname_copilot_short %} to create a pull request from {% data variables.copilot.copilot_chat_short %} in {% data variables.product.prodname_dotcom_the_website %}

  1. Open {% data variables.copilot.copilot_chat %} on {% data variables.product.prodname_dotcom_the_website %}.

  2. Type /task to ask {% data variables.product.prodname_copilot_short %} to create a pull request, and give details of what you want {% data variables.product.prodname_copilot_short %} to change.

    For example, /task Put backticks around file names and variables in output.

  3. Optionally, select a base branch for {% data variables.product.prodname_copilot_short %}'s pull request. {% data variables.product.prodname_copilot_short %} will create a new branch based on this branch, then push the changes to a pull request targeting that branch. {% data reusables.copilot.optional-select-custom-agent %}

  4. Click {% octicon "paper-airplane" aria-label="Start task" %} Start task or press Return.

    {% data variables.product.prodname_copilot_short %} will start a new session, which will appear in the list below the prompt box. {% data variables.product.prodname_copilot_short %} will work on the task and push changes to its pull request, then add you as a reviewer when it has finished, triggering a notification.

Asking {% data variables.product.prodname_copilot_short %} to create a pull request from {% data variables.product.prodname_mobile %}

  1. In {% data variables.product.prodname_mobile %}, navigate to the repository where you want to create a pull request.

  2. Tap the {% octicon "copilot" aria-hidden="true" aria-label="Copilot" %} icon in the bottom right corner of the screen.

  3. Enter a prompt to ask {% data variables.product.prodname_copilot_short %} to create a pull request.

    For example: Create a pull request to ....

    {% data variables.product.prodname_copilot_short %} responds with a brief summary of the task it will perform, asking for your confirmation before it proceeds.

  4. Check that {% data variables.product.prodname_copilot_short %} has interpreted your prompt correctly, then tap Accept or Dismiss.

    {% data variables.product.prodname_copilot_short %} creates a pull request and gives you a link to it. It will work on the task and push changes to the pull request, and then add you as a reviewer when it has finished, triggering a notification.

Asking {% data variables.product.prodname_copilot_short %} to create a pull request from the {% data variables.product.prodname_cli %}

Note

The agent-task command set is only available in v2.80.0 or later of the {% data variables.product.prodname_cli %}. This command set is a {% data variables.release-phases.public_preview %} and is subject to change.

You can start a new {% data variables.copilot.copilot_coding_agent %} session with the gh agent-task create command in the {% data variables.product.prodname_cli %}.

When you run the command without any arguments, you are asked to enter a prompt. {% data variables.copilot.copilot_coding_agent %} acts on the prompt and opens a pull request in the current repository.

You can use command line options to:

  • Provide the prompt (gh agent-task create "Example prompt")
  • Choose a base branch, instead of using the repository's default branch (--base)
  • Select a repository, instead of targeting the current repository (--repo)
  • Follow the session log in real time (--follow)

To see all of the available options, run gh agent-task create --help.

Asking {% data variables.product.prodname_copilot_short %} to create a pull request from the {% data variables.product.github %} MCP server

Note

  • This capability is only available on the remote {% data variables.product.github %} MCP server and host applications where remote MCP servers are supported.
  1. Install the {% data variables.product.github %} MCP server in your preferred IDE or agentic coding tool. See AUTOTITLE.

  2. Ensure the create_pull_request_with_copilot tool is enabled.

  3. Open chat.

  4. Type a prompt asking {% data variables.product.prodname_copilot_short %} to create a pull request, with the details of what you want to change.

    For example, Open a PR in my repository to expand unit test coverage.

    Tip

    • You can ask {% data variables.product.prodname_copilot_short %} to open a pull request using a specific branch as the base branch by including it in your prompt.
  5. Submit your prompt.

    {% data variables.product.prodname_copilot_short %} will start a new session, open a draft pull request and work on the task in the background. As it works, it will push changes to the pull request, and once it has finished, it will add you as a reviewer. In most cases, the MCP host will show you the URL of the created pull request.

Asking {% data variables.product.prodname_copilot_short %} to create a pull request from Raycast

{% data reusables.copilot.coding-agent.raycast-intro %}

{% data reusables.copilot.coding-agent.raycast-setup %}

  1. Open Raycast, search for "{% data variables.product.prodname_copilot_short %}," find the Create Task command, then press Enter.

  2. Click Sign in with {% data variables.product.github %}, then complete the authentication flow. Raycast will re-open.

  3. Type a prompt describing what you want {% data variables.product.prodname_copilot_short %} to do.

    For example, Implement a user friendly message for common errors.

  4. Select the repository you want {% data variables.product.prodname_copilot_short %} to work in.

  5. Optionally, select a base branch for {% data variables.product.prodname_copilot_short %}'s pull request. {% data variables.product.prodname_copilot_short %} will create a new branch based on this branch, then push the changes to a pull request targeting that branch.

  6. Press Command+Enter to start the task.

    {% data variables.product.prodname_copilot_short %} will start a new session. {% data variables.product.prodname_copilot_short %} will work on the task and push changes to its pull request, then add you as a reviewer when it has finished, triggering a notification.

Note

If you are unable to select a specific repository when starting a task, the organization that owns the repository may have enabled {% data variables.product.prodname_oauth_app %} access restrictions. To learn how to request approval for the "{% data variables.product.prodname_copilot %} for Raycast" {% data variables.product.prodname_oauth_app %}, see AUTOTITLE.

Asking {% data variables.product.prodname_copilot_short %} to create a pull request from the "New repository" page

When creating a new repository, you can ask {% data variables.product.prodname_copilot_short %} to seed the new repository by entering a prompt.

{% data reusables.repositories.create_new %} {% data reusables.repositories.owner-drop-down %}

  1. In the Prompt field, enter a prompt describing what you want {% data variables.product.prodname_copilot_short %} to build.

    For example, Create a Rust CLI for converting CSV spreadsheets to Markdown {% data reusables.repositories.create-repo %}

    {% data variables.product.prodname_copilot_short %} will immediately open a draft pull request. {% data variables.product.prodname_copilot_short %} will work on the task and push changes to its pull request, then add you as a reviewer when it has finished, triggering a notification.

{% data reusables.copilot.coding-agent.monitoring-progress-heading %}

Further reading