TokenJam Script
Some of your agent tasks don't need an agent. Replacing them with scripts is 100% cost recovery on those tasks.
Surface recurring agent sessions that should have been simple (deterministic) scripts.
The problem
A user types "deploy staging" into Claude Code. The agent thinks for a few seconds, runs git pull, npm install, reads .env.staging, runs npm run build, runs pm2 restart staging-app. Same five commands, same order, every single time.
The agent's reasoning didn't change anything; the user just paid Opus pricing to have it figure out a 5-line shell script. Multiply that across hundreds of deterministic tasks and you have meaningful, recoverable cost. Script finds those tight clusters — and only the tight ones, where the reasoning genuinely added nothing.
How it works
Cluster sessions by tool-call signature: the ordered list of tools called, with which arguments are fixed vs variable. Inside each cluster, measure three kinds of variation — argument variation, branch variation (did the agent ever skip or add a step?), outcome variation (did the user accept the result every time?).
Surface clusters where >90% of instances follow identical patterns, where the agent's reasoning contributed no observed variation. The output names the cluster, shows the example sequence, counts instances, and projects the savings from replacing it with a script you write.
Confidence levels
Every finding carries an explicit confidence level. TokenJam never claims a smaller model would have produced an identical answer; it shows the candidates with evidence, and you decide what to apply.
Structural
Conservative thresholds in v1 to minimize false positives — only flag clusters with 100% argument-pattern stability, 20+ instances, and zero observed branching. Surfaces fewer findings, but the findings are reliable.
Example output
Verbatim from a real run against a real Claude Code project. No screenshots, no cherry-picks.
Deterministic workflow candidates (high confidence only): • 23 sessions in last 30d executed identical 5-step sequence: git pull → npm install → cat .env.staging → npm run build → pm2 restart Zero argument variation. Zero observed branching. Estimated current cost: ~$87/mo (23 sessions × ~$3.80 average) → This looks like a deployment script, not an agent task. Suggested: replace with `scripts/deploy-staging.sh`. Estimated savings: $87/mo, plus ~30s latency per execution.
What you do with it
Recommendations land in your existing tools — terminal, MCP-capable agent, or as an exportable config.
- CLI
tj optimize --finding workflow-restructureoutput names candidate sessions; you write the script
- MCP
surfaces in get_optimize_report
The research behind it
-
Efficient Agents
2025
Demonstrates 96.7% of OWL framework performance at 28.4% lower cost via principled component selection. The empirical basis for selective de-agent-ification.
-
Agentic Plan Caching
2025
46.62% cost reduction at 96.67% accuracy retention by extracting reusable program templates from trajectories. The "agent" v2 of this idea; Script is the conservative v1.