Create GitHub Pull Request Prompt

Last updated on Feb 27, 2026

A pull request generator that analyzes your full branch history — not just the last commit — to create well-structured GitHub PRs. It runs git diff main...HEAD to capture every change since your branch diverged, then drafts a PR title in Conventional Commits format and a body with a summary and test plan checklist.

The agent handles the entire workflow: checking remote tracking status, pushing if needed, and creating the PR as a draft via the GitHub CLI. The structured output includes a multi-commit analysis, so reviewers see the full picture regardless of how many intermediate commits your branch contains.

Prompt

# Creating Pull Requests

Use the gh command via the Bash tool for ALL GitHub-related tasks including working with issues, pull requests, checks, and releases. If given a Github URL use the gh command to get the information needed.

IMPORTANT: When the user asks you to create a pull request, follow these steps carefully:

1. Run the following commands in parallel, in order to understand the current state of the branch since it diverged from the main branch:
   - Run a git status command to see all untracked files
   - Run a git diff command to see both staged and unstaged changes that will be committed
   - Check if the current branch tracks a remote branch and is up to date with the remote, so you know if you need to push to the remote
   - Run a git log command and \`git diff main...HEAD\` to understand the full commit history for the current branch (from the time it diverged from the \`main\` branch)

2. Analyze all changes that will be included in the pull request, making sure to look at all relevant commits (NOT just the latest commit, but ALL commits that will be included in the pull request!!!), and draft a pull request summary. Wrap your analysis process in <pr_analysis> tags:

<pr_analysis>
- List the commits since diverging from the main branch
- Summarize the nature of the changes (eg. new feature, enhancement to an existing feature, bug fix, refactoring, test, docs, etc.)
- Brainstorm the purpose or motivation behind these changes
- Assess the impact of these changes on the overall project
- Do not use tools to explore code, beyond what is available in the git context
- Check for any sensitive information that shouldn't be committed
- Draft a concise (1-2 bullet points) pull request summary that focuses on the "why" rather than the "what"
- Ensure the summary accurately reflects all changes since diverging from the main branch
- Ensure your language is clear, concise, and to the point
- Ensure the summary accurately reflects the changes and their purpose (ie. "add" means a wholly new feature, "update" means an enhancement to an existing feature, "fix" means a bug fix, etc.)
- Ensure the summary is not generic (avoid words like "Update" or "Fix" without context)
- Review the draft summary to ensure it accurately reflects the changes and their purpose
</pr_analysis>

1. Run the following commands in parallel:
   - Create new branch if needed
   - Push to remote with -u flag if needed
   - Create PR using gh pr create --draft with the format below. Use a HEREDOC to pass the body to ensure correct formatting.
<example>
gh pr create --draft --title "type: the pr title" --body "$(cat <<'EOF'
## Summary
<1-3 bullet points>

## Test plan
[Checklist of TODOs for testing the pull request...]

EOF
)"
</example>

Important:
- NEVER update the git config
- Return an empty response - the user will see the gh output directly
- ALWAYS use the --draft flag to create DRAFT PRs, unless user states otherwise.
- Test plan MUST have a checklist as TODOs, using `[ ]`
- NEVER include "Generated with"
- ALWAYS use [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) style formatting when writing the title

# Other common operations
- View comments on a Github PR: gh api repos/foo/bar/pulls/123/comments`;

Subscribe for the latest prompts

Get the latest prompts delivered to your inbox