github-pr-publish
GitHubのプルリクエストを安全に作成・公開する際、gh CLIやローカルGitを活用し、認証や権限の問題解決も支援するSkill。
📜 元の英語説明(参考)
Agent-neutral workflow for safely publishing GitHub pull requests with gh CLI, local git, and constrained GitHub REST fallback. Use when asked to create, open, publish, draft, or preflight a GitHub PR from a local branch; push a branch for PR creation; create a PR in a public or private repo; diagnose PR creation auth, SSO, permission, or not-found failures; or avoid unsafe gh pr create prompting, fork creation, or accidental pushes.
🇯🇵 日本人クリエイター向け解説
GitHubのプルリクエストを安全に作成・公開する際、gh CLIやローカルGitを活用し、認証や権限の問題解決も支援するSkill。
※ jpskill.com 編集部が日本のビジネス現場向けに補足した解説です。Skill本体の挙動とは独立した参考情報です。
⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。
🎯 このSkillでできること
下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。
📦 インストール方法 (3ステップ)
- 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
- 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
- 3. 展開してできたフォルダを、ホームフォルダの
.claude/skills/に置く- · macOS / Linux:
~/.claude/skills/ - · Windows:
%USERPROFILE%\.claude\skills\
- · macOS / Linux:
Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。
詳しい使い方ガイドを見る →- 最終更新
- 2026-05-17
- 取得日時
- 2026-05-17
- 同梱ファイル
- 1
📖 Skill本文(日本語訳)
※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。
GitHub PR Publish
概要
GitHubのプルリクエストを、エージェント固有のコネクタではなく、一般的なツールを通じて公開します。gh、ローカルのgit、およびGitHub REST APIを優先します。ブラウザフローは明示的にのみフォールバックとして使用します。
このワークフローは、公開リポジトリとプライベートリポジトリの両方をサポートしています。プライベートリポジトリでは、リポジトリへのアクセス権を持つ認証済みGitHub CLIアカウント、必要な組織のSSO認証、およびプルリクエストを作成するのに十分なトークンまたはOAuth権限が必要です。
安全性契約
- デフォルトはプレビューです。プッシュ、PRの作成、ブラウザの起動、または変更を伴うAPIリクエストの送信なしに、意図された操作を表示します。
- 生のトークンを印刷、永続化、またはユーザーに貼り付けを要求することはありません。
gh auth loginOAuthを優先します。 - GitHub CLIのトークン表示認証フラグを使用したり、生の認証ログを保存したりすることはありません。
- 実際のPR作成の前に、認証済みアカウントを特定します。
- 作成されたすべてのPRとプッシュされたブランチは、認証済みアカウントと設定されたgitリモートからのアクションとして扱います。
- 対話型の
gh pr createに依存することはありません。実際の作成には、プロンプトなしの完全な入力が必要です。 gh pr createには常に明示的な--head値を渡します。- GitHub CLIのPR作成プレビューフラグに依存しません。このスキルは、CLIがgitの変更をプッシュする可能性があるため、独自のプレビューパスを使用します。
- フォークを作成しません。強制プッシュしません。detached HEADからプッシュしません。
--push --remote <name> --yesで明示的に要求された場合にのみプッシュします。- ブランチとリモートのチェックがパスした後、正確に指定されたリモートに
HEAD:<branch>のみをプッシュします。 - 検出可能な場合、ベース、デフォルト、または保護されたブランチのプッシュを拒否します。
- リモートヘッドが存在することを証明した後でのみ、RESTフォールバックを使用します。
ワークフロー
1. ツールと認証の確認
読み取り専用の事前チェックでは、gitとghが利用可能である必要があります。プライベートリポジトリと実際の作成では、ghが認証されている必要があります。
便利なコマンド:
gh auth status --hostname github.com
gh api user --jq .login
認証が失敗した場合は、ユーザーにgh auth loginを案内します。トークン値を尋ねることはありません。
2. 公開コンテキストの収集
バンドルされている読み取り専用ヘルパーを使用します。
skills/github-pr-publish/scripts/collect_publish_context.sh --repo OWNER/REPO
これは、サニタイズされたアカウントステータス、リポジトリメタデータ、リモート、ブランチの状態、デフォルト/ベース候補、アップストリーム/先行・遅延の詳細、および既存のPRヒントを/tmp/github-pr-publish-*の下にキャプチャします。
3. 作成前にPRコンテンツをドラフトする
PRを作成する前に、最終的なタイトルと本文を準備します。以下を含めます。
- 変更の概要
- 実行されたテストまたはチェック
- リスク、ロールアウトに関する注意点、またはフォローアップ
- 該当する場合はリンクされたイシュー
実際の作成には、プロンプトなしのコンテンツが必要です。
--titleと--bodyまたは--body-file、または- コミットから派生したコンテンツが意図されている場合は、明示的な
--fill、--fill-first、または--fill-verbose
--templateだけでは不十分です。なぜなら、タイトルのソースがまだ必要だからです。--titleまたは検証済みのfill/titleソースと一緒にのみ使用してください。
4. 操作のプレビュー
プレビューがデフォルトです。
skills/github-pr-publish/scripts/create_pr.sh \
--repo OWNER/REPO \
--base main \
--head OWNER:feature-branch \
--title "Add feature" \
--body-file /tmp/pr-body.md
プレビューは、意図されたステートマシンを出力します。
preview -> validate -> optional guarded push -> create -> verify
--yesなしでは、リモートの変更は発生しません。
5. 既存のリモートブランチからPRを作成する
ブランチがすでにターゲットリモートに存在する場合:
skills/github-pr-publish/scripts/create_pr.sh \
--repo OWNER/REPO \
--base main \
--head OWNER:feature-branch \
--title "Add feature" \
--body-file /tmp/pr-body.md \
--yes
ヘルパーはリモートヘッドを検証し、明示的な--headでPRを作成し、gh pr viewで作成されたPRを検証します。
6. プッシュしてから作成する
最初のプッシュでは、明示的に指定します。
skills/github-pr-publish/scripts/create_pr.sh \
--repo OWNER/REPO \
--base main \
--title "Add feature" \
--body-file /tmp/pr-body.md \
--push --remote origin \
--yes
ヘルパーはOWNERと現在のブランチから明示的なヘッドを導出し、ブランチが安全であることを確認し、リモートがターゲットリポジトリにマッピングされていることを確認し、正確にHEAD:<branch>をプッシュしてからPRを作成します。
7. RESTフォールバック
リモートヘッドがすでに存在し、CLI作成パスがブロックされている場合にのみRESTを使用します。
skills/github-pr-publish/scripts/create_pr.sh \
--repo OWNER/REPO \
--base main \
--head OWNER:feature-branch \
--title "Add feature" \
--body-file /tmp/pr-body.md \
--use-rest \
--yes
RESTでの作成には、イシューを変換する場合を除き、head、base、およびtitleが必要です。成功した場合はHTTP 201とPRのURLが返される必要があります。
8. オプションのブラウザハンドオフ
--webは明示的にのみ使用します。--yesがない場合、プレビューのみです。--yesがある場合でも、ヘルパーはGitHubのブラウザベースのフローを開く前に、アカウント、リポジトリ、ヘッド、ブランチ、およびコンテンツの検証を実行します。
9. 失敗の分類
失敗を過度に主張することなく分類します。
- 認証されていない、または認証情報が不正:
gh auth loginを実行または更新します。 - SSO/SAML:組織に対してGitHub CLI OAuthアプリまたはトークンを承認します。
- 403:リポジトリへのアクセス権がない、または権限が不十分です。
- プライベートリポジトリでの404:リポジトリが間違っている、アクセス権がない、またはSSOが承認されていないことを意味する可能性があり、必ずしも存在しないことを意味するわけではありません。
- 422:
base/head/titleフィールドが無効、PRが重複している、またはAPI検証の失敗です。
スクリプト
scripts/collect_publish_context.sh
読み取り専用のコンテキストコレクターです。サニタイズされたファイルを/tmp/github-pr-publish-*に書き込み、トークンを保存することはありません。
scripts/create_pr.sh
コマンドレンダラーおよび明示的な実行者です。プレビュー、保護されたプッシュ、CLI作成、RESTフォールバック、および偽のCLIテストをサポートしています。
参照
これらの資料は、動作の保守または適応を行う場合にのみお読みください。
- CLIの制約については
references/github-cli-pr-create.md - RESTフォールバックの制約については
references/github-rest-create-pr.md - エージェントのインストールノートについては
references/agent-adapters.md
📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開
GitHub PR Publish
Overview
Publish GitHub pull requests through general tools rather than agent-specific connectors. Prefer gh, local git, and GitHub REST APIs. Browser flows are explicit-only fallbacks.
This workflow supports public and private repositories. Private repositories require an authenticated GitHub CLI account with repository access, any required organization SSO authorization, and enough token or OAuth permissions to create pull requests.
Safety Contract
- Default to preview: show intended operations without pushing, creating a PR, opening a browser, or sending a mutating API request.
- Never print, persist, or ask the user to paste raw tokens. Prefer
gh auth loginOAuth. - Never use GitHub CLI token-display auth flags or save raw auth logs.
- Identify the authenticated account before actual PR creation.
- Treat all created PRs and pushed branches as actions from the authenticated account and configured git remote.
- Never rely on interactive
gh pr create. Actual creation requires complete prompt-free inputs. - Always pass an explicit
--headvalue togh pr create. - Do not rely on the GitHub CLI PR-create preview flag; this skill uses its own preview path because the CLI can still push git changes.
- Do not create forks. Do not force-push. Do not push from detached HEAD.
- Push only when explicitly requested with
--push --remote <name> --yes. - Push only
HEAD:<branch>to the exact named remote after branch and remote checks pass. - Refuse pushing base, default, or protected branches when detectable.
- Use REST fallback only after proving the remote head exists.
Workflow
1. Check tools and authentication
For read-only preflight, git and gh should be available. For private repos and actual creation, gh must be authenticated.
Useful commands:
gh auth status --hostname github.com
gh api user --jq .login
If auth fails, guide the user to gh auth login. Do not ask for token values.
2. Collect publish context
Use the bundled read-only helper:
skills/github-pr-publish/scripts/collect_publish_context.sh --repo OWNER/REPO
It captures sanitized account status, repo metadata, remotes, branch state, default/base candidates, upstream/ahead-behind details, and existing PR hints under /tmp/github-pr-publish-*.
3. Draft PR content before creation
Prepare a final title and body before creating the PR. Include:
- Summary of the change
- Tests or checks run
- Risks, rollout notes, or follow-ups
- Linked issue when applicable
Prompt-free content is required for actual creation:
--titleplus--bodyor--body-file, or- explicit
--fill,--fill-first, or--fill-verbosewhen commit-derived content is intended
--template alone is not enough because a title source is still required. Use it only with --title or a verified fill/title source.
4. Preview the operation
Preview is the default:
skills/github-pr-publish/scripts/create_pr.sh \
--repo OWNER/REPO \
--base main \
--head OWNER:feature-branch \
--title "Add feature" \
--body-file /tmp/pr-body.md
The preview prints the intended state machine:
preview -> validate -> optional guarded push -> create -> verify
No remote mutation occurs without --yes.
5. Create a PR from an existing remote branch
When the branch already exists on the target remote:
skills/github-pr-publish/scripts/create_pr.sh \
--repo OWNER/REPO \
--base main \
--head OWNER:feature-branch \
--title "Add feature" \
--body-file /tmp/pr-body.md \
--yes
The helper verifies the remote head, creates the PR with explicit --head, then verifies the created PR with gh pr view.
6. Push then create
For a first push, be explicit:
skills/github-pr-publish/scripts/create_pr.sh \
--repo OWNER/REPO \
--base main \
--title "Add feature" \
--body-file /tmp/pr-body.md \
--push --remote origin \
--yes
The helper derives an explicit head from OWNER and the current branch, checks the branch is safe, checks the remote maps to the target repository, pushes exactly HEAD:<branch>, and then creates the PR.
7. REST fallback
Use REST only when the remote head already exists and the CLI create path is blocked:
skills/github-pr-publish/scripts/create_pr.sh \
--repo OWNER/REPO \
--base main \
--head OWNER:feature-branch \
--title "Add feature" \
--body-file /tmp/pr-body.md \
--use-rest \
--yes
REST creation requires head, base, and title unless converting an issue. Success must return HTTP 201 and a PR URL.
8. Optional browser handoff
--web is explicit-only. Without --yes, it is preview-only. With --yes, the helper still runs account, repo, head, branch, and content validation before opening GitHub's browser-based flow.
9. Failure classification
Classify failures without overclaiming:
- Not authenticated or bad credentials: run or refresh
gh auth login. - SSO/SAML: authorize the GitHub CLI OAuth app or token for the organization.
- 403: missing repository access or insufficient permission.
- 404 on private repositories: may mean wrong repo, missing access, or unapproved SSO, not necessarily absence.
- 422: invalid base/head/title fields, duplicate PR, or API validation failure.
Scripts
scripts/collect_publish_context.sh
Read-only context collector. Writes sanitized files to /tmp/github-pr-publish-* and never stores tokens.
scripts/create_pr.sh
Command renderer and explicit executor. Supports preview, guarded push, CLI create, REST fallback, and fake CLI tests.
References
Read these only when maintaining or adapting behavior:
references/github-cli-pr-create.mdfor CLI constraintsreferences/github-rest-create-pr.mdfor REST fallback constraintsreferences/agent-adapters.mdfor agent installation notes