Back to Skills

create-pull-request

pjt222
Updated 2 days ago
5 views
17
2
17
View on GitHub
Metawordaiautomation

About

This Claude Skill automates creating and managing GitHub pull requests using the GitHub CLI. It handles branch preparation, PR creation with structured titles/descriptions, and manages review feedback through merge workflows. Use it when proposing changes from feature branches for code review or merging completed work into main branches.

Quick Install

Claude Code

Recommended
Primary
npx skills add pjt222/agent-almanac -a claude-code
Plugin CommandAlternative
/plugin add https://github.com/pjt222/agent-almanac
Git CloneAlternative
git clone https://github.com/pjt222/agent-almanac.git ~/.claude/skills/create-pull-request

Copy and paste this command in Claude Code to install this skill

Documentation

造拉取請求

造 GitHub 拉取請求,含明標題、結構化描述、得宜之分支立。

適用時機

  • 自功能或修正分支提改以供審
  • 將已完工作併入主分支
  • 請協作者行程式審查
  • 記一組改動之目的與範圍

輸入

  • 必要:含已提交之改動之功能分支
  • 必要:合併至之基底分支(常為 main
  • 選擇性:待請之審者
  • 選擇性:標籤或里程碑
  • 選擇性:草稿狀態

步驟

步驟一:確保分支已備

驗分支與基底分支同步且所有改動已提交:

# Check for uncommitted changes
git status

# Fetch latest from remote
git fetch origin

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

預期: 分支超前 origin/main,無未提交之改動且無衝突。

失敗時: 若 rebase 衝突,解之(見 resolve-git-conflicts 技能),繼以 git rebase --continue。若分支顯著分歧,考慮 git merge origin/main 代之。

步驟二:察分支上所有改動

察 PR 所含之全差異與提交歷史:

# 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

預期: 所有提交與 PR 相關。差異僅顯所欲之改動。

失敗時: 若有不相關之提交,考慮互動 rebase 以清歷史,再造 PR。

步驟三:推分支

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

預期: 分支現於 GitHub 遠端。

失敗時: 若推被拒,先以 git pull --rebase origin <branch> 拉並解任何衝突。

步驟四:寫 PR 標題與描述

標題守於 70 字以內。用正文述細節:

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
)"

草稿 PR:

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

預期: PR 造於 GitHub 且返 URL。描述明述改動與測法。

失敗時:gh 未認證,行 gh auth login。若基底分支誤,以 --base main 指定。

步驟五:處審查回饋

應審查意見並推更新:

# 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

預期: 新提交顯於 PR。審查意見已處。

失敗時: 若推後 CI 察敗,以 gh pr checks 察檢查輸出,修之再請重審。

步驟六:合併與清

核准後:

# 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

合併後更本地 main:

git checkout main
git pull origin main

預期: PR 已合、遠端分支已刪、本地 main 已更。

失敗時: 若合被失敗檢查或缺核准所阻,先處之。勿未解阻礙而強制合併。

驗證

  • PR 標題簡(70 字內)且述性
  • PR 正文含改動摘要與測計畫
  • 分支上所有提交與 PR 相關
  • CI 察皆通
  • 分支與基底分支同步
  • 審者已指(若倉設要求)
  • 差異中無敏感資料

常見陷阱

  • PR 過大:PR 守於單功能或修正。大 PR 難審且易生合併衝突
  • 缺測計畫:恒述改動可如何驗,即文件 PR 亦然
  • 陳舊分支:若基底分支顯著前行,造 PR 前 rebase 以減合併衝突
  • 審中強制推:避對有開放審查意見之分支強制推。推新提交令審者見漸進改動
  • 不讀 CI 輸出:請重審前察 gh pr checks。敗 CI 耗審者之時
  • 忘刪分支:合併時用 --delete-branch 以保遠端清

相關技能

  • commit-changes - 為 PR 造提交
  • manage-git-branches - 分支造與命名慣例
  • resolve-git-conflicts - rebase/合併中之衝突處
  • create-github-release - 合併後之發布

GitHub Repository

pjt222/agent-almanac
Path: i18n/wenyan-lite/skills/create-pull-request
0
agentsagentskillsai-assisted-developmentclaude-codeskillsteams

Related Skills

content-collections

Meta

This skill provides a production-tested setup for Content Collections, a TypeScript-first tool that transforms Markdown/MDX files into type-safe data collections with Zod validation. Use it when building blogs, documentation sites, or content-heavy Vite + React applications to ensure type safety and automatic content validation. It covers everything from Vite plugin configuration and MDX compilation to deployment optimization and schema validation.

View skill

polymarket

Meta

This skill enables developers to build applications with the Polymarket prediction markets platform, including API integration for trading and market data. It also provides real-time data streaming via WebSocket to monitor live trades and market activity. Use it for implementing trading strategies or creating tools that process live market updates.

View skill

creating-opencode-plugins

Meta

This skill helps developers create OpenCode plugins that hook into 25+ event types like commands, files, and LSP operations. It provides the plugin structure, event API specifications, and implementation patterns for JavaScript/TypeScript modules. Use it when you need to intercept, monitor, or extend the OpenCode AI assistant's lifecycle with custom event-driven logic.

View skill

sglang

Meta

SGLang is a high-performance LLM serving framework that specializes in fast, structured generation for JSON, regex, and agentic workflows using its RadixAttention prefix caching. It delivers significantly faster inference, especially for tasks with repeated prefixes, making it ideal for complex, structured outputs and multi-turn conversations. Choose SGLang over alternatives like vLLM when you need constrained decoding or are building applications with extensive prefix sharing.

View skill