Developer cuts Claude Code costs 15–20% by auto-logging subagents with a Stop hook
A solo developer building an autonomous Claude Code workflow discovered that without structured logging, there was no way to identify which AI subagents were slow or error-prone. By configuring a Stop hook in Claude Code's settings, a shell script automatically parses session transcripts each time a session ends, recording subagent type, duration, and success or failure. Analysis revealed the code-reviewer subagent averaged 37 seconds per run — far slower than other agents — and adjusting its usage drove a 15–20% reduction in weekly API spending. The Stop hook requires only a single line added to the settings file and does not alter Claude Code's core behavior. The developer uses jq queries on the accumulated JSONL logs to regularly review performance data and make evidence-based optimizations.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in