git status

built-in
-61.8% Savings
1,793 Commands
-125609 Tokens saved
12 Tests

Install

tokf install 6463630efc31b19ec7b554d6b8edfb6253cb17597a99231a44f450ae92268757
Safety checks passed

Filter definition

# git-status.toml — compact file listing with native git status codes
# Runs: git status --porcelain=v1 -b -uall --find-renames
#   -b              → branch header (## main...origin/main [ahead 1])
#   -uall           → list every untracked file individually instead of
#                     collapsing newly-created directories to "?? dir/".
#                     The collapsing default caused models to retry status
#                     because they "didn't see" files they had just created.
#   --find-renames  → render renames as "R old -> new" instead of D + ??.
#                     Without it, the model sees the rename as a deletion
#                     plus an unrelated new file and tries to "fix" the
#                     deletion.
# Filtered: branch header transformed to a compact form that always
#           communicates upstream sync state — "[synced]", "[ahead N]",
#           "[behind N]", "[ahead N, behind M]", or "(no upstream)".
#           The previous filter stripped the upstream tracking entirely
#           when in sync, leaving the model unable to tell whether it had
#           unpushed commits.

command = "git status"
description = "Compact porcelain format with branch and upstream sync state"

# Override: porcelain v1 with untracked-all and rename detection
run = "git status --porcelain=v1 -b -uall --find-renames"

match_output = [
  { contains = "not a git repository", output = "Not a git repository" },
]

replace = [
  # Detached HEAD
  { pattern = '^## HEAD \(no branch\).*$', output = "HEAD (detached)" },
  # Branch with ahead/behind info: ## main...origin/main [ahead 2]
  { pattern = '^## (\S+?)(?:\.\.\.\S+)?\s+\[(.+)\]$', output = "{1} [{2}]" },
  # Branch with upstream but in sync (no [ahead/behind] bracket)
  { pattern = '^## (\S+?)\.\.\.\S+$', output = "{1} [synced]" },
  # Local-only branch (no upstream tracking)
  { pattern = '^## (\S+)$', output = "{1} (no upstream)" },
  # File lines pass through unchanged (XY codes are standard and understood by models)
]

# Restructure path-list output into a directory tree, writing each shared
# prefix once. The transformed branch header is preserved at the top via
# `passthrough_unmatched`. min_files=3 is below the global default (4)
# because git status output where 3+ files share a directory is the common
# case where the tree wins (e.g. untracked files inside a new directory).
#
# style = "indent" is chosen over the prettier "unicode" connectors because
# Unicode box-drawing chars are 3 bytes each in UTF-8 and add up fast on
# deep trees — measured net-negative on a 10-file mid-depth fixture. Plain
# 2-space indent communicates the same hierarchy at a fraction of the cost.
[tree]
pattern = '^(.. )(.+)$'
passthrough_unmatched = true
min_files = 3
min_shared_depth = 1
style = "indent"
collapse_single_child = true

Examples

all status types show correct file listing ~67 tokens → ~60 tokens (10% saved)
Raw output
## feature-branch...origin/feature-branch [ahead 2]
A  src/new_module.rs
AM src/half_staged.rs
D  old_file.rs
 D src/forgotten.rs
 M src/config.rs
M  src/main.rs
M  src/lib.rs
MM src/both.rs
R  old_name.rs -> new_name.rs
UU src/conflict.rs
?? untracked.txt
?? scratch.md
Filtered output
feature-branch [ahead 2]
A  src/new_module.rs
AM src/half_staged.rs
D  old_file.rs
 D src/forgotten.rs
 M src/config.rs
M  src/main.rs
M  src/lib.rs
MM src/both.rs
R  old_name.rs -> new_name.rs
UU src/conflict.rs
?? untracked.txt
?? scratch.md
clean repo shows branch name with synced marker ~5 tokens → ~3 tokens (40% saved)
Raw output
## main...origin/main
Filtered output
main [synced]
detached HEAD shows detached message ~11 tokens → ~7 tokens (36% saved)
Raw output
## HEAD (no branch)...abc1234
M  src/main.rs
Filtered output
HEAD (detached)
M  src/main.rs
diverged branch shows ahead and behind counts ~13 tokens → ~9 tokens (31% saved)
Raw output
## main...origin/main [ahead 1, behind 2]
M  src/foo.rs
Filtered output
main [ahead 1, behind 2]
M  src/foo.rs
monorepo with many files clustered under a shared prefix renders as a tree ~104 tokens → ~75 tokens (28% saved)
Raw output
## main...origin/main
M  crates/tokf-cli/src/config/cache.rs
M  crates/tokf-cli/src/config/types.rs
M  crates/tokf-cli/src/main.rs
M  crates/tokf-cli/filters/git/diff.toml
M  crates/tokf-cli/filters/git/status.toml
M  crates/tokf-cli/filters/git/show.toml
?? crates/tokf-cli/filters/git/log.toml
M  crates/tokf-common/src/config/types.rs
M  crates/tokf-common/src/config/tree.rs
?? crates/tokf-filter/src/filter/tree.rs
Filtered output
main [synced]
crates/
  tokf-cli/
    src/
      config/
        M  cache.rs
        M  types.rs
      M  main.rs
    filters/git/
      M  diff.toml
      M  status.toml
      M  show.toml
      ?? log.toml
  tokf-common/src/config/
    M  types.rs
    M  tree.rs
  ?? tokf-filter/src/filter/tree.rs
local-only branch with no upstream is marked explicitly ~6 tokens → ~9 tokens
Raw output
## my-feature
?? scratch.rs
Filtered output
my-feature (no upstream)
?? scratch.rs
normal repo shows branch with synced marker and file listing ~20 tokens → ~18 tokens (10% saved)
Raw output
## main...origin/main
M  src/main.rs
 M src/lib.rs
?? new_file.txt
?? another.txt
Filtered output
main [synced]
M  src/main.rs
 M src/lib.rs
?? new_file.txt
?? another.txt
not a git repository shows friendly error ~17 tokens → ~5 tokens (71% saved)
Raw output
fatal: not a git repository (or any of the parent directories): .git
Filtered output
Not a git repository
rename detection shows R old -> new instead of D + ?? ~12 tokens → ~10 tokens (17% saved)
Raw output
## main...origin/main
R  old_path.rs -> new_path.rs
Filtered output
main [synced]
R  old_path.rs -> new_path.rs
single-child directory chain collapses into one node ~29 tokens → ~19 tokens (34% saved)
Raw output
## main...origin/main
M  src/lib/inner/foo.rs
M  src/lib/inner/bar.rs
M  src/lib/inner/baz.rs
M  src/lib/inner/qux.rs
Filtered output
main [synced]
src/lib/inner/
  M  foo.rs
  M  bar.rs
  M  baz.rs
  M  qux.rs
two-file output stays flat (below min_files=3 fallback) ~12 tokens → ~10 tokens (17% saved)
Raw output
## main...origin/main
M  src/foo.rs
M  src/bar.rs
Filtered output
main [synced]
M  src/foo.rs
M  src/bar.rs
untracked files in newly created directories list individually ~20 tokens → ~14 tokens (30% saved)
Raw output
## main...origin/main
?? new_module/a.rs
?? new_module/b.rs
?? new_module/sub/c.rs
Filtered output
main [synced]
new_module/
  ?? a.rs
  ?? b.rs
  ?? sub/c.rs
Warning: Community filters are third-party code. Review the filter definition above before installing it in production environments.
Browse all filters