Create Pull Request
UserRequest
UserRequest: $ARGUMENTS
Meta
- DefaultBranch: Run
gh repo view --json defaultBranchRef --template '{{.defaultBranchRef.name}}'to get the default branch.
Step 1: Atomically Commit Uncommitted Changes
Check uncommitted changes:
git status --short
If changes exist:
Run through the ~/.pi/agent/prompts/commit workflow to create atomic commits with conventional messages.
Validate readiness:
- Run
git branch --show-currentto get the current branch. - Stop if the current branch is the default branch.
- Ensure current branch is pushed to remote:
- Check:
git rev-parse --abbrev-ref --symbolic-full-name @{u} - Push if missing:
git push -u origin HEAD
- Check:
- Verify ArtifactReference is provided:
- If missing, assume current branch context can derive information.
If validation fails: Report specific error and exit.
Step 2: Gather Info
Identify current branch:
CURRENT_BRANCH=$(git branch --show-current)
Determine target branch:
TARGET_BRANCH={DefaultBranch}
Parse artifact reference from UserRequest:
- If GitHub issue:
#123 - If BasicMemory task:
5.1.1-task-database-schema - If Jira ticket:
PROJ-456
Fetch artifact details:
- For GitHub issues: Use
gh issue view {ISSUE_NUMBER} --json title,body,labels - For BasicMemory tasks: Query BasicMemory API for task details
- For Jira tickets: Delegate using
task(jira)and fetch issue summary, description, labels
Review commits on current branch:
git log {TARGET_BRANCH}...HEAD --oneline
Summarize changes:
- Extract key changes from commit messages
- Identify affected components/modules for scope
- Propose the WHY based on commit context and artifact details
Step 3: Prepare PR
Generate title (semantic format):
{type}({scope}): {title} ({artifact_id})
Examples:
feat(auth): implement login with OAuth (closes #123)feat(database): design user schema (5.1.1-task-database-schema)
Generate description:
## Summary
{One-sentence description of what this PR accomplishes}
## Linked Artifact
{GitHub: Closes #{ISSUE}} OR {BasicMemory: Task {ARTIFACT_ID} (Epic {epic_id})}
## Changes
- {Specific change 1}
- {Specific change 2}
## Testing
- [ ] Unit tests added/passing
- [ ] Integration tests passing
- [ ] Manual testing completed
Step 4: Review & Confirm
Display:
- PR Title
- PR Description
- Changed files:
git diff --name-stat origin/main...HEAD - Impact:
git diff --stat origin/main...HEAD
Prompt: "Proceed with creating this pull request?"
- Option: Edit title/description
- Option: Cancel
Step 5: Create PR
Execute:
echo "{description}" > /tmp/pr_description.md
gh pr create --title "{title}" --body-file "/tmp/pr_description.md" --base {target_branch}
Update artifacts:
- GitHub issues: Add comment with PR link, update labels
- BasicMemory tasks: Update status to "in-review", add pr_link
Step 6: Summary
✅ Pull Request Created
- PR: #{PR_NUMBER} → {PR_URL}
- Title: {pr_title}
- Branch: {CURRENT_BRANCH}
- Files: {count} changed, +{lines} -{lines}
Next: Wait for review, address feedback, merge when approved