gh-code-search

GitHub リポジトリからコードを検索し、関連するコードの実装を取得するスキル。 別リポジトリのコードコンテキストが必要な場合に使用。 以下の場面で使用: - APIエンドポイントの実装を確認したい時 - リクエスト/レスポンスの型定義を探したい時 - 関連するバックエンドコードを検索したい時 - フロントエンドのコンポーネント実装を確認したい時 - テストコードを検索したい時 「バックエンド検索」「フロントエンド検索」「API実装確認」「コード検索」「gh search」などでも呼び出し可能。

Safety Notice

This listing is imported from skills.sh public index metadata. Review upstream SKILL.md and repository scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "gh-code-search" with this command: npx skills add 884js/agent-skills/884js-agent-skills-gh-code-search

gh-code-search スキル

GitHub リポジトリからコードを検索し、関連するコードの実装コンテキストを取得するためのスキル。 フロントエンド→バックエンド、バックエンド→フロントエンドの双方向検索に対応。

前提条件

  • gh CLI がインストール済みであること
  • gh auth login で認証済みであること
  • 検索対象リポジトリへの読み取り権限があること

基本的な使い方

1. 認証状態確認

gh auth status

2. コード検索

方法A: search_code.sh スクリプト使用

./scripts/search_code.sh <owner/repo> "<検索クエリ>" [オプション]

# オプション:
#   --language <lang>    言語でフィルタ (例: go, typescript, python)
#   --path <path>        パスでフィルタ
#   --show-content       ファイル内容も表示
#   --limit <n>          結果数制限 (default: 10)
#   --branch <branch>    ブランチ指定 (default: リポジトリのデフォルトブランチ)

方法B: gh コマンド直接使用

# 基本検索(言語指定なし)
gh search code "<クエリ>" --repo owner/repo

# 言語を指定して検索
gh search code "<クエリ>" --repo owner/repo --language go
gh search code "<クエリ>" --repo owner/repo --language typescript

# ファイル内容取得
gh api "repos/owner/repo/contents/path/to/file" --jq '.content' | base64 -d

検索パターン例

キーワード検索

# 単純なキーワード検索
./scripts/search_code.sh myorg/repo "UserService"

# パス絞り込み
./scripts/search_code.sh myorg/repo "handler" --path src/api

関数・クラス定義検索

# 関数定義(言語非依存)
./scripts/search_code.sh myorg/repo "function createUser"
./scripts/search_code.sh myorg/repo "func.*Handler"
./scripts/search_code.sh myorg/repo "def create_user"

# クラス・型定義
./scripts/search_code.sh myorg/repo "class UserService"
./scripts/search_code.sh myorg/repo "interface User"
./scripts/search_code.sh myorg/repo "type User struct"

ユースケース

FE→BE: バックエンドAPI実装確認

フロントエンドからバックエンドのAPI実装を調べる場合:

# エンドポイント検索 (Go/Echo)
./scripts/search_code.sh myorg/backend "e.POST" --language go --path internal/handler

# エンドポイント検索 (Python/FastAPI)
./scripts/search_code.sh myorg/backend "@app.post" --language python

# 型定義検索
./scripts/search_code.sh myorg/backend "type.*Request struct" --language go --show-content

BE→FE: フロントエンド利用箇所確認

バックエンドからフロントエンドでの利用状況を調べる場合:

# API呼び出し箇所検索
./scripts/search_code.sh myorg/frontend "/api/v1/users" --language typescript

# コンポーネント検索
./scripts/search_code.sh myorg/frontend "UserList" --path src/components --show-content

# フック・ユーティリティ検索
./scripts/search_code.sh myorg/frontend "useUser" --language typescript

言語別パターン

Go

# ハンドラー関数
gh search code "func.*Handler" --repo owner/repo --language go

# 構造体定義
gh search code "type User struct" --repo owner/repo --language go

TypeScript / JavaScript

# React コンポーネント
gh search code "export.*function.*Component" --repo owner/repo --language typescript

# API クライアント
gh search code "fetch.*api" --repo owner/repo --language typescript

Python

# FastAPI エンドポイント
gh search code "@app.get|@app.post" --repo owner/repo --language python

# クラス定義
gh search code "class.*Service" --repo owner/repo --language python

ファイル内容の取得

検索で見つかったファイルの全体を取得する場合:

# ファイル内容を取得してデコード
gh api "repos/owner/repo/contents/path/to/file" --jq '.content' | base64 -d

# 特定ブランチのファイル
gh api "repos/owner/repo/contents/path/to/file?ref=develop" --jq '.content' | base64 -d

トラブルシューティング

認証エラー

# 再認証
gh auth login

# 認証状態確認
gh auth status

検索結果が少ない場合

  • クエリを簡略化する
  • 言語フィルタを外す(--language オプションを省略)
  • パスフィルタを広げる

rate limit エラー

# rate limit 確認
gh api rate_limit

少し待ってから再実行してください。

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

Coding

github-activity-report

No summary provided by upstream source.

Repository SourceNeeds Review
Automation

lib-docs-generator

No summary provided by upstream source.

Repository SourceNeeds Review
Automation

qa-level-assessment

No summary provided by upstream source.

Repository SourceNeeds Review