github-pr
Automate GitHub PR workflow: fork repo, analyze issues, create fix branches, submit PRs and handle CI failures
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Automate GitHub PR workflow: fork repo, analyze issues, create fix branches, submit PRs and handle CI failures
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
| name | github-pr |
| description | Automate GitHub PR workflow: fork repo, analyze issues, create fix branches, submit PRs and handle CI failures |
Automates the complete GitHub Pull Request workflow from forking a repository to handling CI failures.
Use this skill when you need to:
Before using this skill, ensure:
gh CLI is installed and authenticated (see Auto Setup below)git is configured with your user name and emailThis skill includes an automatic setup script for GitHub CLI:
# Check if gh is installed and authenticated
./scripts/setup-gh.sh --check-only
# Full setup (install + auth + completion)
./scripts/setup-gh.sh
# Install without authentication
./scripts/setup-gh.sh --no-auth
The script will:
gh using the appropriate package managerSupported package managers:
If automatic installation fails, see manual installation guide.
gh repo fork OWNER/REPO --clone=false
git clone https://github.com/YOUR_USERNAME/REPO.git
cd REPO
git remote add upstream https://github.com/OWNER/REPO.git
Analyze all open issues in the repository and create a structured analysis:
For each issue, determine:
Output format (Markdown table):
| # | Issue | Title | Description | Affected Files | Difficulty | Feasibility | Fix Approach |
|---|-------|-------|-------------|----------------|------------|-------------|--------------|
| 1 | [#123](link) | **Title** | Brief desc | `file.go` | ⭐ Simple | ✅ Can fix | Explanation |
git checkout -b fix-plan
Create FIX_PLAN.md with the analysis table, then:
git add FIX_PLAN.md
git commit -m "docs: create fix plan for open issues"
git push origin fix-plan
Choose an issue from the FIX_PLAN.md based on:
git checkout master # or main
git pull upstream master
git checkout -b fix/ISSUE_NUMBER-short-description
Branch naming convention:
fix/123-client-ip-parsing (for bug fixes)feat/123-add-feature (for features)docs/123-update-readme (for documentation)Best practices:
Common fix patterns:
Run the project's test suite:
# Common patterns
go test ./... # Go projects
npm test # Node.js projects
pytest # Python projects
cargo test # Rust projects
Verify:
git add <changed_files>
git commit -m "fix: <concise description> (#ISSUE_NUMBER)
<Detailed explanation of what changed and why>
Fixes #ISSUE_NUMBER"
Commit message format:
type: subject (#issue) (50 chars max)fix, feat, docs, test, refactor, style, choreFixes #123 or Closes #123git push -u origin fix/ISSUE_NUMBER-short-description
Ask user for confirmation:
Ready to create PR for issue #123?
Title: fix: <description>
Base: OWNER/REPO:master
Head: YOUR_USERNAME/REPO:fix/123-description
Proceed? (yes/no)
gh pr create \
--repo OWNER/REPO \
--base master \
--head YOUR_USERNAME:fix/ISSUE_NUMBER-description \
--title "fix: <description> (#ISSUE_NUMBER)" \
--body "$(cat <<EOF
## Description
Fixes #ISSUE_NUMBER
<Detailed explanation of the fix>
## Changes
- Change 1
- Change 2
- Change 3
## Testing
- [x] Added/updated tests
- [x] All tests pass locally
- [x] Linter passes
## Related Issues
Closes #ISSUE_NUMBER
EOF
)"
Fetch PR URL and monitor checks:
PR_URL=$(gh pr view --json url -q .url)
echo "PR created: $PR_URL"
# Check CI status
gh pr checks
If CI fails:
Loop until all checks pass:
Identify failure cause
gh pr checks # View all check statuses
gh pr view # View PR details and comments
Fix locally
Commit and push fix
git add <files>
git commit -m "fix: resolve CI error - <description>"
git push
Wait and verify
gh pr checksOnce PR is created and CI passes:
git checkout fix-plan
Update FIX_PLAN.md to add PR status column:
| # | Issue | ... | PR Status |
|---|-------|-----|-----------|
| 1 | [#123](link) | ... | 🔄 MR中 [PR #456](pr_link) |
Status indicators:
git add FIX_PLAN.md
git commit -m "docs: update FIX_PLAN.md with PR #456 for issue #123"
git push origin fix-plan
# 1. Select issue #4572 from FIX_PLAN.md
# 2. Create fix branch
git checkout master && git pull upstream master
git checkout -b fix/4572-client-ip-parsing
# 3. Implement fix in context.go
# 4. Add tests in context_test.go
# 5. Run tests
go test ./...
# 6. Commit
git add context.go context_test.go
git commit -m "fix: support non-standard X-Forwarded-For formats (#4572)"
# 7. Push and create PR
git push -u origin fix/4572-client-ip-parsing
gh pr create --repo gin-gonic/gin --base master \
--title "fix: support non-standard X-Forwarded-For formats (#4572)" \
--fill
# 8. Monitor CI
gh pr checks
# CI failed with errcheck errors
# Fix by adding error handling
git add -u
git commit -m "fix: resolve errcheck lint errors"
git push
# Verify fix
gh pr checks
Solution: Use existing fork or delete and re-fork:
gh repo delete YOUR_USERNAME/REPO --yes
gh repo fork OWNER/REPO --clone=true
Solution: Rebase on upstream:
git fetch upstream
git rebase upstream/master
git push --force-with-lease
Solution: Wait and check if re-run is needed:
gh run list --repo OWNER/REPO
gh run rerun RUN_ID
Solution: Add more test cases to cover new code paths
Solution: Run linter locally and fix all at once:
golangci-lint run # Go
npm run lint -- --fix # JavaScript
flake8 . && black . # Python
cargo clippy -- -D warnings # Rust
If the automatic setup script doesn't work, install gh manually:
macOS
brew install gh
Ubuntu/Debian
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | \
sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg
sudo chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | \
sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null
sudo apt update && sudo apt install gh -y
Fedora/CentOS/RHEL
sudo dnf install gh
Windows
winget install --id GitHub.cli
# or use scoop
scoop install gh
Then authenticate:
gh auth login
gh auth login # Authenticate
gh auth status # Check auth status
gh repo fork OWNER/REPO # Fork repository
gh pr create --fill # Create PR with auto-fill
gh pr checks # View CI status
gh pr view # View PR details
gh pr list --state open # List open PRs
gh issue list --label bug # List issues by label
git remote -v # List remotes
git fetch upstream # Fetch upstream changes
git rebase upstream/master # Rebase on upstream
git push --force-with-lease # Safe force push
git log --oneline -10 # View recent commits