git diff

built-in
-30.7% Savings
1,958 Commands
-82333 Tokens saved
4 Tests

Install

tokf install 19fcb7985866d12e7e782e8ee4100fc4b1137f1682c8c04f8f94805a605e8592
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",
  "--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

# Route --name-only / --name-status to a tree-structured child filter
# instead of passing through unfiltered.
[[variant]]
name = "name-list"
detect.args_pattern = '--(name-only|name-status)'
filter = "git/diff-name-list"

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