Create pull request

From pjt222/agent-almanac · View interactive version

Create pull request is an AI agent skill from the GitHub repository pjt222/agent-almanac. Create and manage pull requests using GitHub CLI. Covers branch preparation, writing PR titles and descriptions, creating PRs, handling review feedback, and merge/cleanup workflows. Use when proposing changes from a feature or fix branch for review, merging completed work into the main branch, reque

How to use this skill

Skill file

Create Pull Request

GitHub PR w/ clear title + structured desc + branch setup.

Use When

In

Do

Step 1: Branch Ready

Verify up-to-date + all committed:

# Check for uncommitted changes
git status

# Fetch latest from remote
git fetch origin

# Rebase on latest main (or merge)
git rebase origin/main

Got: Branch ahead of origin/main, no uncommit, no conflicts.

If err: Rebase conflicts → resolve (see resolve-git-conflicts) → git rebase --continue. Diverged → git merge origin/main.

Step 2: Review Changes

Full diff + commit history:

# See all commits on this branch (not on main)
git log origin/main..HEAD --oneline

# See the full diff against main
git diff origin/main...HEAD

# Check if branch tracks remote and is pushed
git status -sb

Got: All commits PR-relevant. Diff = intended changes only.

If err: Unrelated commits → interactive rebase → clean up history pre-PR.

Step 3: Push Branch

# Push branch to remote (set upstream tracking)
git push -u origin HEAD

Got: Branch on GitHub remote.

If err: Rejected → git pull --rebase origin <branch> + resolve.

Step 4: Title + Desc

Title <70 chars. Body for details:

gh pr create --title "Add weighted mean calculation" --body "$(cat <<'EOF'
## Summary
- Implement `weighted_mean()` with NA handling and zero-weight filtering
- Add input validation for mismatched vector lengths
- Include unit tests covering edge cases

## Test plan
- [ ] `devtools::test()` passes with no failures
- [ ] Manual verification with example data
- [ ] Edge cases: empty vectors, all-NA weights, zero-length input

🤖 Generated with [Claude Code](https://claude.com/claude-code)
EOF
)"

Draft:

gh pr create --title "WIP: Add authentication" --body "..." --draft

Got: PR on GitHub + URL. Desc = what changed + how to test.

If err: gh not auth → gh auth login. Wrong base → --base main.

Step 5: Review Feedback

Respond + push:

# View PR comments
gh api repos/{owner}/{repo}/pulls/{number}/comments

# View PR review status
gh pr checks

# After making changes, commit and push
git add <files>
git commit -m "$(cat <<'EOF'
fix: address review feedback on input validation

EOF
)"
git push

Got: New commits on PR. Comments addressed.

If err: CI fail post-push → gh pr checks → fix pre-rereq.

Step 6: Merge + Cleanup

Post-approval:

# Merge the PR (squash merge keeps history clean)
gh pr merge --squash --delete-branch

# Or merge with all commits preserved
gh pr merge --merge --delete-branch

# Or rebase merge (linear history)
gh pr merge --rebase --delete-branch

Update local main:

git checkout main
git pull origin main

Got: PR merged, remote branch deleted, local main updated.

If err: Blocked by fail checks / missing approvals → address first. No force-merge w/o resolve.

Check

Traps

→

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.