Skip to content
AI Skills Central

Type to search Agent Skills, workflows, tutorials, tools and the glossary.

Workflow recipe

Hand a GitHub issue to a background coding agent and review the PR

Write a brief it can finish, set up its environment, hand it to Copilot, Codex or Jules, then review and iterate once.

By Intermediate1 h 30 min6 steps
Bookmark

Bookmarks are kept in your free account, so you can find this page again on any device.

Sign in to bookmark
On this page

To assign a GitHub issue to an AI agent and get a pull request you can merge, pick an issue small enough to finish without questions, rewrite it as a brief with acceptance criteria, files and a test command, and make sure the agent’s environment can install and test your project. Then assign it to Copilot, start a Codex cloud task or label it for Jules, review the pull request against the brief as if a stranger wrote it, and send one batch of review comments before you merge or close.

Background agents work on their own branch while you do something else, which is the attraction and the risk. Nobody is watching when the agent misreads a vague issue, so you get a confident pull request that solves a slightly different problem, with tests written to match its own reading. Almost every bad result traces back to the issue: no acceptance criteria, no hint which files matter, or a task that needed a decision only a person could make. The brief in step 2 and the review in step 5 are the two places to spend your time.

GitHubAbout 10 min

1. Pick an issue an agent can finish

Choose from your backlog with these tests. An agent can finish the issue if:

  • the expected behaviour is already decided, and a tester could tell when it is done;
  • the change touches one area of the code, ideally one to three files;
  • the repository’s tests can run without secrets or production services;
  • it does not involve security, authentication, personal data or a migration you cannot roll back.

GitHub’s own guidance says the same: give the agent clear, well-scoped tasks first, and keep security-sensitive or poorly defined work for yourself. Good first issues are a bug with a reproduction, a missing validation, a small refactor with tests already around it, or an update across files that follows an obvious pattern. Skip anything labelled “needs discussion”.

GitHub and your AI assistantAbout 15 min

2. Rewrite the issue as a brief the agent can finish

The agent reads the issue title and body, and its comments, as its instructions. Rewrite the body with this prompt in any assistant, then paste the result back into the issue. Check the files and the test command yourself; the assistant can only guess them.

Turn an issue into an agent brief · Claude, ChatGPT or Gemini
Rewrite this GitHub issue as a brief for a coding agent that will work alone and cannot ask me questions until it opens a pull request. Issue: [PASTE THE ISSUE TITLE AND BODY] Files I believe are involved: [FILES OR "UNKNOWN"] Command that runs the tests: [TEST COMMAND] Use these sections: 1. Problem: what happens now and what should happen, with a reproduction if there is one. 2. Acceptance criteria: a numbered list of checks a reviewer can verify, including the tests that must be added or changed. 3. Where to look: the files and functions involved. 4. Out of scope: what the agent must not change (public APIs, dependencies, unrelated files, formatting). 5. How to verify: the exact commands to run before opening the pull request. 6. Stop and ask: the situations in which it should open a draft pull request with a question instead of guessing. Rules: keep it under 300 words. Do not invent files, functions or commands; if you are unsure, write "check" and leave it for me.

A brief that names the test to add (“add a test that parseDate('31/02/2026') raises ValueError”) is worth more than any amount of description. If you cannot write the acceptance criteria, the issue is not ready for an agent; it needs a person to decide first.

Repository settings and filesAbout 20 min

3. Make sure the agent can install, build and test

A background agent that cannot run your tests will still open a pull request; it will just say it could not verify it. Give it three things.

Instructions. All three agents read AGENTS.md at the repository root. Copilot also reads .github/copilot-instructions.md. Put the build and test commands, the code style rules and the “never touch” list there; write a useful AGENTS.md shows what belongs in it.

An environment. Each service sets up its sandbox differently:

When Copilot runs on GitHub Actions, add a workflow at .github/workflows/copilot-setup-steps.yml with a single job that must be named copilot-setup-steps. Its steps run before the agent starts, so install your dependencies there. It only takes effect once it is on the default branch, and you can run it by hand from the Actions tab to check it works.

name: "Copilot Setup Steps"
on: workflow_dispatch
jobs:
  copilot-setup-steps:
    runs-on: ubuntu-latest
    permissions:
      contents: read
    steps:
      - uses: actions/checkout@v7
      - uses: actions/setup-node@v7
        with:
          node-version: 22
      - run: npm ci

