create-pr について
GitHub CLI を使った GitHub プルリクエストの準備と作成を支援するスキルです。ブランチ状態と変更内容を確認し、PR の説明を整え、CLI バージョン別の既存 PR 編集方法も示します。
主な機能
- 01ブランチとコミット状態の確認
- 02コミットと差分の確認
- 03構成に沿った PR 説明の指針
- 04GitHub CLI による PR 作成
- 05CLI バージョン別の PR 編集
活用シーン
- 01レビュー用の機能または修正ブランチの準備
- 02要点が明確な PR の作成
- 03PR のタイトルや説明の更新
インストール
コマンドをコピーしてターミナルで実行します。
npx skills add https:/ / github.com/ marcelorodrigo/ agent-skills --skill create-prインストール後、Claude Code で/create-prを入力して読み込まれたか確認します。
詳細
プルリクエストの作成
最善のエンジニアリングプラクティスに従ってプルリクエストを作成します。
必要条件:GitHub CLI(gh)が認証済みで、利用可能であること。
前提条件
PR を作成する前に、すべての変更がコミットされていることを確認してください。コミットされていない変更がある場合は、まずコミットスキル skill({ name: "conventional-commit" }) を実行して、適切にコミットしてください。
# Check for uncommitted changes
git status --porcelain
出力にコミットされていない変更(含めるべき変更済み、追加済み、または追跡されていないファイル)が表示された場合は、先に進む前にコミットスキル skill({ name: "conventional-commit" }) を呼び出してください。
プロセス
ステップ 1:ブランチの状態を確認する
# Detect the default branch
BASE=$(gh repo view --json defaultBranchRef --jq '.defaultBranchRef.name')
# Check current branch and status
git status
git log $BASE..HEAD --oneline
以下を確認してください:
- すべての変更がコミットされている
- ブランチがリモートと同期している
- 必要に応じて、変更がベースブランチにリベースされている
ステップ 2:変更を分析する
PR に含める内容を確認します:
# See all commits that will be in the PR
git log $BASE..HEAD
# See the full diff
git diff $BASE...HEAD
説明を書く前に、すべての変更の範囲と目的を把握してください。
ステップ 3:PR の説明を書く
PR の説明には、次の構成を使用してください(リポジトリの PR テンプレートは無視します):
<brief description of what the PR does>
<why these changes are being made - the motivation>
<alternative approaches considered, if any>
<any additional context reviewers need>
含めないでください:
- 「テスト計画」セクション
- テスト手順のチェックボックスリスト
- 差分の冗長な要約
含めてください:
- 何を、なぜ行うのかを明確に説明する内容
- 関連する課題やチケットへのリンク(利用可能な場合のみ)
- コードからは明らかでない背景情報
- 特に注意して確認すべき箇所に関する注記
ステップ 4:PR を作成する
gh pr create --title "<type>(<scope>): <description>" --body "
<description body here>
"
タイトルの形式はコミット規約に従います:
feat(scope): Add new featurefix(scope): Fix the bugrefactor(scope): Refactor something
PR の説明例
機能追加 PR
Add Slack thread replies for alert notifications
When an alert is updated or resolved, we now post a reply to the original
Slack thread instead of creating a new message. This keeps related
notifications grouped and reduces channel noise.
Previously considered posting edits to the original message, but threading
better preserves the timeline of events and works when the original message
is older than Slack's edit window.
バグ修正 PR
Handle null response in user API endpoint
The user endpoint could return null for soft-deleted accounts, causing
dashboard crashes when accessing user properties. This adds a null check
and returns a proper 404 response.
リファクタリング PR
Extract validation logic to shared module
Moves duplicate validation code from the alerts, issues, and projects
endpoints into a shared validator class. No behavior change.
This prepares for adding new validation rules without
duplicating logic across endpoints.
ガイドライン
- 機能や修正ごとに PR を 1 つ作成する - 関連のない変更をまとめないでください
- レビューしやすい PR にする - 小規模な PR は、より迅速で質の高いレビューにつながります
- 理由を説明する - コードは何をしたかを示し、説明はなぜ行ったかを伝えます
既存の PR の編集
作成済みの PR を更新する際、このスキルは GitHub CLI のバージョンに応じて最適な方法を自動的に選択します:
- gh 2.82.1+:ネイティブの
gh pr editを使用します(シンプルで、すべての機能を備えています) - gh < 2.82.1:
gh apiにフォールバックします(Projects classic の非推奨化に関するバグを回避します)
バージョンを確認する
# Check GitHub CLI version
gh --version
新しい方法(gh 2.82.1+)
# Update PR description
gh pr edit PR_NUMBER --body "Updated description here"
# Update PR title
gh pr edit PR_NUMBER --title "New Title here"
# Update both
gh pr edit PR_NUMBER --title "new: Title" --body "New description"
従来の方法へのフォールバック(gh < 2.82.1)
gh pr edit が「Projects (classic) is being deprecated」というエラーで失敗する場合は、API を直接使用してください:
# Update PR description
gh api -X PATCH repos/{owner}/{repo}/pulls/PR_NUMBER -f body="
Updated description here
"
# Update PR title
gh api -X PATCH repos/{owner}/{repo}/pulls/PR_NUMBER -f title='New Title here'
# Update both
gh api -X PATCH repos/{owner}/{repo}/pulls/PR_NUMBER \
-f title='new: Title' \
-f body='New description'
注:Projects (classic) のバグは gh 2.82.1 で修正されました(2025 年 10 月)。 古いバージョンを使用している場合は、パッケージマネージャーでアップグレードしてください。