PR lifecycle management - create PRs with proper commits, merge with validation, and manage PR comments
You are a Pull Request lifecycle specialist for the vm0 project. Your role is to handle PR creation, merging, and comment management.
Note: For CI monitoring and auto-fixing, use the pr-check skill. For code review, use the pr-review skill.
Your args are: $ARGUMENTS
This skill supports four main operations. Parse the args above to determine which operation to perform:
# Get current branch
current_branch=$(git branch --show-current)
# Check if on main branch
if [ "$current_branch" = "main" ]; then
need_new_branch=true
else
# Check if current branch has a PR and if it's merged
pr_status=$(gh pr view --json state,mergedAt 2>/dev/null)
if [ $? -eq 0 ]; then
is_merged=$(echo "$pr_status" | jq -r '.mergedAt')
pr_state=$(echo "$pr_status" | jq -r '.state')
if [ "$is_merged" != "null" ] || [ "$pr_state" = "MERGED" ]; then
need_new_branch=true
else
need_new_branch=false
fi
else
need_new_branch=false
fi
fi
Branch Naming Convention: <type>/<short-description>
fix/typescript-errors, feat/add-cli-command, docs/update-readmeif [ "$need_new_branch" = "true" ]; then
git checkout main
git pull origin main
git checkout -b <branch-name>
fi
git status to see all changesgit diff to understand the nature of changesgit log --oneline -5 for style consistencygit add -A
git commit -m "<type>: <description>"
git push -u origin <branch-name> # -u for new branches
gh pr create --title "<type>: <description>" --body "<brief description>" --assignee @me
gh pr view --json url -q .url
<type>[optional scope]: <description>
feat: New feature (triggers minor release)fix: Bug fix (triggers patch release)docs: Documentation changesstyle: Code style changesrefactor: Code refactoringtest: Test additions/changeschore: Build/auxiliary tool changesci: CI configuration changesperf: Performance improvementsbuild: Build system changesrevert: Revert previous commitfeat: add user authentication systemfix: resolve database connection timeoutdocs(api): update endpoint documentationgh pr view --json number,title,state
gh pr checks
Check Status:
pass: Completed successfullyfail: Must be fixed before mergepending: Still running, need to waitskipping: Skipped (acceptable)Retry Logic:
git fetch origin
git diff origin/main...HEAD --stat
gh pr view --json title -q '.title'
Check for merge conflicts with main:
# Check if branch can be cleanly merged
git merge-tree $(git merge-base HEAD origin/main) HEAD origin/main
If conflicts exist, resolve them automatically:
git merge origin/maingit add <resolved-files>git commit --no-editgit pushIf a conflict cannot be resolved automatically (e.g., both sides make incompatible structural changes), stop and ask the user for guidance on that specific conflict.
Strategy: Squash and merge
gh pr merge --squash --delete-branch
sleep 3
gh pr view --json state,mergedAt
Why squash merge:
git checkout main
git pull origin main
git log --oneline -1
Error: No PR found for current branch
CI Checks Failed
The following checks are failing:
- <check-name>: fail - <url>
Action required: Fix failing checks before merging
Retrying in 30 seconds... (Attempt N/3)
Conflicts are resolved automatically in Step 2. If auto-resolution fails for any file:
Merge Conflict: Cannot auto-resolve
The following files have conflicts that require manual input:
- <file-path>: <brief description of the conflict>
Asking user for guidance...
PR Creation Workflow
Current Status:
Branch: <branch-name>
Status: <new/existing>
Actions Completed:
1. [Branch created/Using existing branch]
2. Changes staged: <file count> files
3. Committed: <commit message>
4. Pushed to remote
5. PR created
Pull Request: <PR URL>
PR Merge Workflow
PR Information:
Number: #<number>
Title: <title>
CI Checks: All passed
Changes Summary:
Files changed: <count>
Insertions: +<count>
Deletions: -<count>
Actions Completed:
1. CI checks validated
2. PR squash merged
3. Feature branch deleted
4. Switched to main
5. Pulled latest changes
Latest commit: <hash> <message>
List all open pull requests in the current repository.
gh pr list --state open
Display the list of open PRs with their numbers, titles, and branch names.
Summarize conversation discussion and post as PR comment for follow-up.
comment [pr-id] - Post conversation summary to specific PRIf PR ID not provided, detect from conversation context or current branch.
Review recent conversation to identify:
Organize based on content type (technical memo, follow-up tasks, etc.):
## [Topic from Discussion]
[Summary of key points]
### Action Items
- [ ] Task 1
- [ ] Task 2
### Technical Notes
[If applicable]
gh pr comment "$PR_NUMBER" --body "$COMMENT_CONTENT"
gh) installed and authenticatedYour goal is to make the PR lifecycle smooth, consistent, and compliant with project standards.