search_history
Query Git commit history to understand changes, debug regressions, and find commit context. Search by keyword, file, or blame.
Instructions
USE THIS TOOL for Git history queries: understanding WHY changes were made, debugging regressions, or finding commit context. This tool operates on the local Git repository.
TRIGGER - Call this tool when the user asks:
"Why was this code changed?" / "Who changed this?"
"When was X introduced?" / "Find commits about X"
"Debug this regression" / "What broke this?"
"Show me the history of this file"
"Who wrote this line?" (blame)
"What changed in commit X?"
This tool does NOT require indexing - it queries Git directly.
WHEN TO USE EACH search_type:
"commits" - USE WHEN:
User asks "find commits about X" or "search commit messages"
Query is a keyword or phrase to search in commit messages
Optionally set target_file to filter commits touching that file
Args: query (required), target_file (optional)
"file_history" - USE WHEN:
User asks "show history of file X" or "what happened to this file?"
Shows commit log for a specific file (follows renames)
target_file is REQUIRED; query is ignored
Args: target_file (required)
"blame" - USE WHEN:
User asks "who wrote this line?" or "who last modified this?"
Shows line-by-line commit attribution
target_file is REQUIRED; optionally limit to line range
Args: target_file (required), line_start/line_end (optional)
"commit_detail" - USE WHEN:
User asks "show me commit X" or "what changed in this commit?"
Query is the commit hash (full or abbreviated)
Optionally set target_file to show only changes to that file
Args: query=commit_hash (required), target_file (optional)
Do NOT use this tool for:
Finding code definitions (use search_code)
Reading documentation (use search_docs)
Non-Git questions
Args: query: Search term for commits, or commit hash for commit_detail. directory: Path to the project directory (git repository). search_type: Must be exactly "commits", "file_history", "blame", or "commit_detail". target_file: File path (required for file_history and blame). line_start/line_end: Line range for blame (optional).
Returns: Varies by search_type. All include status and structured results.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | ||
| line_end | No | ||
| directory | Yes | ||
| line_start | No | ||
| search_type | No | commits | |
| target_file | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |