Prompt file imported from drexed/cmdx (
.cursor/commands/create-pr.md). Copyright stays with the author.
Create Pull Request
Role
You are a senior developer creating a pull request on GitHub using the gh CLI, filling in the project's PR template with an accurate, thorough description derived from the branch's changes.
Context
This project uses a PR template at .github/PULL_REQUEST_TEMPLATE.md with these sections:
## ๐๏ธ Issue, exception, or other link
## ๐ Change description
## ๐งช Test plan
## โ
Before you request a review
PRs should have concise, imperative-mood titles matching the commit style (sentence case, no trailing period, no conventional-commit prefixes). When an issue key is provided, prepend it in brackets: [CMDX-123] Add performance optimization.
Task
Create a GitHub pull request for the current branch.
Steps
-
Ask for options โ Prompt the user with these optional questions:
- Issue key / issue URL โ e.g.
CMDX-123or a full URL. Used in the title bracket and the "Issue" section. Leave blank to skip. - Base branch โ defaults to
main. Override if targeting a different branch. - Draft โ whether to create the PR as a draft. Default: no.
- Issue key / issue URL โ e.g.
-
Gather context โ Run these in parallel:
git statusโ verify the working tree (warn if there are uncommitted changes)git log --oneline main..HEADโ all commits on this branch since it diverged from basegit diff main...HEAD --statโ summary of all file changesgit diff main...HEADโ full diff for content analysisgit branch --show-currentโ current branch namegit log --oneline main..HEAD --reverseโ chronological order for narrative flow- Check remote tracking:
git status -sbโ determine if branch is pushed
-
Push the branch โ If the branch has no upstream or is ahead of the remote:
git push -u origin HEAD- Do not force-push
-
Draft the PR title โ Summarize the overall change in imperative mood:
- If an issue key was provided, prepend it:
[CMDX-123] Add feature - Keep it โค 72 characters
- Should describe the "what" at a high level
- If an issue key was provided, prepend it:
-
Draft the PR body โ Fill in each template section:
๐๏ธ Issue, exception, or other link
- If an issue key or URL was provided, include it here
- If none, write "N/A"
๐ Change description
- Analyze ALL commits (not just the latest) and the full diff
- Write a clear summary of what changed and why
- Use bullet points for multiple concerns
- Mention key files or areas affected when it adds clarity
- Keep it factual and concise โ no filler
๐งช Test plan
- List concrete steps or checks to verify the changes work
- If specs were added/modified, mention them
- If manual verification is needed, describe the steps
- If no tests apply, explain why
โ Before you request a review
- Include the checklist items from the template
- Pre-check items that are already satisfied based on the diff
-
Attach visuals โ If the changes involve UI, styling, or any visual behavior:
- Run app locally (seed or generate any data required)
- Use the
GenerateImagetool to create a screenshot, mockup, or diagram illustrating the implemented solution - Upload it to the PR as a comment using
gh pr comment <number> --body ""or attach viagh api - If the changes are purely backend/config with no visual component, skip this step
-
Create the PR โ Use
gh pr createwith a HEREDOC for the body:gh pr create --title "<title>" --base <base> [--draft] --body "$(cat <<'EOF' <body> EOF )" -
Report โ Display the result.
Constraints
- Do not modify
git config - Do not force-push or run destructive Git operations
- Do not use
--no-verifyor skip hooks - Do not push to
mainormasterdirectly - Do not create the PR if the branch has zero commits ahead of base โ say so and stop
- If the working tree has uncommitted changes, warn the user and ask whether to proceed or commit first
- Use the full PR template structure โ do not skip sections
- Derive all content from the actual diff and commits โ do not fabricate changes
Output
After creating the PR, display:
| Field | Value |
|---|---|
| PR | #<number> |
| Title | <title> |
| URL | <url> |
| Base | <base branch> |
| Head | <current branch> |
| Draft | Yes / No |
| Commits | <count> commit(s) |
| Files | <count> file(s) changed |