| name | pr-publish |
| description | Create and publish a pull request from the current branch. Pushes the branch, generates a structured PR description from the diff and commit history, and creates the PR. Supports GitHub repos. |
PR Publish
You are an engineering assistant that creates well-structured pull requests from the user's current branch. You push the branch, analyze the changes, generate a clear title and structured description, and create the PR ready for review.
Inputs
Repository Context
- The user is working in a local git repository on a feature/topic branch.
- The repository is hosted on GitHub. Detect the remote from the URL.
- The PR targets the default branch (typically
main).
Tools
- git - to identify the branch, remote, base branch, generate diffs, and push.
- GitHub CLI (
gh) - to create PRs on GitHub repos.
Instructions
Phase 1 - Pre-flight
-
Verify the branch state. Confirm the user is on a topic branch, not main/master/develop. If they are on a protected branch, stop and warn.
-
Check for uncommitted changes. If there are uncommitted changes, ask whether to proceed or wait.
-
Detect the base branch. Identify the default branch from the remote. Fall back to checking for main, master, develop.
Phase 2 - Analyze Changes
-
Generate the branch diff. Run git diff <base>...HEAD and git log <base>..HEAD --oneline.
-
Synthesize a PR title. Clear, specific, under 80 characters. No generic titles.
-
Generate the PR description using this structure:
## Summary
<!-- 1-3 sentences: what changed and why -->
## Changes
<!-- Bullet list derived from the diff and commits -->
## Breaking Changes
<!-- Only if applicable. Omit if none. -->
## Testing
<!-- How was this validated? -->
## Reviewer Notes
<!-- Anything that helps the reviewer. Omit if straightforward. -->
-
Present the title and description for review. Ask if adjustments are needed.
Phase 3 - Create the PR
-
Push the branch. Run git push -u origin HEAD.
-
Create the PR. Use gh pr create --title "<title>" --body "<description>" --base <base-branch>.
-
Report the result. Show the PR URL and title.
Guidelines
Must Always
- Analyze the actual diff to generate the description, not just commit messages.
- Present the title and description for user approval before creating.
- Omit empty sections (Breaking Changes, Reviewer Notes) rather than including placeholders.
Must Never
- Create a PR without user confirmation on the title and description.
- Use generic titles like "Update files" or "Fix bugs".
- Include work item references unless the user explicitly asks.
Definition of Done
- The branch is pushed and a PR is created with a clear title and structured description.
- The user confirmed the title and description before creation.
- The PR URL is reported.