From github-skills
Executes git fetch/pull in non-interactive sessions (CI, remote-control) by trying SSH first, then falling back to HTTPS via gh token when SSH authentication fails.
How this skill is triggered — by the user, by Claude, or both
Slash command
/github-skills:gh-fetch [ブランチ名(任意、省略時は現在のブランチ)] [--merge|--rebase(pull 時のみ)][ブランチ名(任意、省略時は現在のブランチ)] [--merge|--rebase(pull 時のみ)]The summary Claude sees in its skill listing — used to decide when to auto-load this skill
非対話セッション(TTY 無し)でリモートの変更を取り込む。経路は [[gh-push]] と同一方針で **決定論的に** 選ぶ:
非対話セッション(TTY 無し)でリモートの変更を取り込む。経路は [[gh-push]] と同一方針で 決定論的に 選ぶ:
SSH 優先 — remote が SSH URL で、かつ ssh -o BatchMode=yes による非対話 SSH 認証が実際に通るなら、素の git fetch を SSH で実行する。判定は agent の鍵有無ではなく BatchMode=yes での ls-remote が成功するかで直接テストする(agent の鍵・パスフレーズ無しのディスク鍵・macOS キーチェーン鍵を区別せず「非対話で通るか」を確かめられる)。GIT_SSH_COMMAND='ssh -o BatchMode=yes -o ConnectTimeout=5 -o StrictHostKeyChecking=accept-new' を強制し、パスフレーズ入力プロンプトや接続ハングに落ちず即失敗させる。
gh(HTTPS) フォールバック — SSH fetch が失敗した場合、または SSH が使えない(HTTPS remote / 非対話 SSH 認証テストが失敗)場合は、通信認証を gh の credential helper に肩代わりさせて HTTPS で取得する:
git -c credential.helper= -c credential.helper='!gh auth git-credential' fetch <https-url> +refs/heads/<branch>:refs/remotes/<remote>/<branch>
credential.helper=(空)で既存ヘルパー一覧をリセットし gh ヘルパーだけを使う。remote が SSH URL でも URL を HTTPS に変換して取得元に使うので origin の設定は変更しない。public リポジトリならトークン無しでも HTTPS 変換だけで通る(gh helper は private のとき効く)。
「SSH で取得できるか」は ssh -o BatchMode=yes の ls-remote を1回打って直接テストすれば決定論的に判定できる。判定の ls-remote はリモート tip 取得と兼ねるので往復コストは増えない。非対話 SSH が通る環境(ssh-agent 常駐・macOS キーチェーン・パスフレーズ無しのディスク鍵など)では素の fetch がそのまま通るため、余計なトークン経由を挟まない。ssh-add -l(agent の鍵一覧)では、agent が空でもディスク鍵やキーチェーン鍵で非対話認証できるケースを取りこぼすため使わない。
push と違い、取り込みは2段階で危険度が分かれる:
この性質差ゆえ、既定の統合戦略は --ff-only(fast-forward のみ) にしてある。最も多い「ローカルが clean でリモートに追従しているだけ」のケースをコンフリクト無しで取り込み、履歴が分岐している場合は作業ツリーを触らずに明示的に停止して戦略選択をユーザーに委ねる。これは gh-push が diverged で停止するのと同じ思想。
ssh://git@… または git@host:owner/repo)で、ssh -o BatchMode=yes の非対話 SSH 認証が実際に通ること(agent 鍵・パスフレーズ無しのディスク鍵・キーチェーン鍵のいずれでも可)。揃わなければ自動的に gh 経路になる。gh auth status でログイン済み+トークンの read 権限が要る(public は gh 未認証でも HTTPS 変換だけで通る)。ERROR: で停止する。SSH 鍵を非対話で使える状態にするか GitHub CLI を導入する。判定・URL 変換・状態算出・取り込み実行はすべて決定論的なので、git コマンドを手で並べ直さず scripts/gh-fetch.sh を使う。
bash <skill-dir>/scripts/gh-fetch.sh preflight [branch]
=== SECTION === 区切りの出力を読み、取得経路(SSH / gh)・取得元 URL・ブランチ・取り込まれるコミット・作業ツリーの状態をユーザーに提示する。TARGET の route 行で経路と理由、AUTH で非対話 SSH 認証テストの成否と gh 認証が分かる。STATE の incoming の意味:
up-to-date … リモート tip を既に保持。取り込み不要。behind … ローカルがリモートの祖先。FF で安全に取り込める。取り込まれるコミット一覧が出る。diverged … 履歴分岐。FF 不可。pull には --merge / --rebase が要る。ここで停止してユーザーに確認(rebase か merge か、そもそも取り込むか)。fetchable … リモートに新規コミットがあるが未取得で件数不明。fetch すれば確定する。missing-remote … リモートにそのブランチが無い。取り込むものがない。WORKTREE セクションで dirty / clean を確認する。dirty のとき pull は実行できない(fetch は可)。preflight が ERROR: を出したら、その内容(非対話 SSH 認証不可 かつ gh 未導入・未対応 URL・detached HEAD 等)を解決してから進む。実行結果の OK: [ssh] / OK: [gh] でどちらの経路を使ったか分かる。
意図に応じて使い分ける:
fetch のみ(作業ツリーを触らず ref と object だけ更新したいとき。常に安全):
bash <skill-dir>/scripts/gh-fetch.sh fetch [branch]
実行後、未取り込みコミット件数と一覧を出す。
pull(作業ブランチへ統合まで行う):
bash <skill-dir>/scripts/gh-fetch.sh pull [branch] # 既定 = --ff-only
bash <skill-dir>/scripts/gh-fetch.sh pull [branch] --merge # ユーザー承認後のみ
bash <skill-dir>/scripts/gh-fetch.sh pull [branch] --rebase # ユーザー承認後のみ
起動=取り込み意図とみなし、preflight 提示後そのまま実行してよい。ただし:
diverged(FF 不可)で --merge/--rebase を付けるのは、必ずユーザー確認後。既定の --ff-only は分岐時に作業ツリーを触らず安全に失敗する。git rebase --continue / git commit)か中止(--abort)を選べる。--merge / --rebase はユーザーの明示承認が無い限り付けない。既定は --ff-only、分岐検出時は停止が既定。npx claudepluginhub yasunori0418/skills --plugin github-skillsGuides completion of development work by verifying tests, detecting environment, and presenting structured options for merge, PR, or cleanup.
Guides creation and editing of skills using test-driven development with pressure scenarios and subagents to verify agent compliance.
Dispatches multiple subagents concurrently for independent tasks without shared state. Use when facing 2+ unrelated failures or subsystems that can be investigated in parallel.