Pipe a file list into gnaw
gnaw reads a list of file paths from standard input and builds a prompt from
exactly those files โ no directory walk, no glob matching. The canonical use
is handing it the output of git, so a model sees precisely what you changed:
git diff --name-only | gnaw
That pipes the names of your unstaged changes into gnaw, which sources each one, counts tokens, and renders the prompt to stdout like any other run.
Common git workflows
All of these run from the repository root, because git prints paths
relative to the root and gnaw resolves them against your current directory.
# Unstaged working-tree changes
git diff --name-only | gnaw
# Staged changes only
git diff --cached --name-only | gnaw
# Everything changed since three commits back
git diff --name-only HEAD~3 | gnaw
# Changes on this branch versus main
git diff --name-only main...HEAD | gnawOther producers
Anything that emits one path per line works. A few that pair well:
# Every Rust file under src/ (fd)
fd -e rs . src | gnaw
# Files that mention a symbol (ripgrep -l lists matching files)
rg -l TODO | gnaw
# A hand-curated list kept in a file
cat review-set.txt | gnawShaping the output
The piped list only decides which files. Everything else โ format, template, destination โ composes exactly as in a normal run:
# Write straight to a file
git diff --name-only | gnaw -O context.md
# Copy to the clipboard (macOS)
git diff --name-only | gnaw | pbcopy
# JSON, then inspect which files landed
git diff --name-only | gnaw -F json | jq '.files[].path'
A custom or built-in content template applies as usual with -t / --template:
git diff --name-only | gnaw -t refactor
What gets dropped
gnaw quietly skips paths it can't use, so a messy list is safe to pipe:
- Deleted files โ they appear in
git diff --name-onlybut no longer exist on disk, so they can't be read. - Binary and empty files โ dropped during extraction, same as a normal walk.
- Paths outside the root โ anything that resolves above your current
directory is confined out, so a stray
../secretscan't escape.
Gotchas
Next steps
The Reading paths from stdin reference spells out the trigger conditions, path resolution, and how stdin interacts with filtering and templates. For folding git history into the prompt instead of just the file list, see Git diffs and logs.