git diff
built-in -1.4% Savings
749 Commands
-533 Tokens saved
4 Tests
Install
Safety checks passed
Filter definition
# git-diff.toml — Override to --stat for compact output
# Raw: full unified diff (potentially hundreds of lines)
# Filtered: compact stat summary (files changed + insertions/deletions)
#
# Escape hatches: when the model needs the actual diff content (or an
# alternative summary format), it can pass any of the flags in
# `passthrough_args` and tokf will skip the override and run `git diff`
# as the user requested. The list below was chosen from observed agent
# retry patterns: forcing --stat with no escape caused models to thrash
# through ~50 retries trying every variation of `git diff` to get the
# patch content out.
command = "git diff"
description = "Show compact --stat summary instead of full diff"
# Override: use --stat for compact summary output
run = "git diff --stat {args}"
# Skip the override entirely when the user explicitly asks for diff content,
# specific context-line counts, or alternative summary formats.
passthrough_args = [
"-p", # patch (full diff content)
"--patch", # also matches --patch-with-stat, --patch-with-raw, --patch-id
"--no-stat", # explicitly disable our forced --stat
"-U", # -U3, -U10, ... custom unified context line counts
"--unified",
"--name-only", # alternative summary: file paths only
"--name-status", # alternative summary: status + file paths
"--numstat", # alternative summary: machine-readable
"--shortstat", # alternative summary: one line
"--raw", # alternative summary: raw format
]
match_output = [
{ contains = "fatal:", output = "✗ {line_containing}" },
]
[on_success]
output = "{output}"
[on_failure]
tail = 5
Examples
empty diff produces no output
~0 tokens → ~0 tokens
Raw output
Filtered output
non-fatal failure passes through via tail
~10 tokens → ~10 tokens
Raw output
error: something went wrong details here
Filtered output
error: something went wrong details here
fatal revision error shows friendly message
~8 tokens → ~9 tokens
Raw output
fatal: bad revision 'nonexistent'
Filtered output
✗ fatal: bad revision 'nonexistent'
diff stat output passes through unchanged
~34 tokens → ~34 tokens
Raw output
src/main.rs | 10 +++---- src/filter/mod.rs | 5 +++-- src/config.rs | 3 ++- 3 files changed, 8 insertions(+), 10 deletions(-)
Filtered output
src/main.rs | 10 +++---- src/filter/mod.rs | 5 +++-- src/config.rs | 3 ++- 3 files changed, 8 insertions(+), 10 deletions(-)
Warning: Community filters are third-party code. Review the filter definition above before installing it in production environments.Browse all filters