github prs skill
This commit is contained in:
90
pi/files/agent/skills/github-prs/SKILL.md
Normal file
90
pi/files/agent/skills/github-prs/SKILL.md
Normal file
@@ -0,0 +1,90 @@
|
|||||||
|
---
|
||||||
|
name: github-prs
|
||||||
|
description: Find, inspect, and create GitHub pull requests for a branch using the GitHub CLI and git. Use when you need to locate the PR tied to a branch or open/update a PR.
|
||||||
|
---
|
||||||
|
|
||||||
|
# GitHub PRs (branch workflows)
|
||||||
|
|
||||||
|
This skill documents common GitHub CLI workflows for finding a PR for a branch, inspecting it, and creating one if needed.
|
||||||
|
|
||||||
|
## Prerequisites
|
||||||
|
|
||||||
|
- Repository has a GitHub remote (usually `origin`).
|
||||||
|
- GitHub CLI (`gh`) is installed and authenticated (`gh auth status`).
|
||||||
|
|
||||||
|
## Find the PR for the current branch
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Show current branch
|
||||||
|
branch=$(git rev-parse --abbrev-ref HEAD)
|
||||||
|
|
||||||
|
# Find PR for the current branch (if one exists)
|
||||||
|
gh pr list --head "$branch" --state all
|
||||||
|
|
||||||
|
# View the PR details by branch
|
||||||
|
pr_number=$(gh pr list --head "$branch" --state all --json number --jq '.[0].number')
|
||||||
|
if [ -n "$pr_number" ]; then
|
||||||
|
gh pr view "$pr_number" --web
|
||||||
|
fi
|
||||||
|
```
|
||||||
|
|
||||||
|
## Find PRs by branch name (explicit)
|
||||||
|
|
||||||
|
```bash
|
||||||
|
branch="feature/your-branch"
|
||||||
|
gh pr list --head "$branch" --state all
|
||||||
|
```
|
||||||
|
|
||||||
|
## Find the PR for the current branch (alternative via git)
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# If upstream is set, this is handy for branch -> PR lookup
|
||||||
|
upstream=$(git rev-parse --abbrev-ref --symbolic-full-name @{u})
|
||||||
|
if [ -n "$upstream" ]; then
|
||||||
|
gh pr list --head "${upstream#origin/}" --state all
|
||||||
|
fi
|
||||||
|
```
|
||||||
|
|
||||||
|
## Create a PR from the current branch
|
||||||
|
|
||||||
|
```bash
|
||||||
|
branch=$(git rev-parse --abbrev-ref HEAD)
|
||||||
|
|
||||||
|
# Push branch if needed
|
||||||
|
if ! git rev-parse --symbolic-full-name "${branch}@{u}" >/dev/null 2>&1; then
|
||||||
|
git push -u origin "$branch"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Create PR (edit title/body as needed)
|
||||||
|
gh pr create \
|
||||||
|
--title "[ISSUE-123] Short summary" \
|
||||||
|
--body $'[](https://awac.attio.com/redirect/developer-preview/<preview-hash>)\n\n\n\n- Summary bullet 1\n- Summary bullet 2\n'
|
||||||
|
```
|
||||||
|
|
||||||
|
## Update an existing PR body
|
||||||
|
|
||||||
|
```bash
|
||||||
|
pr_number=<number>
|
||||||
|
|
||||||
|
# Edit in editor
|
||||||
|
EDITOR=vim gh pr edit "$pr_number" --body-file -
|
||||||
|
|
||||||
|
# Or overwrite directly
|
||||||
|
gh pr edit "$pr_number" --body $'...'
|
||||||
|
```
|
||||||
|
|
||||||
|
## Quick checks
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Confirm gh auth and repo
|
||||||
|
|
||||||
|
gh auth status
|
||||||
|
|
||||||
|
gh repo view --web
|
||||||
|
```
|
||||||
|
|
||||||
|
## Troubleshooting
|
||||||
|
|
||||||
|
- If `gh pr list --head` returns nothing, the PR may not exist yet, or the branch name differs.
|
||||||
|
- Use `git branch -r | rg <branch-name>` to confirm the remote branch name.
|
||||||
|
- Ensure you're in the correct repo (`git remote -v`).
|
||||||
Reference in New Issue
Block a user