Skip to documentation content
Branchcut
Reference

Cheat sheet

The Branchcut commands and semantics worth keeping within reach.

Everyday selections

GoalCommand
Find a filenamebranchcut config
Search a full relative pathbranchcut --full-path config
Find Rust filesbranchcut --glob '**/*.rs'
Select several extensionsbranchcut --glob '**/*.{rs,toml}'
Match any repeated termbranchcut README LICENSE
Use an exact glob rootbranchcut --glob 'src/**/mod.rs'

Simple terms search the filename by default. Multiple terms match with OR. Positive globs also form a union.

Exclude generated work

branchcut \
  --glob '**/*.{rs,ts}' \
  --exclude '**/{target,node_modules,dist}/**'

An exclusion removes matches. A safely covered subtree can be pruned before it is opened.

Filter results

GoalOption
Files, directories, symlinks--type file, --type dir, --type symlink
Extension union-e rs -e toml
Large files--size '>100MB'
Exact fractional threshold--size '>=1.5MiB'
Recent files--modified-within 7d
Older files--modified-before 30d
Absolute time--modified-before '2025-01-01T12:00:00+05:30' or --modified-before '@-0.5'
Depth boundary--min-depth 2 --max-depth 5
Hidden entries--hidden
Nested .gitignore--gitignore
.ignore plus Git sources--ignore
Smart case--smart-case
Unicode scalar matching--unicode

Different filter families combine with AND. Metadata is requested only after cheap name, type, extension, and glob checks.

Search inside selected files

GoalCommand
Find a literal stringbranchcut grep --glob '**/*.rs' TODO
Match any of several termsbranchcut grep -l -e ERROR -e WARN
Case-insensitive contentbranchcut grep -i todo
Scan binary-looking files toobranchcut grep --glob '**/*.log' --text crash
Stop after N matching linesbranchcut grep --glob '**/*.rs' --limit 20 TODO
Show surrounding linesbranchcut grep --context 2 TODO
Require every termbranchcut grep --content-mode all -e ERROR -e timeout
Export spans and totalsbranchcut grep --output jsonl --summary TODO
Search with content regex`branchcut-regex grep -E 'TODO
Find regex filenamesbranchcut-regex find -E '^test_.*\.rs$'

Content search runs after path selection. Repeated patterns default to OR. --content-mode all requires all patterns on one line. --count counts selected lines and file-list modes count files for limits. -l --print0 emits native NUL-delimited paths. Templates use --format; structured formats use --output. Content mode rejects command execution and preview. See the content guide.

Stop and order

GoalOption
Stop after the first match--first
Stop after N matches--limit 100
Globally sort paths--sort
Count only--count

Without an explicit worker count, --limit uses sequential traversal and stops at N delivered matches. Explicit multi-worker traversal is allowed but results are unordered and workers may already have inspected more entries when the limit is reached. --sort --limit N scans the full selection because global order must be known.

Output to another program

GoalOption
One path per linedefault
JSON Lines--json
NUL-delimited paths-0 / --print0
Absolute paths--absolute
Run once per path--exec 'command {}'
Run once per batch--exec-batch 'command {}'

--exec and the CLI --limit default to sequential traversal. Commands are shell-free and receive native path arguments. --exec-jobs N sets the child-process concurrency limit; values greater than one run concurrently, so side-effect order is unspecified.

Explain and measure

branchcut --glob '**/*.rs' --exclude '**/target/**' --explain
branchcut --glob '**/*.rs' --exclude '**/target/**' --stats
branchcut --glob '**/*.rs' --why src/generated/client.rs
  • --explain: intended compilation and prune strategy;
  • --stats: actual traversal counters;
  • --why: ordered checks for one candidate.

Saved project query

Create .branchcut-queries:

[source]
glob src/**/*.{rs,toml}
exclude **/target/**
exclude **/generated/**
extension rs
extension toml
gitignore
type file

Run it with:

branchcut --config .branchcut-queries --profile source --explain
branchcut --config .branchcut-queries --profile source

Boundaries

  • Matching is byte-oriented by default, with opt-in Unicode scalar matching and simple lowercase comparison for valid UTF-8 names; no normalization or multi-character case folding is performed.
  • Default case options fold ASCII only. With --unicode, smart-case detection and lowercase matching also use Unicode scalars; invalid native byte names fall back to byte matching.
  • --gitignore loads supported Git sources and nested .gitignore; --ignore adds .ignore; explicit ignore files have higher precedence. Advanced Git configuration and escaping boundaries remain documented.
  • branchcut grep uses literal patterns. branchcut-regex grep -E PATTERN adds line-oriented regex, and branchcut-regex find -E PATTERN selects names or paths. Multiline content, capture-group output, and replacement are unsupported. BOMs and explicit encodings are supported, and binary detection is bounded to the first 8 KiB.
  • Prefix/suffix negated extglobs and Unicode case folding are unsupported.

See the CLI reference and glob syntax for exact constraints.

On this page