git-ai-search
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseGit AI Search Skill
Git AI Search Skill
Search and restore AI conversation context from git history using and .
git-ai searchgit-ai continue使用和从Git历史记录中搜索并恢复AI对话上下文。
git-ai searchgit-ai continueOverview
概述
Git AI tracks AI-generated code and the conversations that produced it. This skill helps you:
- Search - Find AI prompt sessions by commit, file, pattern, or author
- Continue - Restore AI session context to continue work where someone left off
- Show - View the full transcript of a specific prompt
Git AI 会追踪AI生成的代码及其对应的对话过程。本Skill可帮助你:
- 搜索 - 通过提交记录、文件、关键词或作者查找AI提示会话
- 续接 - 恢复AI会话上下文,在他人中断的地方继续工作
- 查看 - 查看特定提示的完整对话记录
When to Use Each Command
各命令适用场景
| You want to... | Use... |
|---|---|
| See what AI context exists for a commit | |
| See AI context for specific lines | |
| Read the full AI conversation | |
| Get machine-readable output | |
| Find prompts mentioning a topic | |
| Continue someone's AI session | |
| Continue working on a code region | |
| Launch Claude with restored context | |
| View a specific prompt transcript | |
| 你想要... | 使用... |
|---|---|
| 查看某提交记录中的AI上下文 | |
| 查看特定代码行的AI上下文 | |
| 阅读完整的AI对话内容 | |
| 获取机器可读格式的输出 | |
| 查找提及特定主题的提示 | |
| 续接他人的AI会话 | |
| 针对某代码区域继续工作 | |
| 加载恢复后的上下文启动Claude | |
| 查看特定提示的完整对话记录 | |
Workflow Patterns
工作流模式
1. Investigate a Commit
1. 调查提交记录
Understand what AI assistance was used in a specific commit:
bash
undefined了解某特定提交记录中使用了哪些AI辅助:
bash
undefinedSee a summary of AI sessions in the commit
查看该提交记录中AI会话的摘要
git-ai search --commit abc1234
git-ai search --commit abc1234
View the full conversations
查看完整对话内容
git-ai search --commit abc1234 --verbose
git-ai search --commit abc1234 --verbose
Get JSON for programmatic processing
获取JSON格式输出用于程序化处理
git-ai search --commit abc1234 --json | jq '.prompts | keys[]'
undefinedgit-ai search --commit abc1234 --json | jq '.prompts | keys[]'
undefined2. Understand a Code Region
2. 理解代码区域
Find what AI sessions contributed to specific lines:
bash
undefined查找哪些AI会话贡献了特定代码行:
bash
undefinedSearch by file
按文件搜索
git-ai search --file src/main.rs
git-ai search --file src/main.rs
Search specific lines
搜索特定代码行
git-ai search --file src/main.rs --lines 100-150
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
undefinedgit-ai search --file src/main.rs --lines 50-75 --lines 200-250
undefined3. Continue Someone's Work
3. 续接他人工作
Pick up where a teammate left off:
bash
undefined接手队友未完成的工作:
bash
undefinedSee what they were working on
查看他们之前的工作内容
git-ai search --commit abc1234 --verbose
git-ai search --commit abc1234 --verbose
Restore context and continue in your shell
恢复上下文并在你的Shell中继续
git-ai continue --commit abc1234
git-ai continue --commit abc1234
Or launch directly into Claude Code
或直接启动Claude Code
git-ai continue --commit abc1234 --launch
git-ai continue --commit abc1234 --launch
Or copy context to clipboard to paste elsewhere
或复制上下文到剪贴板以便在其他地方粘贴
git-ai continue --commit abc1234 --clipboard
undefinedgit-ai continue --commit abc1234 --clipboard
undefined4. Review a Pull Request
4. 审查拉取请求(PR)
Understand AI involvement in a PR:
bash
undefined了解PR中AI的参与情况:
bash
undefinedGet all commits in the PR
获取PR中的所有提交记录
COMMITS=$(gh pr view 123 --json commits -q '.commits[].oid')
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
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
undefinedBASE=$(gh pr view 123 --json baseRefOid -q '.baseRefOid')
HEAD=$(gh pr view 123 --json headRefOid -q '.headRefOid')
git-ai search --commit $BASE..$HEAD
undefined5. Audit AI Involvement in a File
5. 审计文件中的AI参与情况
See all AI sessions that touched a file:
bash
undefined查看所有涉及某文件的AI会话:
bash
undefinedFull file history
完整文件历史
git-ai search --file src/auth/login.rs
git-ai search --file src/auth/login.rs
Filter by author
按作者过滤
git-ai search --file src/auth/login.rs --author "Alice"
git-ai search --file src/auth/login.rs --author "Alice"
Filter by tool
按工具过滤
git-ai search --file src/auth/login.rs --tool claude
undefinedgit-ai search --file src/auth/login.rs --tool claude
undefined6. Search by Topic
6. 按主题搜索
Find prompts discussing specific topics:
bash
undefined查找讨论特定主题的提示:
bash
undefinedSearch prompt content
搜索提示内容
git-ai search --pattern "authentication"
git-ai search --pattern "error handling"
git-ai search --pattern "authentication"
git-ai search --pattern "error handling"
Combine with filters
结合过滤条件
git-ai search --pattern "refactor" --tool cursor
undefinedgit-ai search --pattern "refactor" --tool cursor
undefined7. Pipe to Other Tools
7. 与其他工具配合使用
Integrate with scripts and workflows:
bash
undefined与脚本和工作流集成:
bash
undefinedGet prompt IDs only
仅获取提示ID
git-ai search --commit abc1234 --porcelain
git-ai search --commit abc1234 --porcelain
Count matches
统计匹配数量
git-ai search --file src/main.rs --count
git-ai search --file src/main.rs --count
JSON for processing
获取JSON格式用于处理
git-ai search --commit abc1234 --json | jq '.prompts[] | {tool, model, author: .human_author}'
git-ai search --commit abc1234 --json | jq '.prompts[] | {tool, model, author: .human_author}'
Find commits with AI-authored code
查找包含AI生成代码的提交记录
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
undefinedgit 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
undefinedCommand Reference
命令参考
git-ai search
git-ai search
Search for AI prompt sessions by various criteria.
git-ai search [OPTIONS]Context Source (pick one):
- - Search a specific commit (or range with
--commit <rev>)sha1..sha2 - - Search by file path
--file <path> - - Filter to line range (requires --file, repeatable)
--lines <range> - - Full-text search in prompt content
--pattern <text> - - Look up specific prompt by ID
--prompt-id <id>
Filters (combinable):
- - Filter by human author (substring match)
--author <name> - - Filter by tool (claude, cursor, etc.)
--tool <name> - - Only prompts after date
--since <date> - - Only prompts before date
--until <date>
Output Format (pick one):
- (default) - Human-readable summary
- - Full JSON output
--json - - Detailed output with full transcripts
--verbose - - Machine-readable prompt IDs only
--porcelain - - Just the count of matching prompts
--count
根据多种条件搜索AI提示会话。
git-ai search [OPTIONS]上下文来源(选其一):
- - 搜索特定提交记录(或使用
--commit <rev>指定范围)sha1..sha2 - - 按文件路径搜索
--file <path> - - 过滤到指定代码行范围(需配合--file使用,可重复)
--lines <range> - - 对提示内容进行全文搜索
--pattern <text> - - 通过ID查找特定提示
--prompt-id <id>
过滤条件(可组合):
- - 按人类作者过滤(子字符串匹配)
--author <name> - - 按工具过滤(claude、cursor等)
--tool <name> - - 仅搜索指定日期之后的提示
--since <date> - - 仅搜索指定日期之前的提示
--until <date>
输出格式(选其一):
- 默认 - 人类可读的摘要格式
- - 完整JSON格式输出
--json - - 包含完整对话记录的详细输出
--verbose - - 仅输出机器可读的提示ID
--porcelain - - 仅输出匹配提示的数量
--count
git-ai continue
git-ai continue
Restore AI session context for continuation.
git-ai continue [OPTIONS]Context Source (pick one, or none for TUI):
- - Continue from a commit
--commit <rev> - - Continue from a file
--file <path> - - Limit to line range (with --file)
--lines <range> - - Continue specific prompt
--prompt-id <id>
Agent Selection:
- - Target agent (claude, cursor; default: claude)
--agent <name> - - Alias for --agent
--tool <name>
Output Mode (pick one):
- (default) - Print formatted context to stdout
- - Spawn agent CLI with context
--launch - - Copy context to clipboard
--clipboard - - Output as structured JSON
--json
Options:
- - Limit messages per prompt (default: 50)
--max-messages <n>
恢复AI会话上下文以便续接工作。
git-ai continue [OPTIONS]上下文来源(选其一,或留空使用TUI):
- - 从某提交记录续接
--commit <rev> - - 从某文件续接
--file <path> - - 限制到指定代码行范围(需配合--file)
--lines <range> - - 续接特定提示
--prompt-id <id>
Agent选择:
- - 目标Agent(claude、cursor;默认:claude)
--agent <name> - - --agent的别名
--tool <name>
输出模式(选其一):
- 默认 - 将格式化后的上下文输出到标准输出
- - 启动Agent CLI并加载上下文
--launch - - 将上下文复制到剪贴板
--clipboard - - 以结构化JSON格式输出
--json
选项:
- - 限制每个提示的消息数量(默认:50)
--max-messages <n>
git-ai show-prompt
git-ai show-prompt
Display the full transcript of a specific prompt.
git-ai show-prompt <prompt_id> [OPTIONS]- - Output as JSON
--json - - Show raw internal format
--raw
显示特定提示的完整对话记录。
git-ai show-prompt <prompt_id> [OPTIONS]- - 以JSON格式输出
--json - - 显示原始内部格式
--raw
Output Formats
输出格式
Default Output
默认输出
Human-readable summary:
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人类可读的摘要:
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 Output
--json输出
Full structured data for programmatic use:
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": [...]
}
]
}用于程序化处理的完整结构化数据:
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 Output
--verbose输出
Full conversations inline:
=== 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...内嵌完整对话内容:
=== 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 Output
--porcelain输出
One prompt ID per line (for scripting):
a1b2c3d4
e5f6g7h8每行一个提示ID(用于脚本):
a1b2c3d4
e5f6g7h8--count Output
--count输出
Just the number:
2仅输出数字:
2Tips
技巧
Combining Filters
组合过滤条件
Filters use AND semantics - prompts must match ALL specified filters:
bash
undefined过滤条件使用AND语义 - 提示必须匹配所有指定的过滤条件:
bash
undefinedClaude prompts by Alice in the last 7 days
过去7天内Alice使用Claude的提示
git-ai search --commit HEAD~10..HEAD --tool claude --author "Alice" --since 7d
undefinedgit-ai search --commit HEAD~10..HEAD --tool claude --author "Alice" --since 7d
undefinedUsing with Git Commands
与Git命令配合使用
Combine with git log to explore history:
bash
undefined与git log结合探索历史:
bash
undefinedFind commits with high AI involvement
查找AI参与度高的提交记录
git log --oneline --since="1 week ago" | while read sha msg; do
git-ai search --commit $sha --count 2>/dev/null
done
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
搜索提交记录中修改文件的AI上下文
git diff-tree --no-commit-id --name-only -r abc1234 | while read file; do
git-ai search --file "$file"
done
undefinedgit diff-tree --no-commit-id --name-only -r abc1234 | while read file; do
git-ai search --file "$file"
done
undefinedRestoring Context for Different Agents
为不同Agent恢复上下文
The flag controls context formatting:
--agentbash
undefined--agentbash
undefinedFor Claude Code
针对Claude Code
git-ai continue --commit abc1234 --agent claude --launch
git-ai continue --commit abc1234 --agent claude --launch
For other tools, copy to clipboard
针对其他工具,复制到剪贴板
git-ai continue --commit abc1234 --clipboard
undefinedgit-ai continue --commit abc1234 --clipboard
undefinedInspecting Specific Prompts
检查特定提示
If search returns many results, drill down:
bash
undefined如果搜索返回大量结果,可深入查看:
bash
undefinedGet the IDs
获取ID
git-ai search --commit abc1234 --porcelain
git-ai search --commit abc1234 --porcelain
View a specific one
查看特定提示
git-ai show-prompt a1b2c3d4
undefinedgit-ai show-prompt a1b2c3d4
undefinedPerformance Tips
性能技巧
- Use for fastest results (direct note lookup)
--commit - requires blame computation (slower for large files)
--file - searches the database (fast substring match)
--pattern - Add first to check result size before verbose output
--count
- 使用可获得最快结果(直接查找记录)
--commit - 需要计算blame(大文件会较慢)
--file - 搜索数据库(快速子字符串匹配)
--pattern - 先使用检查结果数量,再使用详细输出
--count
Examples
示例
Quick checks
快速检查
bash
undefinedbash
undefinedAny AI in this commit?
此提交记录中是否有AI内容?
git-ai search --commit HEAD --count
git-ai search --commit HEAD --count
What tools were used?
使用了哪些工具?
git-ai search --commit abc1234 --json | jq '.prompts[].tool' | sort -u
git-ai search --commit abc1234 --json | jq '.prompts[].tool' | sort -u
Who used AI in this file?
谁在该文件中使用了AI?
git-ai search --file src/main.rs --json | jq '.prompts[].author' | sort -u
undefinedgit-ai search --file src/main.rs --json | jq '.prompts[].author' | sort -u
undefinedDetailed exploration
详细探索
bash
undefinedbash
undefinedFull context of the most recent AI session
最近一次AI会话的完整上下文
git-ai search --commit HEAD --verbose | head -100
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
undefinedgit-ai continue --file src/main.rs --lines 50-100 --launch
undefinedIntegration with CI/CD
与CI/CD集成
bash
undefinedbash
undefinedIn a PR check, report AI involvement
在PR检查中报告AI参与情况
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
undefinedPROMPT_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
undefined