Compact git diff as structured JSON. Strips context padding by default, outputting only changed lines grouped by file. Cuts diff token cost by 60-80% compared to raw git diff output.
Works as both an MCP tool and a standalone CLI.
go build -o cleanDiff
sudo cp cleanDiff /usr/local/bin/
codesign -s - /usr/local/bin/cleanDiffOr with just:
just installcleanDiff --cli --ref HEAD~1
cleanDiff --cli --staged --stat-only
cleanDiff --cli --path /some/repo --ref main..feature --context 3
cleanDiff --cli --files main.go,util.goRegister as an MCP server:
claude mcp add --transport stdio --scope user cleanDiff -- cleanDiff| Param | Type | Description |
|---|---|---|
path |
string | Repo path (default: cwd) |
ref |
string | Git ref/range (HEAD~1, main..HEAD, etc.) |
staged |
bool | Show staged changes (--cached) |
stat_only |
bool | File stats only, no line content |
file_filter |
array | Restrict to specific files |
context_lines |
int | Context lines (default 0) |
{
"summary": {"files_changed": 3, "insertions": 15, "deletions": 8},
"files": [
{
"path": "main.go",
"status": "modified",
"insertions": 5,
"deletions": 2,
"hunks": [
{
"old_start": 10,
"old_count": 3,
"new_start": 10,
"new_count": 4,
"added": ["new line 1", "new line 2"],
"removed": ["old line"]
}
]
}
]
}MIT