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.
Bookmark
Bookmarks are kept in your free account, so you can find this page again on any device.
Sign in to bookmarkOn 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.
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 ciIn ChatGPT, create and publish a cloud environment for the repository. Codex inspects the repository and proposes setup steps, which you review before publishing. Network access is a setting of the environment: allow the package registries you need and nothing more, and use the environment’s secrets only for services the tests really need.
In Jules, select the repository under Codebases, open Configuration, and enter your install commands in Initial Setup. Click Run and Snapshot; when it succeeds, later tasks on that repository start from the snapshot. Each Jules VM runs Ubuntu with Node.js, Python, Go, Java and Rust already installed.
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.
Codex cloud starts from a task rather than an issue assignment. In ChatGPT, start a chat, choose Work in > Cloud, select your published environment and paste the brief from step 2 with a link to the issue. From the terminal, with Codex CLI signed in:
codex cloud exec --env [ENVIRONMENT ID] "$(cat brief.md)"
codex cloud listcodex cloud with no arguments opens a picker that lists your environments. When the task finishes, review the changed files and test results in the task, then open a pull request from it. To try the diff locally first, codex apply [TASK ID] applies it to your working tree.
With the Jules GitHub app authorised on the repository, add the label jules to the issue. Jules comments on the issue and, when it has finished, links the pull request there. You can also start the task at jules.google: choose the repository and branch, paste the brief and click Give me a plan.
Jules writes a plan before it changes any code. Read it and click Approve plan, or correct it in the chat box first; if you leave the page, the plan is approved automatically after a while.
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 --statApprove 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
TODOcomments 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.
Ask for the changes in the same cloud task, which keeps the context, and review the new diff and test results there before you push them to the pull request branch. For an independent pass before merging, comment @codex review on the pull request; Codex posts a review that flags only high-priority issues.
Send the changes in the task’s chat box; Jules replies and revises the plan or the code. Publish the updated branch and check the pull request again.
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.
Related coding agent guides
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%
Review
Related
- Triage GitHub issues automatically with an agent
Label new issues, post a short summary, flag likely duplicates and suggest an owner, with narrow permissions.
- Write a useful AGENTS.md: example, template and test
An AGENTS.md example and template with build and test commands, conventions and traps, plus a before-and-after task that shows whether the file actually helps.
- Code review with Claude Code on every pull request
Write your checklist once, dry-run it locally, then review every pull request in GitHub Actions and post the findings.
- Run coding agents headless in CI
Run claude -p and codex exec in GitHub Actions with pinned versions, narrow permissions, scoped secrets and separate jobs for writing back to the pull request.
- Reviewing AI-written code: what to look for
The ways agent-written diffs fail, a practical review checklist, and how to set up the work so review stays manageable.