PR
Overview
Automates pull request creation by detecting repository-specific title patterns, adapting PR templates, and creating draft PRs after user confirmation.
Workflow
Step 1: Analyze Changes
- •Run
git diff origin/<base>...HEADto examine all changes - •Run
git log origin/<base>..HEADto see commit history - •Identify the single most important change - what's the primary purpose of this PR?
- •New feature? Which one?
- •Bug fix? What bug?
- •Refactoring? Of what?
- •Performance improvement? Where?
- •Understand scope: frontend, backend, infrastructure, tests, etc.
Step 2: Detect Title Pattern
- •Run
gh pr list --limit 10 --json titleto examine recent PRs - •Identify common patterns:
- •Prefix formats:
[TICKET-123],feature(TICKET-123):,fix: - •Ticket number formats:
ENG-555,FGF-123,JIRA-456
- •Prefix formats:
- •Extract ticket number from current branch name if pattern exists
- •If pattern detected but ticket number not found in branch name, ask user for it
Step 3: Check for PR Template
- •
Look for template at:
- •
.github/pull_request_template.md - •
.github/PULL_REQUEST_TEMPLATE.md
- •
- •
If template found, adapt it:
- •Remove/skip UI-related sections if changes don't touch frontend code (no views, CSS, JS, React)
- •Fill relevant sections based on change analysis
- •
Content guidelines:
- •Use imperative language ("Add feature", not "Added feature")
- •Focus only on most important changes
- •Don't mention tests - tests are expected and obvious. Only mention if they're a major part of the PR (e.g., new testing framework, significant test infrastructure changes)
- •Use backticks for code references (variables, methods, classes, file names)
- •Use third person ("This adds..." not "I added...")
- •Never mention Claude
Step 4: Generate Title and Body
- •
Craft title following detected pattern:
- •Title must mention the single most important thing in the PR
- •Apply ticket number prefix if pattern exists
- •Use imperative mood ("Add feature", "Fix bug")
- •Focus on primary purpose, not implementation details
- •
Generate body from template (if found) or create summary of changes
- •Focus on why, ask for context if don't have, not what.
Step 5: Interactive Confirmation (REQUIRED - DO NOT SKIP)
STOP. Do NOT create the PR yet.
- •
Display the generated PR title and body
- •
MUST use AskUserQuestion tool (do NOT ask conversationally, do NOT proceed to Step 6 without this). Use this exact structure:
- •header: "Next step"
- •question: "What would you like to do?"
- •options (exactly 3):
- •label: "Create PR", description: "Create the PR as shown above"
- •label: "Edit title", description: "Modify the PR title"
- •label: "Edit body", description: "Modify the PR body"
- •multiSelect: false
- •
Handle response:
- •"Create PR" → NOW proceed to Step 6
- •"Edit title" → user provides new title via "Other", apply it, show updated PR, return to step 2
- •"Edit body" → user provides new body via "Other", apply it, show updated PR, return to step 2
- •"Other" text → treat as edited content for whichever edit option user intended
Step 6: Create Draft PR (WAIT FOR STEP 5 TO BE EXPLICITLY CONFIRMED, DON'T ACCEPT EMPTY RESPONSES)
Only execute this step after user selected "Create PR" in Step 5.
- •Push branch to remote with
-uflag if not tracking remote - •Run
gh pr createwith:- •
--title(generated title) - •
--body(generated or template-based body) - •
--assignee @me - •
--draft
- •