git-ai-search

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Git AI Search Skill

Git AI Search Skill

Search and restore AI conversation context from git history using
git-ai search
and
git-ai continue
.
使用
git-ai search
git-ai continue
从Git历史记录中搜索并恢复AI对话上下文。

Overview

概述

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
git-ai search --commit <sha>
See AI context for specific lines
git-ai search --file <path> --lines <range>
Read the full AI conversation
git-ai search --commit <sha> --verbose
Get machine-readable output
git-ai search --json
Find prompts mentioning a topic
git-ai search --pattern "keyword"
Continue someone's AI session
git-ai continue --commit <sha>
Continue working on a code region
git-ai continue --file <path> --lines <range>
Launch Claude with restored context
git-ai continue --commit <sha> --launch
View a specific prompt transcript
git-ai show-prompt <id>
你想要...使用...
查看某提交记录中的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>

Workflow Patterns

工作流模式

1. Investigate a Commit

1. 调查提交记录

Understand what AI assistance was used in a specific commit:
bash
undefined
了解某特定提交记录中使用了哪些AI辅助:
bash
undefined

See 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[]'
undefined
git-ai search --commit abc1234 --json | jq '.prompts | keys[]'
undefined

2. Understand a Code Region

2. 理解代码区域

Find what AI sessions contributed to specific lines:
bash
undefined
查找哪些AI会话贡献了特定代码行:
bash
undefined

Search 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
undefined
git-ai search --file src/main.rs --lines 50-75 --lines 200-250
undefined

3. Continue Someone's Work

3. 续接他人工作

Pick up where a teammate left off:
bash
undefined
接手队友未完成的工作:
bash
undefined

See 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
undefined
git-ai continue --commit abc1234 --clipboard
undefined

4. Review a Pull Request

4. 审查拉取请求(PR)

Understand AI involvement in a PR:
bash
undefined
了解PR中AI的参与情况:
bash
undefined

Get 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
undefined
BASE=$(gh pr view 123 --json baseRefOid -q '.baseRefOid') HEAD=$(gh pr view 123 --json headRefOid -q '.headRefOid') git-ai search --commit $BASE..$HEAD
undefined

5. Audit AI Involvement in a File

5. 审计文件中的AI参与情况

See all AI sessions that touched a file:
bash
undefined
查看所有涉及某文件的AI会话:
bash
undefined

Full 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
undefined
git-ai search --file src/auth/login.rs --tool claude
undefined

6. Search by Topic

6. 按主题搜索

Find prompts discussing specific topics:
bash
undefined
查找讨论特定主题的提示:
bash
undefined

Search 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
undefined
git-ai search --pattern "refactor" --tool cursor
undefined

7. Pipe to Other Tools

7. 与其他工具配合使用

Integrate with scripts and workflows:
bash
undefined
与脚本和工作流集成:
bash
undefined

Get 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
undefined
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
undefined

Command Reference

命令参考

git-ai search

git-ai search

Search for AI prompt sessions by various criteria.
git-ai search [OPTIONS]
Context Source (pick one):
  • --commit <rev>
    - Search a specific commit (or range with
    sha1..sha2
    )
  • --file <path>
    - Search by file path
  • --lines <range>
    - Filter to line range (requires --file, repeatable)
  • --pattern <text>
    - Full-text search in prompt content
  • --prompt-id <id>
    - Look up specific prompt by ID
Filters (combinable):
  • --author <name>
    - Filter by human author (substring match)
  • --tool <name>
    - Filter by tool (claude, cursor, etc.)
  • --since <date>
    - Only prompts after date
  • --until <date>
    - Only prompts before date
Output Format (pick one):
  • (default) - Human-readable summary
  • --json
    - Full JSON output
  • --verbose
    - Detailed output with full transcripts
  • --porcelain
    - Machine-readable prompt IDs only
  • --count
    - Just the count of matching prompts
根据多种条件搜索AI提示会话。
git-ai search [OPTIONS]
上下文来源(选其一):
  • --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>
    - 仅搜索指定日期之前的提示
输出格式(选其一):
  • 默认 - 人类可读的摘要格式
  • --json
    - 完整JSON格式输出
  • --verbose
    - 包含完整对话记录的详细输出
  • --porcelain
    - 仅输出机器可读的提示ID
  • --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):
  • --commit <rev>
    - Continue from a commit
  • --file <path>
    - Continue from a file
  • --lines <range>
    - Limit to line range (with --file)
  • --prompt-id <id>
    - Continue specific prompt
Agent Selection:
  • --agent <name>
    - Target agent (claude, cursor; default: claude)
  • --tool <name>
    - Alias for --agent
Output Mode (pick one):
  • (default) - Print formatted context to stdout
  • --launch
    - Spawn agent CLI with context
  • --clipboard
    - Copy context to clipboard
  • --json
    - Output as structured JSON
Options:
  • --max-messages <n>
    - Limit messages per prompt (default: 50)
恢复AI会话上下文以便续接工作。
git-ai continue [OPTIONS]
上下文来源(选其一,或留空使用TUI):
  • --commit <rev>
    - 从某提交记录续接
  • --file <path>
    - 从某文件续接
  • --lines <range>
    - 限制到指定代码行范围(需配合--file)
  • --prompt-id <id>
    - 续接特定提示
Agent选择:
  • --agent <name>
    - 目标Agent(claude、cursor;默认:claude)
  • --tool <name>
    - --agent的别名
输出模式(选其一):
  • 默认 - 将格式化后的上下文输出到标准输出
  • --launch
    - 启动Agent CLI并加载上下文
  • --clipboard
    - 将上下文复制到剪贴板
  • --json
    - 以结构化JSON格式输出
选项:
  • --max-messages <n>
    - 限制每个提示的消息数量(默认:50)

git-ai show-prompt

git-ai show-prompt

Display the full transcript of a specific prompt.
git-ai show-prompt <prompt_id> [OPTIONS]
  • --json
    - Output as JSON
  • --raw
    - Show raw internal format
显示特定提示的完整对话记录。
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
仅输出数字:
2

Tips

技巧

Combining Filters

组合过滤条件

Filters use AND semantics - prompts must match ALL specified filters:
bash
undefined
过滤条件使用AND语义 - 提示必须匹配所有指定的过滤条件:
bash
undefined

Claude prompts by Alice in the last 7 days

过去7天内Alice使用Claude的提示

git-ai search --commit HEAD~10..HEAD --tool claude --author "Alice" --since 7d
undefined
git-ai search --commit HEAD~10..HEAD --tool claude --author "Alice" --since 7d
undefined

Using with Git Commands

与Git命令配合使用

Combine with git log to explore history:
bash
undefined
与git log结合探索历史:
bash
undefined

Find 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
undefined
git diff-tree --no-commit-id --name-only -r abc1234 | while read file; do git-ai search --file "$file" done
undefined

Restoring Context for Different Agents

为不同Agent恢复上下文

The
--agent
flag controls context formatting:
bash
undefined
--agent
标志控制上下文格式:
bash
undefined

For 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
undefined
git-ai continue --commit abc1234 --clipboard
undefined

Inspecting Specific Prompts

检查特定提示

If search returns many results, drill down:
bash
undefined
如果搜索返回大量结果,可深入查看:
bash
undefined

Get the IDs

获取ID

git-ai search --commit abc1234 --porcelain
git-ai search --commit abc1234 --porcelain

View a specific one

查看特定提示

git-ai show-prompt a1b2c3d4
undefined
git-ai show-prompt a1b2c3d4
undefined

Performance Tips

性能技巧

  • Use
    --commit
    for fastest results (direct note lookup)
  • --file
    requires blame computation (slower for large files)
  • --pattern
    searches the database (fast substring match)
  • Add
    --count
    first to check result size before verbose output
  • 使用
    --commit
    可获得最快结果(直接查找记录)
  • --file
    需要计算blame(大文件会较慢)
  • --pattern
    搜索数据库(快速子字符串匹配)
  • 先使用
    --count
    检查结果数量,再使用详细输出

Examples

示例

Quick checks

快速检查

bash
undefined
bash
undefined

Any 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
undefined
git-ai search --file src/main.rs --json | jq '.prompts[].author' | sort -u
undefined

Detailed exploration

详细探索

bash
undefined
bash
undefined

Full 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
undefined
git-ai continue --file src/main.rs --lines 50-100 --launch
undefined

Integration with CI/CD

与CI/CD集成

bash
undefined
bash
undefined

In 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
undefined
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
undefined