Guide
A Pull Request Template for AI-Generated Code
Your coding agent can turn one prompt into 40 changed files in about three minutes. Reviewing those changes takes much longer. It also takes more care, because AI-written code usually looks right. It compiles, the names are sensible and the comments are confident. The bugs sit in the parts nobody asked for: a check that got loosened, a test that was "fixed" by deleting the assertion, a new dependency you have never heard of.
A normal pull request template asks "What does this PR do?". That question is not enough for AI-generated code. The author (the agent) will always give you a fluent answer. What you need is a template that makes the scope, the risk and the evidence visible, so a human can decide in a few minutes whether to merge, ask for a revision or throw the branch away.
Below is the template I use. You can copy it as it is, followed by an explanation of each section and three ways to make sure it actually gets used.
The template
Save this as .github/pull_request_template.md in your repository. GitHub picks it up automatically for every new pull request on the default branch.
<!-- .github/pull_request_template.md -->
## What was asked
<!-- Paste the original prompt / issue / task in 1–3 lines. Not the agent's summary. -->
## What changed
<!-- Agent: list every file you touched and why, one line each. -->
| File | Change | Why it was needed |
|------|--------|-------------------|
| | | |
## Out of scope changes
<!-- Anything changed that was NOT required by "What was asked". Write "none" if none. -->
-
## Risk flags (tick all that apply)
- [ ] Auth, permissions or access checks
- [ ] Database schema, migrations or data deletion
- [ ] Payments, billing or anything with money
- [ ] Secrets, env vars, config or CI/CD files
- [ ] New or upgraded dependencies
- [ ] Deleted or weakened tests
- [ ] None of the above
## Evidence
- Tests run (command + result):
- Manual check (what I clicked / called and what happened):
- Screenshot or log (if UI or API changed):
## Rollback
<!-- How do we undo this if it breaks production? "Revert this PR" is fine if true. -->
## AI involvement
- Tool / model: <!-- e.g. Claude Code, Cursor, Codex -->
- Agent ran commands outside the repo: yes / no
- Human has read every changed line: yes / partially / no
## Reviewer sign-off
- [ ] I can explain what this change does without reading the agent's summary
- [ ] Every "Out of scope" item is either reverted or justified
- [ ] Risk flags were checked line by line, not skimmed
That's the whole thing. It fits on one screen, which matters. Long templates get ignored, by people and by agents.
Why each section exists
"What was asked" (the original task, not the summary)
Agents rewrite your request in their own words, and their summary often describes what they did rather than what you wanted. Pasting the original prompt gives the reviewer a fixed yardstick. Every changed line either serves that request or it doesn't.
"What changed" as a table
A per-file table forces the agent to account for each file. If the task was "add a newsletter signup form" and the table lists .github/workflows/deploy.yml, you've found your first question before reading a single line of code. You can cross-check the table against the real diff in seconds:
git fetch origin
git diff --stat origin/main...HEAD
git diff --name-status origin/main...HEAD
The three-dot form compares your branch with the point where it left main, so you only see what this branch changed.
"Out of scope changes"
This is the most valuable line in the template. AI agents love to tidy up. They rename a helper, "simplify" an error handler, reformat a config file or bump a package because a warning annoyed them. None of that is necessarily wrong, but all of it is unreviewed risk hidden inside an unrelated PR. Making the agent list these changes, or say "none", turns silent drift into a visible decision.
A good rule of thumb: revert out-of-scope changes by default and ask for them as a separate PR if they are worth keeping.
Risk flags
Not all lines are equal. A typo in a button label and a changed WHERE clause in a delete query should not get the same attention. The checkboxes tell the reviewer where to slow down. When a box is ticked, the reviewer traces that path by hand: who can reach this code now, what data does it write or delete, and what happens if it fails halfway?
Two flags deserve special mention for AI code:
-
New or upgraded dependencies. Models sometimes suggest packages that are outdated, unmaintained or simply don't exist under that name. Check every new name on the official registry.
git diff origin/main...HEAD -- package.json package-lock.json pyproject.toml requirements.txt go.mod -
Deleted or weakened tests. When a test fails, "make the test pass" is the easiest route for an agent, and editing the test is easier than fixing the code. Look for removed assertions, added
.skip, loosened matchers and snapshot files that were regenerated wholesale.git diff origin/main...HEAD -- '**/*.test.*' '**/*_test.*' '**/tests/**'
Evidence
"All tests pass" from an agent is a claim, not evidence. It may have run the tests before its last edit. Ask for the exact command and the result, plus one manual check a human could repeat. For UI changes, a screenshot is worth more than a paragraph.
Rollback
Most PRs can be rolled back with "revert this PR". Migrations, data backfills and changes to external services (webhooks, DNS, payment settings) can't. Writing the rollback down before merging is cheap. Finding out at 2 a.m. that you can't roll back is expensive.
AI involvement
This is not about blame. It tells future-you, or the developer you eventually hire, which parts of the codebase were reviewed line by line and which were accepted on trust. "Human has read every changed line: partially" is an honest and useful answer.
Reviewer sign-off
The first checkbox is the real test: can you explain the change without the agent's summary? If not, don't merge yet. Ask the agent to explain the change, split it up or simplify it.
Make the agent fill in the template
A template only helps if it gets filled in. The easiest way is to tell the agent in your repository's instruction file. Claude Code reads CLAUDE.md, and Codex, Cursor and many other tools read AGENTS.md. Add a short section:
## Pull requests
- Never push to `main`. Work on a branch named `ai/<short-task-name>`.
- Open pull requests as drafts only.
- Always fill in `.github/pull_request_template.md` completely.
- List every file you changed in "What changed". List anything not required
by the task under "Out of scope changes", or write "none".
- Paste the exact test command and its output under "Evidence".
- Do not tick "Human has read every changed line"; leave that to the reviewer.
With the GitHub CLI, an agent can open a draft PR that uses your template like this:
gh pr create --draft --base main --head ai/newsletter-form \
--title "Add newsletter signup form" \
--body-file .github/pull_request_template.md
It then edits the body with its answers. You can also ask it to write the filled-in body to a file first so you can read it before the PR is created.
Make the template hard to skip
Instructions are suggestions. Agents follow them most of the time, not all of the time. Three small guardrails make the template stick:
-
Protect the default branch. On GitHub, add a branch ruleset for
mainwith "Require a pull request before merging" and "Block force pushes". Then nothing reachesmainwithout a PR, and the template gets used. (See How to Stop Claude Code, Cursor and Codex From Pushing to Main for the step-by-step.) -
Check that the sections are filled. A tiny GitHub Action can fail the PR if "Out of scope changes" or "Evidence" is still empty:
# .github/workflows/pr-template-check.yml name: PR template check on: pull_request: types: [opened, edited, synchronize, ready_for_review] jobs: check: runs-on: ubuntu-latest steps: - name: Require key sections env: BODY: ${{ github.event.pull_request.body }} run: | for section in "## What was asked" "## Out of scope changes" "## Evidence" "## Rollback"; do if ! printf '%s' "$BODY" | grep -qF "$section"; then echo "Missing section: $section"; exit 1 fi done if printf '%s' "$BODY" | grep -A2 "## Evidence" | grep -qE "Tests run \(command \+ result\):\s*$"; then echo "Evidence section is empty"; exit 1 fiPassing the body through an environment variable, rather than pasting
${{ }}straight into the script, keeps PR text from being executed as shell code. Then make this check a required status check in your ruleset. -
Keep PRs small. Ask for one task per branch. A 3-file PR with a filled-in template takes five minutes to review. A 40-file PR takes an afternoon, or more realistically gets merged without being read.
A filled-in example
Here's what a good answer looks like for a small task:
## What was asked
"Add a newsletter signup form to the footer that posts to /api/subscribe."
## What changed
| File | Change | Why it was needed |
|------|--------|-------------------|
| components/Footer.tsx | Added <NewsletterForm/> | Requested UI |
| components/NewsletterForm.tsx | New file | Form + client validation |
| app/api/subscribe/route.ts | New route, validates email, calls provider | Requested endpoint |
## Out of scope changes
- Renamed `formatDate` to `formatDisplayDate` in utils/date.ts (reverted after review)
## Risk flags
- [x] Secrets, env vars, config or CI/CD files (new NEWSLETTER_API_KEY)
- [x] New or upgraded dependencies (none added, checked lockfile)
## Evidence
- Tests run: `npm test -- NewsletterForm` → 6 passed
- Manual check: submitted valid + invalid email locally, saw success / error message
- Screenshot: attached
## Rollback
Revert this PR. Remove NEWSLETTER_API_KEY from Vercel env afterwards.
The reviewer can see in ten seconds where to look: the new route and the new secret. Everything else is low risk.
Start with the free kit
If you want this template plus the instruction files that make agents use it, the free Founder Repo OS Community Kit has them ready to copy: AGENTS.md, a PR template for AI changes and a DECISIONS.md log. It's open source on GitHub: github.com/suppelabs/founder-repo-os-community.
If you'd rather not set it up by hand, Founder Repo OS scans your repository, proposes rules that fit your project and delivers everything as a draft pull request with the full diff. It never writes to main, and you decide what gets merged. You can start with the free Repo Scorecard to see where your repo stands.