git-prism
Agent-optimized git data for LLM agents. Three MCP tools that replace human-oriented diffs with structured JSON -- function-level granularity, import tracking, dependency changes, complete file snapshots, and per-commit history.
The Problem
Git's porcelain output (diff, log, --stat) is designed for human eyes. When
an LLM agent parses a unified diff, it burns tokens on @@ hunk headers, +/-
line prefixes, and whitespace context that carries no semantic meaning. Worse, it
has to reconstruct what actually changed -- which functions were modified, which
imports were added, whether the file is generated -- from raw text.
git-prism gives agents structured data directly: a change manifest with per-file metadata and function-level analysis, plus full before/after file content when deeper inspection is needed.
Installation
From crates.io (recommended)
From source
Binary download
Grab a prebuilt binary from the GitHub Releases page.
Homebrew (macOS and Linux)
MCP Registration
Register git-prism as an MCP server for Claude Code:
That's it. The server uses stdio transport and is available in all Claude Code sessions.
Tools
get_change_manifest
Returns structured metadata about what changed between two git refs.
Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
base_ref |
string | (required) | Base git ref (commit SHA, branch, tag, HEAD~1) |
head_ref |
string | "HEAD" |
Head git ref |
repo_path |
string | cwd | Path to the git repository |
include_patterns |
string[] | [] |
Glob patterns to include (e.g. ["*.rs", "*.go"]) |
exclude_patterns |
string[] | [] |
Glob patterns to exclude (e.g. ["*.lock"]) |
include_function_analysis |
bool | true |
Enable tree-sitter function/import analysis |
Example output:
get_file_snapshots
Returns complete before/after file content at two git refs. No diffs to parse -- the agent gets the full file at each point in time.
Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
base_ref |
string | (required) | Base git ref |
head_ref |
string | "HEAD" |
Head git ref |
paths |
string[] | (required) | File paths to snapshot (max 20) |
repo_path |
string | cwd | Path to the git repository |
include_before |
bool | true |
Include file content at base ref |
include_after |
bool | true |
Include file content at head ref |
max_file_size_bytes |
int | 100000 |
Truncate files larger than this |
line_range |
[int, int] | null |
Return only lines in this range (1-indexed) |
Example output:
get_commit_history
Returns one manifest per commit in a range, so agents can see what changed in each commit separately instead of a single collapsed diff.
Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
base_ref |
string | (required) | Base git ref (exclusive -- commits after this) |
head_ref |
string | (required) | Head git ref (inclusive) |
repo_path |
string | cwd | Path to the git repository |
Example output:
CLI Usage
git-prism also works as a standalone CLI for scripting and debugging:
# Change manifest between two refs
# Manifest for a specific repo path
# Per-commit history for a range
# File snapshots for specific paths
# List supported languages
The manifest, snapshot, and history commands output JSON to stdout. The
languages command outputs plain text.
Agent Workflow
The typical agent pattern is two calls -- triage, then deep dive:
Step 1: Triage with get_change_manifest
Ask for the manifest to understand the shape of a change. The summary tells you file counts, line counts, and affected languages. The per-file entries tell you which functions changed signatures, which imports were added, and whether files are generated (safe to skip).
Step 2: Deep dive with get_file_snapshots
Once you know which files matter, request full snapshots of just those files.
You get complete before/after content -- no reconstructing files from diff hunks.
Use line_range to focus on specific sections and include_before: false when
you only need the current state.
This two-step approach keeps token usage low. The manifest is compact metadata; snapshots are requested only for files that need inspection.
Supported Languages
Function-level analysis uses tree-sitter to extract functions, methods, and imports from source code.
| Language | Extensions | Extracts |
|---|---|---|
| C | .c, .h |
functions, declarations, #include directives |
| C++ | .cpp, .hpp |
class/namespace-qualified methods, functions, #include directives |
| Go | .go |
functions, methods, imports |
| Java | .java |
methods, constructors, imports |
| JavaScript | .js, .jsx |
functions, arrow functions, methods, imports |
| Python | .py |
functions, methods, imports |
| Rust | .rs |
functions, methods, use statements |
| TypeScript | .ts, .tsx |
functions, arrow functions, methods, imports |
Files in unsupported languages still appear in the manifest with full
line/size/change-type metadata -- functions_changed is null (not an empty
array) to distinguish "no grammar available" from "analyzed, nothing changed."
Dependency File Tracking
git-prism parses dependency files and reports added, removed, and version-changed packages:
Cargo.toml(Rust)package.json(Node.js)go.mod(Go)pyproject.toml(Python, PEP 621)
Contributing
See CONTRIBUTING.md.