Loading...
Loading...
Search and restore AI conversation context from git history
npx skill4agent add git-ai-project/git-ai git-ai-searchgit-ai searchgit-ai continue| 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 | |
# 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[]'# 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# 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# 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# 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# Search prompt content
git-ai search --pattern "authentication"
git-ai search --pattern "error handling"
# Combine with filters
git-ai search --pattern "refactor" --tool cursor# 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
donegit-ai search [OPTIONS]--commit <rev>sha1..sha2--file <path>--lines <range>--pattern <text>--prompt-id <id>--author <name>--tool <name>--since <date>--until <date>--json--verbose--porcelain--countgit-ai continue [OPTIONS]--commit <rev>--file <path>--lines <range>--prompt-id <id>--agent <name>--tool <name>--launch--clipboard--json--max-messages <n>git-ai show-prompt <prompt_id> [OPTIONS]--json--rawFound 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{
"source": {
"sha": "abc1234",
"author": "Alice",
"date": "2025-01-15",
"message": "Add authentication"
},
"prompts": [
{
"id": "a1b2c3d4",
"tool": "claude",
"model": "claude-sonnet-4",
"author": "Alice",
"messages": [...]
}
]
}=== 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...a1b2c3d4
e5f6g7h82# Claude prompts by Alice in the last 7 days
git-ai search --commit HEAD~10..HEAD --tool claude --author "Alice" --since 7d# 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--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# 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