mcpField
G
github

github

github.com/odyssey4me開発13213 回インストール1 日前に更新
リポジトリ

github について

公式 gh CLI を使って GitHub を操作するスキルです。読み取り結果を Markdown に整形する Python ラッパーを備え、リポジトリ、イシュー、プルリクエスト、Actions をコマンドラインから扱えます。

主な機能

  1. 01gh によるイシューとプルリクエストの管理
  2. 02リポジトリ表示と GitHub コンテンツ検索
  3. 03ワークフローと実行履歴の管理
  4. 04ラッパースクリプトによる読み取り結果の整形
  5. 05gh api と JSON 出力の利用

活用シーン

  1. 01プルリクエストとチェックのレビュー
  2. 02イシューの作成と修正 PR の関連付け
  3. 03CI の監視と失敗ジョブの再実行

インストール

コマンドをコピーしてターミナルで実行します。

$npx skills add https://github.com/odyssey4me/agent-skills --skill github

インストール後、Claude Code で/githubを入力して読み込まれたか確認します。

同梱ファイル

SKILL.md と一緒にインストールされる参考資料やスクリプト。

references/
common-workflows.md
permissions.md
scripts/
github.py

詳細

GitHub スキル

このスキルは、公式の gh CLI ツールを使用して GitHub と連携します。Python ラッパースクリプトは、読み取り/表示操作の出力を Markdown 形式に整えます。アクションコマンド(作成、マージ、クローズ、コメント)には gh を直接使用してください。

ネットワークアクセス

GitHub コマンド(gh と Python ラッパー)を実行するには、GitHub API と認証エンドポイント、または設定された GitHub Enterprise ホストへの送信 HTTPS 接続が必要です。Git のフェッチ/プッシュには、リポジトリホストへの HTTPS または SSH 接続が必要です。リモート操作には送信ネットワークアクセスが必要です。エージェント環境でアクセスが制限されている場合は、最初のリモートコマンドを実行する前に、その環境の承認またはネットワーク制御を通じてアクセスを取得し、すでに許可されている認証を再利用してください。ローカルのヘルプ表示とファイル処理には、ネットワークアクセスは不要です。スキルの指示によってネットワーク権限が付与されることはありません。DNS、接続、タイムアウトの失敗はネットワークエラーとして報告してください。解決のために認証情報をリセットしないでください。承認済みのアクセスでも失敗する場合は、停止して報告してください。認証および権限のエラーにはユーザーの対応が必要です。

スクリプトパスの解決

例にある SKILL_DIR は、読み込まれた SKILL.md が置かれているディレクトリです。 コマンドの実行前に絶対パスを設定してください。エージェントがこのシェル変数を設定すると想定しないでください。スクリプトパスにスペースが含まれる場合は、引用符で囲んでください。

前提条件

gh CLI をインストールする:インストールガイド

認証

# Authenticate with GitHub
gh auth login

# Verify authentication
gh auth status

詳細はGitHub CLI の認証を参照してください。

スクリプトの使い方

ラッパースクリプト(scripts/github.py)は出力を Markdown 形式に整えます。エージェントが利用しやすい出力を得るには、読み取り/表示操作に使用してください。アクションコマンド(作成、マージ、クローズ、コメント)には gh を直接使用してください。各コマンドの読み取り/書き込みの分類については、permissions.mdを参照してください。

# Check gh CLI is installed and authenticated
$SKILL_DIR/scripts/github.py check

# Issues
$SKILL_DIR/scripts/github.py issues list --repo OWNER/REPO
$SKILL_DIR/scripts/github.py issues view 123 --repo OWNER/REPO

# Pull Requests
$SKILL_DIR/scripts/github.py prs list --repo OWNER/REPO
$SKILL_DIR/scripts/github.py prs view 456 --repo OWNER/REPO
$SKILL_DIR/scripts/github.py prs checks 456 --repo OWNER/REPO
$SKILL_DIR/scripts/github.py prs status --repo OWNER/REPO

# Workflow Runs
$SKILL_DIR/scripts/github.py runs list --repo OWNER/REPO
$SKILL_DIR/scripts/github.py runs view 12345 --repo OWNER/REPO

# Repositories
$SKILL_DIR/scripts/github.py repos list
$SKILL_DIR/scripts/github.py repos view OWNER/REPO

# Search
$SKILL_DIR/scripts/github.py search repos "machine learning"
$SKILL_DIR/scripts/github.py search issues "label:bug is:open"
$SKILL_DIR/scripts/github.py search prs "is:open review:required"

一覧表示コマンドでは、すべてのコマンドが --limit N に対応しています(デフォルトは 30)。

コマンド(gh の直接使用)

アクションコマンドには gh を直接使用してください。

