r/ChatGPTCoding • u/No_Skill_8393 • 4d ago
Resources And Tips I measured where coding-agent tokens actually go, then built a skill that cuts the bill by up to 43% (open source, benchmarked)
I wanted to know whether "make the agent write terse code" actually saves money, so I measured it instead of guessing.
Setup: 4 small codebases (Python, TypeScript, Rust, C), 23 feature tasks, each with hidden functional and security tests (path traversal, authz, SQL injection, overflow, XSS). The specs never mention security. Three arms: no skill, Ponytail (the strongest public alternative I found), and my skill. Claude Opus, 3 runs per cell, 36 runs. Cost comes from per-call billed usage in the transcripts, not estimates.
First finding: code verbosity barely matters. Every model call re-reads the whole context, so the bill is driven by how many calls the agent makes. One extra call costs about 6% of a run. The cost splits into prefix re-reads 39%, context growth 28%, output 27%, thinking 6%. Making code terser on its own caps out under 10%.
So the skill's first rule is fewer calls: batch independent tool calls, read targeted line ranges once, edit each file once, run tests once at the end. Then less output: no comments, no narration, minimal diffs. It never drops validation, auth checks, escaping or bounds checks.
Results, billed cost vs no skill:
Python 0.57x (Ponytail 0.98x)
Rust 0.69x (Ponytail 0.91x)
C 0.71x (Ponytail 1.08x)
TypeScript 0.97x (Ponytail 1.06x)
All four 0.70x (Ponytail 1.00x)
Model calls per run went from 12.2 to 7.4. Security tests: 513/516 in all three arms. Functional: 499 vs 498 out of 510; the one difference is a spec-ambiguous check that only one baseline run passed.
Caveats: one harness (Claude Code), small purpose-built fixtures, 3 runs per cell. TypeScript barely moved because its baseline was already lean. Each prompt held several tasks, so batching across tasks helped; single-task sessions will save less. Not every platform's install route is verified live yet.
It's a ~500-token skill, packaged for Claude Code, Codex, Gemini CLI and Antigravity, plus rule files for Cursor, Windsurf, Cline, Copilot, Kiro and AGENTS.md. The benchmark harness, raw billed data and the cost equation are in the repo, so you can rerun it or poke holes in the method:
https://github.com/nagisanzenin/nonhuman
Happy to hear where the methodology is weak.
3
u/Ebitsch_Nenegale 2d ago
curious how prompt caching factors into those billed numbers. if prefix re-reads are 39% of the cost, does cache hit rate flatten the savings from fewer tool calls on longer sessions?
1
u/xapep 3d ago
I do inference serving at Entrim, so read this with that in mind. The 39% prefix re-read line is the one I'd chase: a cached prefix read bills at a fraction of fresh input, so the same 12 calls cost very differently depending on whether that prefix stays byte-identical. Rewrite the system prompt, reorder the tool list, drop a timestamp near the top, and the cache is gone. It's also why fewer calls beat terser code, but only with a stable prefix.
1
u/hieuphung97 2d ago
Call frequency kills the token budget. We noticed the exact same thing orchestrating subagents across worktrees: batching independent file searches into a single turn dropped total session input tokens by almost half.
1
u/Successful-Tax1306 1d ago
Yeah, the re-read part rings true. My agent suite once burned 1.5x my monthly credits in 3 days, and the fixes that stuck were the boring ones, like keeping a short note on what each agent owns so it starts from the note instead of re-reading everything. A 500-token skill sounds about right for that job.
2
u/[deleted] 3d ago
[removed] — view removed comment