When Claude runs your tests, the whole output lands in your chat, and your whole chat is sent again with every request after. A hook that keeps only the failures stops that waste. Anthropic's cost docs say this takes a 10,000-line log from tens of thousands of tokens down to hundreds.
Here's the hook, three steps to install it, and the catch.
How it works
- A PreToolUse hook on Bash runs before every command Claude issues.
- If the command is npm test, pytest or go test, the hook rewrites it to pipe through grep, so only the failing lines and five lines after each come back.
- Claude never sees the filter. It just sees the shorter output.
Free, for your email
Get the full setup steps + the copy-paste setup prompt
The rest of this guide (5 more sections, 2 copy-paste prompts) opens right here. The setup prompt, one paste into Claude that sets it all up, comes by email only. Use your real address.
Unlocks: Step 1: save the script · Step 2: turn it on · Step 3: check it worked · The catch · Sources
50,000+ follow where these guides come from. No spam, reply “unsubscribe” any time.