Create a Pull Request
Reviews the current branch's changes, drafts a well-formatted pull request, and creates it after user confirmation.
PR Structure
# [tag][#issue-number] Brief description of what was accomplished ## Summary Concise overview of the completed work and the value it delivers. ## Changes - Modified `path/to/file:lines` — what changed and why - Added `path/to/new_file` — purpose - Deleted `path/to/old_file` — reason ## Testing - Added `tests/test_feature.py` — verifies behaviour X - Manually tested scenario Y ## Related Issue Closes #issue-number
Choosing a Tag
Check whether the project defines its own tag list (common locations: docs/git-msg-tags.md, CONTRIBUTING.md). If none is found, use these defaults:
| Tag | When to use |
|---|---|
[feat] | New functionality |
[fix] | Bug fix |
[docs] | Documentation-only change |
[refactor] | Restructuring without behaviour change |
[test] | Test-only change |
[chore] | Tooling, CI, or dependency updates |
Workflow
1. Review the Changes
Before drafting anything, inspect what the branch contains:
git status git diff git log origin/main..HEAD --oneline
Understand the full scope of changes — not just the latest commit, but everything that will land when the PR merges.
2. Select the Tag
- •Read the project's tag file if one exists
- •Determine the primary purpose of the changes
- •If ambiguous, ask the user to choose
3. Find the Issue Number
The PR title must reference an issue number in the format [tag][#N].
Where to look:
- •Conversation history for explicit references
- •Branch name (e.g.,
issue-42) - •Recent issues:
gh issue list --limit 10
If no related issue exists, ask the user to create one first.
4. Draft the PR
Title: [tag][#N] Brief description — past tense, under 80 characters for the description portion.
Summary: What was achieved and why it matters.
Changes: List every file modified, added, or deleted with a brief note. Include line ranges where helpful. Do not paste code snippets.
Testing: What was tested and how — new test files, manual verification steps, etc.
Related Issue: Use Closes #N, Fixes #N, or Part of #N as appropriate.
5. Confirm with the User
Display the complete draft and wait for explicit approval.
6. Push and Create
Ensure the branch is on the remote:
git push -u origin $(git branch --show-current)
Then create the PR:
gh pr create --title "TITLE" --body-file - <<'EOF' BODY EOF
Display the PR URL to the user.
7. Handle Errors
| Problem | Action |
|---|---|
| No issue number found | Ask user to provide one or create an issue first |
| No changes on the branch | Inform user there's nothing to open a PR for |
| GitHub CLI not authenticated | Ask user to run gh auth login |
| Not on a feature branch | Warn user and suggest creating one |
| Push fails | Show the error and suggest resolution |
Ownership
The PR is created on behalf of the user. The AI agent must not add any authorship or co-authorship attribution.