Cut agent token spend without losing results: thin large command output, skip repeated work, gate scheduled LLM sessions on real state changes, and measure daily usage per profile. Trigger: 'tokens too expensive', 'why is this agent burning tokens', 'reduce token use', a cron job that wakes an agent every few minutes, or raw log output filling the context.
Ships in token-saver. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
; instead of poking one command at a time.| head -40, a match filter, or thin.py. Never dump a full log or table.once.py --key <name> -- <cmd>.Quality gates (money, auth, visual checks, live verification) stay in full. Only duplicate sending is cut.
python3 scripts/measure.py 7 # last 7 days, all profiles
python3 scripts/measure.py 7 --pattern "Lifeline" # split out one loop
python3 scripts/measure.py 7 --quality # plus completed work per day, if a board table exists
Record the numbers somewhere durable. Without a baseline, "it feels cheaper" is the only thing you will ever be able to report.
A quiet loop is usually the biggest line item. Detection:
sqlite3 file:~/.hermes/state.db?mode=ro \
"select date(started_at,'unixepoch','localtime') d, source, count(*),
sum(input_tokens+cache_read_tokens)/1e6
from sessions where started_at is not null group by d, source order by d desc limit 20"
Many short sessions with source='cli' means a script or cron is starting agent runs.
Group the first user message of those sessions to find which prompt repeats. Then count how
many of those runs produced anything:
grep -L '\[SILENT\]' ~/.hermes/logs/<loop>/*.log | wc -l
If that count is zero, the loop is pure spend and a gate is the fix.
scripts/gate.py hashes the state you name in a small JSON config. The expensive session is
only started when the hash changed, or when a heartbeat interval has passed.
python3 scripts/gate.py --config gate-loop.json # exit 0 = run, exit 1 = skip
python3 scripts/gate.py --config gate-loop.json --force # ignore state, run anyway
Three source types, mix them freely:
| type | meaning |
|---|---|
sqlite | path + query, rows are hashed; use it for a work board or task table |
file | path, content is hashed; use it for an alert or inbox file |
cmd | cmd, stdout is hashed; use it for pgrep -c worker counts |
Rules that keep a gate honest:
Report three numbers, never one: tokens per day, expensive runs per day, and completed work per day. If work went down, the gate is too aggressive.
references/case-scheduled-loop.md - the measured case: 696 runs, 1.35 B tokens, zero output,
and the three cause worth checking first.What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
/token-saver:token-saverfrom token-saver
token-saver@bag-of-skills is listed by sngraihan/bag-of-skills — review the source before installing
npx claudepluginhub sngraihan/bag-of-skills --plugin token-saver