Issue
gh issue list                    # List issues
gh issue view 123                # View issue details
gh issue create                  # Create new issue
gh issue comment 123             # Add comment
gh issue close 123               # Close issue
gh issue edit 123 --add-label bug  # Edit issue

詳細なリファレンス:gh issue

プルリクエスト
gh pr list                       # List PRs
gh pr view 456                   # View PR details
gh pr create                     # Create new PR
gh pr review 456 --approve       # Approve PR
gh pr merge 456 --squash         # Merge PR
gh pr checkout 456               # Checkout PR branch
gh pr diff 456                   # View PR diff
gh pr checks 456                 # View CI status

詳細なリファレンス:gh pr

ワークフローと Actions
gh workflow list                 # List workflows
gh workflow run "CI"             # Trigger workflow
gh run list                      # List workflow runs
gh run view 123456               # View run details
gh run watch 123456              # Watch run progress
gh run download 123456           # Download artifacts
gh run rerun 123456 --failed     # Rerun failed jobs

詳細なリファレンス:

リポジトリ
gh repo list                     # List repositories
gh repo view OWNER/REPO          # View repository
gh repo create                   # Create repository
gh repo clone OWNER/REPO         # Clone repository
gh repo fork OWNER/REPO          # Fork repository

詳細なリファレンス:gh repo

検索
gh search repos "machine learning"   # Search repositories
gh search issues "is:open label:bug" # Search issues
gh search prs "is:open"              # Search pull requests
gh search code "function auth"       # Search code

詳細なリファレンス:gh search

使用例

日々の PR レビュー
# Show PRs needing your attention
$SKILL_DIR/scripts/github.py prs status

# Review a specific PR
$SKILL_DIR/scripts/github.py prs view 456
$SKILL_DIR/scripts/github.py prs checks 456
gh pr diff 456
gh pr review 456 --approve

# Verify approval was recorded
$SKILL_DIR/scripts/github.py prs view 456  # check review status
Issue を作成して PR とリンクする
# Create issue
gh issue create --title "Bug: Login fails" --body "Description" --label bug
# Verify: note the issue number from output

# Create PR that fixes it (use issue number from above)
gh pr create --title "Fix login bug (#123)" --body "Fixes #123"
# Verify PR was created and linked
$SKILL_DIR/scripts/github.py prs view <number>
CI パイプラインを監視する
# Watch latest workflow run
gh run watch $(gh run list --limit 1 --json databaseId --jq '.[0].databaseId')

# Check failed runs
gh run list --status failure

# Rerun failed jobs
gh run rerun RUNID --failed
# Verify rerun started
$SKILL_DIR/scripts/github.py runs view RUNID

その他の例はcommon-workflows.mdを参照してください。

高度な使い方

スクリプト用の JSON 出力
# Get specific fields
gh issue list --json number,title,author

# Process with jq
gh pr list --json number,title | jq '.[] | "\(.number): \(.title)"'

# Export to CSV
gh issue list --json number,title,author | jq -r '.[] | @csv'
GitHub API へのアクセス

gh コマンドで対応していない操作の場合:

# Make authenticated API request
gh api repos/OWNER/REPO/issues

# POST request
gh api repos/OWNER/REPO/issues -X POST -f title="Issue" -f body="Text"

# Process response
gh api repos/OWNER/REPO | jq '.stargazers_count'

詳細なリファレンス:gh api

よく使う操作のエイリアス
# Create shortcuts
gh alias set prs 'pr list --author @me'
gh alias set issues 'issue list --assignee @me'
gh alias set review 'pr list --search "review-requested:@me"'

# Use them
gh prs
gh issues
gh review

設定

# View configuration
gh config list

# Set default editor
gh config set editor vim

# Set git protocol
gh config set git_protocol ssh

設定は ~/.config/gh/config.yml に保存されます。

モデルに関するガイダンス

このスキルは公式 CLI をラップしています。高速で軽量なモデルで十分です。

トラブルシューティング

# Check authentication
gh auth status

# Re-authenticate
gh auth login

# Enable debug logging
GH_DEBUG=1 gh issue list

# Check gh version
gh --version

公式ドキュメント

まとめ

GitHub スキルは、公式の gh CLI と Python ラッパーを使用し、読み取り/表示コマンドの出力を Markdown 形式に整えます。

クイックスタート:

  1. インストール:brew install gh(またはお使いの OS に対応する同等の方法)
  2. 認証:gh auth login
  3. 確認:$SKILL_DIR/scripts/github.py check
  4. 読み取り:$SKILL_DIR/scripts/github.py issues list --repo OWNER/REPO
  5. 書き込み:gh issue create、gh pr create など(gh を直接使用)

コマンドの詳細なリファレンスは、gh <command> --help を使用するか、https://cli.github.com/manual/ をご覧ください。

コメント