Asking GitHub Copilot to create a pull request
You can ask Copilot to create a pull request from many places, including GitHub Issues, the agents panel, Copilot Chat, the GitHub CLI, and agentic coding tools and IDEs with Model Context Protocol (MCP) support.
Who can use this feature?
Copilot coding agent is available with the GitHub Copilot Pro, GitHub Copilot Pro+, GitHub Copilot Business and GitHub Copilot Enterprise plans. The agent is available in all repositories stored on GitHub, except repositories owned by managed user accounts and where it has been explicitly disabled.
Sign up for Copilot
In this article
- Introduction
- Assigning an issue to Copilot
- Asking Copilot to create a pull request from the agents panel or page
- Asking Copilot to create a pull request from Copilot Chat in Visual Studio Code
- Asking Copilot to create a pull request from Copilot Chat in other IDEs
- Asking Copilot to create a pull request from Copilot Chat in GitHub.com
- Asking Copilot to create a pull request from GitHub Mobile
- Asking Copilot to create a pull request from the GitHub CLI
- Asking Copilot to create a pull request from the GitHub MCP server
- Asking Copilot to create a pull request from Raycast
- Monitoring progress
- Further reading
Note
For an overview of Copilot coding agent, seeAbout GitHub Copilot coding agent.
Introduction
You can ask Copilot to work on a task from:
- GitHub Issues, byassigning an issue to Copilot
- Theagents panel or page on GitHub
- Copilot Chat inVisual Studio Code andother IDEs
- Copilot Chat onGitHub.com
- TheGitHub CLI
- Your preferred IDE or agentic coding tool withModel Context Protocol (MCP) support
- TheRaycast launcher on macOS
Copilot will start working on the task, raise a pull request, then request a review from you when it's finished working. For more information, seeAbout GitHub Copilot coding agent.
Assigning an issue to Copilot
You can ask Copilot to start working on an issue by assigning the issue to Copilot.
You can assign an issue to Copilot:
- On GitHub.com (see thenext section)
- OnGitHub Mobile
- Via the GitHub API (seelater in this article)
- Using GitHub CLI (see
gh issue edit
)
Assigning an issue to Copilot on GitHub.com
On GitHub, navigate to the main page of the repository.
Under your repository name, click Issues.
Open the issue that you want to assign to Copilot.
In the right side menu, clickAssignees.
ClickCopilot from assignees list.
Additional options are displayed.
In theOptional prompt field you can add specific guidance for Copilot. Add any context, constraints, or specific requirements that will help Copilot 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, Copilot will use any custom instructions that have been configured for the target repository. SeeAdding repository custom instructions for GitHub Copilot.
You can use the dropdown menus in the dialog to change the repository that Copilot will work in and the branch that it will branch off from.
Note
If you don't specify a repository, Copilot will work in the same repository as the issue. If you don't specify a branch, Copilot will work from the default branch of the selected repository.
Tip
When you assign an issue to Copilot, it gets sent the issue title, description, any comments that currently exist, and any additional instructions you provide. After assigning the issue, Copilot 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 Copilot raises.
You can also assign issues to Copilot from other places on GitHub.com:
- From the list of issues on a repository's Issues page.
- When viewing an issue in GitHub Projects.
Assigning an issue to Copilot on GitHub Mobile
- In GitHub Mobile, navigate to the repository that contains the issue you want to assign to Copilot.
- ClickIssues.
- Open the issue that you want to assign to Copilot.
- Tap the icon.
- Beside "Assignees", tapEdit.
- Beside "Copilot", click the plus sign.
- ClickDone.
Assigning an issue to Copilot via the GitHub API
You can assign issues to Copilot using the GraphQL API.
Creating and assigning a new issue
Make sure you're authenticating with the API using a user token, for example a personal access token or a GitHub App user-to-server token.
Verify that Copilot coding agent is enabled in the repository by checking if the repository's
suggestedActors
in the GraphQL API includes Copilot. Replaceocto-org
with the repository owner, andocto-repo
with the repository name.GraphQL query { repository(owner: "octo-org", name: "octo-repo") { suggestedActors(capabilities: [CAN_BE_ASSIGNED], first: 100) { nodes { login __typename ... on Bot { id } ... on User { id } } } }}
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 Copilot coding agent is enabled for the user and in the repository, the first node returned from the query will have the
login
valuecopilot-swe-agent
.Make a note of the
id
value of this login.Fetch the GraphQL global ID of the repository you want to create the issue in, replacing
octo-org
with the repository owner, andocto-repo
with the repository name.GraphQL query { repository(owner: "octo-org", name: "octo-repo") { id }}
query{ repository(owner:"octo-org",name:"octo-repo"){ id}}
Create the issue with the
createIssue
mutation. ReplaceREPOSITORY_ID
with the ID returned from the previous step, andBOT_ID
with the ID returned from the step before that.GraphQL mutation { createIssue(input: {repositoryId: "REPOSITORY_ID", title: "Implement comprehensive unit tests", body: "DETAILS", assigneeIds: ["BOT_ID"]}) { issue { id title assignees(first: 10) { nodes { login } } } }}
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
Make sure you're authenticating with the API using a user token, for example a personal access token or a GitHub App user-to-server token.
Verify that Copilot coding agent is enabled in the repository by checking if the repository's
suggestedActors
in the GraphQL API includes Copilot. Replaceocto-org
with the repository owner, andocto-repo
with the repository name.GraphQL query { repository(owner: "monalisa", name: "octocat") { suggestedActors(capabilities: [CAN_BE_ASSIGNED], first: 100) { nodes { login __typename ... on Bot { id } ... on User { id } } } }}
query{ repository(owner:"monalisa",name:"octocat"){ suggestedActors(capabilities:[CAN_BE_ASSIGNED],first:100){ nodes{ login __typename...on Bot{ id}...on User{ id}}}}}
If Copilot coding agent is enabled for the user and in the repository, the first node returned from the query will have the
login
valuecopilot-swe-agent
.Fetch the GraphQL global ID of the issue you want to assign to Copilot, replacing
monalisa
with the repository owner,octocat
with the name and9000
with the issue number.GraphQL query { repository(owner: "monalisa", name: "octocat") { issue(number: 9000) { id title } }}
query{ repository(owner:"monalisa",name:"octocat"){ issue(number:9000){ id title}}}
Assign the existing issue to Copilot using the
replaceActorsForAssignable
mutation. ReplaceISSUE_ID
with the ID returned from the previous step, andBOT_ID
with the ID returned from the step before that.GraphQL mutation { replaceActorsForAssignable(input: {assignableId: "ISSUE_ID", actorIds: ["BOT_ID"]}) { assignable { ... on Issue { id title assignees(first: 10) { nodes { login } } } } }}
mutation{ replaceActorsForAssignable(input:{assignableId:"ISSUE_ID",actorIds:["BOT_ID"]}){ assignable{...on Issue{ id title assignees(first:10){ nodes{ login}}}}}}
Asking Copilot to create a pull request from the agents panel or page
You can ask Copilot to open a pull request from either the agents panel or the agents page. The only difference is the entry point - once you see the "New agent task" form, the steps are the same.
Open the agents panel or page:
- Open the agents panel: Click in the navigation bar at the top right of GitHub.
- Navigate to the agents page: Go togithub.com/copilot/agents. You can also get here by opening the agents panel, then clickingView all.
Using the dropdown menu in the prompt field, select the repository you want Copilot to work in.
Type a prompt describing your request.
For example,
Implement a user friendly message for common errors.
Optionally, select a base branch for Copilot's pull request. Copilot will create a new branch based on this branch, then push the changes to a pull request targeting that branch.
Click Start task or pressReturn.
Copilot will start a new session, which will appear in the list below the prompt box. Copilot 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 Copilot to create a pull request from Copilot Chat in Visual Studio Code
Install theGitHub Pull Requests extension for Visual Studio Code.
Open GitHub Copilot Chat in Visual Studio Code.
Type a prompt explaining what you want Copilot to do, and add
#copilotCodingAgent
to the prompt.For example,
Put backticks around file names and variables in output #copilotCodingAgent
Tip
- To help Copilot, you can select the relevant line(s) of code before submitting your prompt.
Submit your prompt.
Copilot will typically do some research and context-gathering in Visual Studio Code, and then will ask you to confirm that you want to use the coding agent to create a pull request.
ClickContinue.
Copilot will push up any local changes, 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 Copilot to create a pull request from Copilot Chat in other IDEs
Open GitHub Copilot Chat in Visual Studio or JetBrains IDEs.
Type a prompt, starting with
@github
, asking Copilot to create a pull request, and giving details of what you want Copilot to change.For example,
@github Create a PR to put backticks around file names and variables in output.
Tip
- To help Copilot, you can select the relevant line(s) of code before submitting your prompt.
- From Copilot Chat, you can ask Copilot to open a pull request using a specific branch as the base branch by including it in your prompt.
Submit your prompt.
Copilot asks you to confirm that you want to use the coding agent to create a pull request.
ClickAllow.
Copilot 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 Copilot to create a pull request from Copilot Chat in GitHub.com
Open GitHub Copilot Chat on GitHub.com.
Type a prompt asking Copilot to create a pull request, and giving details of what you want Copilot to change.
For example,
Create a PR in monalisa/bookstore to put backticks around file names and variables in output.
Tip
- You can ask Copilot to open a pull request using a specific branch as the base branch by including it in your prompt.
Submit your prompt.
Copilot asks you to confirm that you want to use the coding agent to create a pull request.
ClickAllow.
Copilot 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 Copilot to create a pull request from GitHub Mobile
In GitHub Mobile, navigate to the repository where you want to create a pull request.
Tap the icon in the bottom right corner of the screen.
Enter a prompt to ask Copilot to create a pull request.
For example:
Create a pull request to ...
.Copilot responds with a brief summary of the task it will perform, asking for your confirmation before it proceeds.
Check that Copilot has interpreted your prompt correctly, then tapAccept orDismiss.
Copilot 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 Copilot to create a pull request from the GitHub CLI
Note
Theagent-task
command set is only available in v2.80.0 or later of the GitHub CLI. This command set is a public preview and is subject to change.
You can start a new Copilot coding agent session with thegh agent-task create
command in the GitHub CLI.
When you run the command without any arguments, you are asked to enter a prompt. 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, rungh agent-task create --help
.
Asking Copilot to create a pull request from the GitHub MCP server
Note
- This capability is only available on the remote GitHub MCP server and host applications where remote MCP servers are supported.
Install the GitHub MCP server in your preferred IDE or agentic coding tool. SeeUsing the GitHub MCP Server.
Ensure the
create_pull_request_with_copilot
tool is enabled.Open chat.
Type a prompt asking Copilot 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 Copilot to open a pull request using a specific branch as the base branch by including it in your prompt.
Submit your prompt.
Copilot 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 Copilot to create a pull request from Raycast
Raycast is an extensible launcher for macOS. With the GitHub Copilot extension for Raycast, you can start and track Copilot coding agent tasks wherever you are on your computer.
Install Raycast from theRaycast website.
Install the GitHub Copilot extension for Raycast by clicking theInstall Extension button on theextension's page.
Open Raycast, search for "Copilot," find theCreate Task command, then pressEnter.
ClickSign in with GitHub, then complete the authentication flow. Raycast will re-open.
Type a prompt describing what you want Copilot to do.
For example,
Implement a user friendly message for common errors.
Select the repository you want Copilot to work in.
Optionally, select a base branch for Copilot's pull request. Copilot will create a new branch based on this branch, then push the changes to a pull request targeting that branch.
PressCommand+Enter to start the task.
Copilot will start a new session. Copilot 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 OAuth app access restrictions. To learn how to request approval for the "GitHub Copilot for Raycast" OAuth app, seeRequesting organization approval for OAuth apps.
Monitoring progress
You can view your current and past Copilot sessions from the agents panel,agents page and Visual Studio Code. SeeTracking GitHub Copilot's sessions.