Protections. Check that the default branch requires a pull request review and passing checks. Copilot’s pull requests are drafts, it cannot approve or merge them, and by default GitHub Actions workflows do not run on them until someone with write access clicks Approve and run workflows. The person who assigned the issue cannot approve the resulting pull request, so a second reviewer is built in.

GitHub, ChatGPT or JulesAbout 5 min

4. Hand the issue to the agent

Open the issue, click Assignees in the sidebar and choose Copilot. The dialog lets you add an optional prompt (for example “keep the change to src/dates.ts and its tests”), and pick the repository, base branch, custom agent and model. From the terminal:

gh issue edit 123 --add-assignee "@copilot"

Copilot works on a new branch whose name starts with copilot/, opens a pull request and requests your review when it finishes. You can follow its session log from the pull request.

Then leave it. Checking the session every few minutes defeats the point of a background agent.

GitHub and your terminalAbout 25 min

5. Review the pull request against the brief, not against the description

Read the agent’s pull request description last. Start from the brief’s acceptance criteria and check each one in the diff and the test run.

gh pr checkout 456
[TEST COMMAND]
git diff main --stat

Approve the workflow run first if the checks have not started. Then work through these red flags, each of which needs a reason in the pull request before you go on:

  • files changed that the brief did not mention, or a lockfile or dependency change you did not ask for;
  • a test deleted, skipped or with a weaker assertion, or new tests that only check what the new code returns;
  • configuration or CI files edited, especially anything under .github/;
  • broad catch blocks, disabled lint rules or new TODO comments in place of handling;
  • a description that claims more than the diff shows (“also improved performance”).

Break the fix on purpose once: revert the one line that matters and run the new test. If the test still passes, it does not test the change. How to review AI-written code has the longer checklist.

GitHubAbout 15 min

6. Send one batch of comments, then merge or close

Write all your comments in one review instead of one at a time, so the agent works on them together.

Use Start a review rather than Add single comment, and mention @copilot in the comments you want it to act on. It adds an eyes reaction to your comment when it starts, pushes commits to the same branch and keeps the context of the earlier session. Only comments from people with write access reach it. When you are happy, mark the draft ready for review and ask a second person to approve.

If a second round does not get the pull request to your acceptance criteria, close it with a comment saying what was missing, fix the brief, and either reassign or do the work yourself. Long back-and-forth with an agent costs more than writing the change. Record what made the issue hard in your instructions file so the next brief is better.

Check it worked

Verification checklist

0 of 7 done

When it goes wrong

If the pull request says the agent could not run the tests, the environment is the problem, not the code. For Copilot, check the setup workflow ran from the default branch and that the job is named exactly copilot-setup-steps; for Codex, re-run the environment’s setup check; for Jules, use Run and Snapshot again. Then reassign.

If the pull request solves a different problem from the one you meant, the issue was ambiguous. Do not argue it round in comments. Close it, add the missing acceptance criterion or example to the issue, and assign again.

If the agent asks you a question in a draft pull request, that is the “stop and ask” rule working. Answer in a comment that mentions the agent (Copilot) or in the task chat (Codex, Jules), and add the answer to the issue so the record is in one place.

If Copilot does not appear in the Assignees list, you need a paid Copilot plan and the cloud agent enabled for that repository. The features page of your Copilot settings shows whether it is enabled for you; for organisation repositories, the organisation or enterprise administrators control it.

Variations

To find issues worth delegating automatically, triage GitHub issues with AI can label the small, well-defined ones as candidates. For changes you want to run in your own CI rather than a vendor’s sandbox, the headless coding agents in CI tutorial runs Claude Code or Codex in GitHub Actions with your own permissions.

For bigger features, write a spec first with the spec-driven feature build recipe and split it into issues an agent can finish one at a time. For a job that recurs on a timetable, such as a nightly dependency check, schedule a recurring task for a coding agent instead of assigning it by hand each time. For a review pass on human pull requests, see code review with Claude Code.

The coding agents for teams path covers permissions, review and shared instructions for teams that delegate work to agents. Before giving any agent repository access, read coding agent permissions and sandboxing.

Outcome and tools

Outcome
A small GitHub issue finished by a background agent as a pull request you reviewed against written acceptance criteria, then merged or closed with a reason.
For
Developers, Team leads
Variants for
GitHub Copilot, Codex, Other agents

Check your understanding

Delegate an issue to a background agent quiz

Choosing an issue an agent can finish, rewriting it as a brief, setting up the agent's environment, handing it over, reviewing against the brief and sending one batch of comments.

7 questions · pass mark 70%

Question 1 of 70 answered
  1. Which issue is the best first task for a background agent?
Back to top