token-efficient-scripts // claude code plugin · self-benchmarking
Throwaway commands that return less context
For one-off shell/python that searches, counts, or aggregates data, context use is often dominated by what the command prints back to the harness. Ten deterministic experiments preserved every answer: reach for native Grep/Glob/Read first, then bash, then python — and optimize output first, data flow second, code last. And when a command fails, recover cheapest-first instead of reading the man page. When you only need a verdict — tests, builds, git — ask for the quiet form.
Measured: same answer, "count ERROR lines in a 120k-line log"output tokens returned — 99.999% cut
rg
370,940 tokens — dumps every matching line
rg -c
3
T1Control output
90.4% avg
7 output experiments
Measured: output reductions ranged from 40.64–99.999%; the median was 99.97%. Return the answer, not the data; cap previews; spill complete results to a file when the harness does not need every row.
grep x f→grep -c x f # need it all? →f>out; head -3 out
T2Push filters early
1.68×
measured filter speedup
Measured: filtering a 300k-row TSV before sorting ran 1.68× faster. rg -c ran 6.99× faster than grep on one literal-search workload. Tool speed is platform- and workload-dependent.
sort f | awk '$4==500' →awk '$4==500' f | sort
T3Bash first, then trim
40%
fewer command tokens
Default to bash (grep/awk/jq/find) over Python for search/count/filter — reach for Python only when the task truly needs it. For throwaway Python, drop the ceremony: no comments, docstrings, argparse, or main(). Measured: awk vs ceremony-heavy Python cut code tokens 40% but ran 3.29× slower — brevity is a context win, not a speed promise.
v0.6.0 · when the command FAILS — 8 GNU-flag-on-BSD failures, every fix verifiedtokens to reach the same answers — 98% cut
man cmd
26,316 tokens — ~3,290 per page, and 2 of the 8 it cannot answer at any price
the ladder
438
↓ escalate cheapest-first · stop at the first hit
1 · re-read the error you have — free, solves 3/82 · cmd --help — ~58 tok3 · man | grep -m3 -B2 -A3 'concept' — ~150 tok4 · web only if 3 is empty — 8/8 for 3,166hook DENIES unfiltered man
v0.7.0 · commands run only to CHECK something — tests, builds, git, archives · every answer kepttokens to get the verdict — 97.1% cut
10-task validationDarwin arm64 · deterministic synthetic data
CORRECTNESS GATE
10 / 10
same task answer · counts, IDs, sums, JSON, previews, stored records, and unique sets verified
ANSWER / PREVIEW / SPILL TASKS
99.16%
combined output reduction · excludes the task that genuinely required the complete JSON value
⚠ guardrails — smaller must equal same
wc -l counts newlinescat glues file boundariessort before uniqties ≠ bugcompare data, not formatshorter ≠ fasterawk CSV only when simplehead/tail can cut the error
self-benchmarking plugin · v0.7.0 · re-runs weekly, tests its own advice10 tasks + 8 recovery + 10 verification scenarios · all answers preserved · cl100k proxy, not a universal billing claim