git-ai-search について
git-ai-search は、Git AI の履歴から AI コーディングの会話を検索し、そのコンテキストを復元するスキルです。コミットやコード範囲に関連するプロンプトを調べ、シェルや Claude で以前のセッションを続けられます。
主な機能
- 01コミット、ファイル、行、トピックでセッション検索
- 02作成者、ツール、日付による絞り込み
- 03プロンプトの全記録を表示
- 04機械可読な結果の出力
- 05作業継続用のコンテキスト復元
- 06復元したコンテキストで Claude を起動
活用シーン
- 01コミットで使われた AI 支援の追跡
- 02特定のコード行に関わるセッションの検索
- 03チームメイトの AI コーディングセッションの再開
- 04プルリクエストでの AI 利用状況の監査
インストール
コマンドをコピーしてターミナルで実行します。
npx skills add https:/ / github.com/ git-ai-project/ git-ai --skill git-ai-searchインストール後、Claude Code で/git-ai-searchを入力して読み込まれたか確認します。
詳細
Git AI 検索スキル
git-ai search と git-ai continue を使って、git の履歴から AI との会話コンテキストを検索し、復元します。
概要
Git AI は、AI が生成したコードと、そのコードを生成した会話を追跡します。このスキルでは、次の操作ができます。
- 検索 - コミット、ファイル、パターン、作成者を指定して AI のプロンプトセッションを見つけます
- 続行 - AI セッションのコンテキストを復元し、前の作業の続きを行います
- 表示 - 特定のプロンプトの全トランスクリプトを表示します
コマンドの使い分け
| 目的 | 使用するコマンド |
|---|---|
| コミットにどのような AI コンテキストがあるか確認する | git-ai search --commit <sha> |
| 特定の行の AI コンテキストを確認する | git-ai search --file <path> --lines <range> |
| AI との会話全体を読む | git-ai search --commit <sha> --verbose |
| 機械可読な出力を取得する | git-ai search --json |
| 特定のトピックに言及しているプロンプトを見つける | git-ai search --pattern "keyword" |
| 他の人の AI セッションを続行する | git-ai continue --commit <sha> |
| コード領域の作業を続行する | git-ai continue --file <path> --lines <range> |
| 復元したコンテキストで Claude を起動する | git-ai continue --commit <sha> --launch |
| 特定のプロンプトのトランスクリプトを表示する | git-ai show-prompt <id> |
ワークフローパターン
1. コミットを調査する
特定のコミットでどのような AI の支援が利用されたかを把握します。
# See a summary of AI sessions in the commit
git-ai search --commit abc1234
# View the full conversations
git-ai search --commit abc1234 --verbose
# Get JSON for programmatic processing
git-ai search --commit abc1234 --json | jq '.prompts | keys[]'
2. コード領域を把握する
特定の行に貢献した AI セッションを見つけます。
# Search by file
git-ai search --file src/main.rs
# Search specific lines
git-ai search --file src/main.rs --lines 100-150
# Multiple line ranges
git-ai search --file src/main.rs --lines 50-75 --lines 200-250
3. 他の人の作業を続行する
チームメイトが中断したところから作業を引き継ぎます。
# See what they were working on
git-ai search --commit abc1234 --verbose
# Restore context and continue in your shell
git-ai continue --commit abc1234
# Or launch directly into Claude Code
git-ai continue --commit abc1234 --launch
# Or copy context to clipboard to paste elsewhere
git-ai continue --commit abc1234 --clipboard
4. プルリクエストをレビューする
PR での AI の関与を把握します。
# Get all commits in the PR
COMMITS=$(gh pr view 123 --json commits -q '.commits[].oid')
# Search each commit
for sha in $COMMITS; do
echo "=== $sha ==="
git-ai search --commit $sha
done
# Or search the full range
BASE=$(gh pr view 123 --json baseRefOid -q '.baseRefOid')
HEAD=$(gh pr view 123 --json headRefOid -q '.headRefOid')
git-ai search --commit $BASE..$HEAD
5. ファイルにおける AI の関与を監査する
ファイルに関与したすべての AI セッションを確認します。
# Full file history
git-ai search --file src/auth/login.rs
# Filter by author
git-ai search --file src/auth/login.rs --author "Alice"
# Filter by tool
git-ai search --file src/auth/login.rs --tool claude
6. トピックで検索する
特定のトピックについて話し合っているプロンプトを見つけます。
# Search prompt content
git-ai search --pattern "authentication"
git-ai search --pattern "error handling"
# Combine with filters
git-ai search --pattern "refactor" --tool cursor
7. 他のツールにパイプする
スクリプトやワークフローに組み込みます。
# Get prompt IDs only
git-ai search --commit abc1234 --porcelain
# Count matches
git-ai search --file src/main.rs --count
# JSON for processing
git-ai search --commit abc1234 --json | jq '.prompts[] | {tool, model, author: .human_author}'
# Find commits with AI-authored code
git log --oneline | while read sha msg; do
count=$(git-ai search --commit $sha --count 2>/dev/null || echo "0")
if [ "$count" != "0" ]; then
echo "$sha ($count sessions): $msg"
fi
done
コマンドリファレンス
git-ai search
さまざまな条件で AI プロンプトセッションを検索します。
git-ai search [OPTIONS]
コンテキストソース(いずれか1つを選択):
--commit <rev>- 特定のコミットを検索します(sha1..sha2で範囲を指定できます)--file <path>- ファイルパスで検索します--lines <range>- 行範囲で絞り込みます(--fileが必要です。複数回指定できます)--pattern <text>- プロンプトの内容を全文検索します--prompt-id <id>- ID を指定して特定のプロンプトを検索します
フィルター(組み合わせ可能):
--author <name>- 人間の作成者で絞り込みます(部分一致)--tool <name>- ツールで絞り込みます(claude、cursor など)--since <date>- 指定した日付より後のプロンプトのみを対象にします--until <date>- 指定した日付より前のプロンプトのみを対象にします
出力形式(いずれか1つを選択):
- (デフォルト) - 人が読みやすい形式の概要
--json- 完全な JSON 出力--verbose- 全トランスクリプトを含む詳細な出力--porcelain- 機械可読形式でプロンプト ID のみを出力--count- 条件に一致するプロンプトの件数のみを出力
git-ai continue
AI セッションのコンテキストを復元して続行します。
git-ai continue [OPTIONS]
コンテキストソース(いずれか1つを選択。TUI の場合は指定不要):
--commit <rev>- コミットから続行します--file <path>- ファイルから続行します--lines <range>- 行範囲に限定します(--fileと併用)--prompt-id <id>- 特定のプロンプトから続行します
エージェントの選択:
--agent <name>- 対象のエージェント(claude、cursor。デフォルト:claude)--tool <name>---agentのエイリアス
出力モード(いずれか1つを選択):
- (デフォルト) - 書式設定済みのコンテキストを標準出力に出力します
--launch- コンテキストを渡してエージェントの CLI を起動します--clipboard- コンテキストをクリップボードにコピーします--json- 構造化 JSON 形式で出力します
オプション:
--max-messages <n>- プロンプトごとのメッセージ数を制限します(デフォルト:50)
git-ai show-prompt
特定のプロンプトの全トランスクリプトを表示します。
git-ai show-prompt <prompt_id> [OPTIONS]
--json- JSON 形式で出力します--raw- 内部形式のまま表示します
出力形式
デフォルト出力
人が読みやすい形式の概要:
Found 2 AI prompt session(s) for commit abc1234
[1] Prompt a1b2c3d4 (claude / claude-sonnet-4)
Author: Alice
Files: src/main.rs:10-50
[2] Prompt e5f6g7h8 (cursor / gpt-4)
Author: Bob
Files: src/lib.rs:100-150, src/utils.rs:20-30
--json 出力
プログラムで使用するための、完全な構造化データ:
{
"source": {
"sha": "abc1234",
"author": "Alice",
"date": "2025-01-15",
"message": "Add authentication"
},
"prompts": [
{
"id": "a1b2c3d4",
"tool": "claude",
"model": "claude-sonnet-4",
"author": "Alice",
"messages": [...]
}
]
}
--verbose 出力
会話全体をインラインで表示します。
=== Session 1: Prompt a1b2c3d4 ===
Tool: claude (claude-sonnet-4)
Author: Alice
**User**:
Help me implement user authentication...
**Assistant**:
I'll help you implement authentication. Here's my approach...
--porcelain 出力
1 行につきプロンプト ID を1つ出力します(スクリプト向け)。
a1b2c3d4
e5f6g7h8
--count 出力
件数のみを出力します。
2
ヒント
フィルターの組み合わせ
フィルターは AND セマンティクスを使用します。プロンプトは指定されたすべてのフィルターに一致する必要があります。
# Claude prompts by Alice in the last 7 days
git-ai search --commit HEAD~10..HEAD --tool claude --author "Alice" --since 7d
Git コマンドとの併用
git log と組み合わせて履歴を調べます。
# Find commits with high AI involvement
git log --oneline --since="1 week ago" | while read sha msg; do
git-ai search --commit $sha --count 2>/dev/null
done
# Search AI context for files changed in a commit
git diff-tree --no-commit-id --name-only -r abc1234 | while read file; do
git-ai search --file "$file"
done
異なるエージェント向けのコンテキストの復元
--agent フラグでコンテキストのフォーマットを制御します。
# For Claude Code
git-ai continue --commit abc1234 --agent claude --launch
# For other tools, copy to clipboard
git-ai continue --commit abc1234 --clipboard
特定のプロンプトの調査
検索結果が多い場合は、さらに詳しく調べます。
# Get the IDs
git-ai search --commit abc1234 --porcelain
# View a specific one
git-ai show-prompt a1b2c3d4
パフォーマンスに関するヒント
- 最速の結果を得るには、
--commitを使用します(ノートを直接検索します) --fileでは blame の計算が必要です(大きなファイルでは時間がかかります)--patternではデータベースを検索します(部分文字列の一致を高速に検索します)- 詳細な出力を表示する前に
--countを追加し、結果の件数を確認します
使用例
簡単な確認
# Any AI in this commit?
git-ai search --commit HEAD --count
# What tools were used?
git-ai search --commit abc1234 --json | jq '.prompts[].tool' | sort -u
# Who used AI in this file?
git-ai search --file src/main.rs --json | jq '.prompts[].author' | sort -u
詳細な調査
# Full context of the most recent AI session
git-ai search --commit HEAD --verbose | head -100
# Continue the exact session that wrote these lines
git-ai continue --file src/main.rs --lines 50-100 --launch
CI/CD との統合
# In a PR check, report AI involvement
PROMPT_COUNT=$(git-ai search --commit $PR_HEAD --count 2>/dev/null || echo "0")
if [ "$PROMPT_COUNT" -gt 0 ]; then
echo "This PR includes $PROMPT_COUNT AI-assisted session(s)"
git-ai search --commit $PR_HEAD
fi