After trimming down to 9 agents and putting CLAUDE.md on a diet, the intervals between Compacting conversation... messages got noticeably longer. Same tasks, but it lasted much longer than before. Felt good.
Then I was watching the console after requesting a new feature. Tests ran. 30 cases, all passing. But Claude was mentioning the successful tests again. Something felt subtly off.
I asked Claude. “Why are you mentioning tests that already passed?” Claude explained the concept of tools. When Claude executes a terminal command or reads a file, those are all “tool calls.” And every time a tool runs, its entire output stacks into the conversation context. npm test results — 30 lines. Hugo build log — 180 lines. All of it. Tests all passed with nothing to look at, yet it read all 30. For build errors, only the last 5 lines mattered, but it loaded all 180.
The leaky bucket wasn’t just one.
And lo, thou shalt follow hooks
While googling, I discovered Claude Code’s hooks. PreToolUse — a script that intercepts right before Claude executes a tool. It can transform output before a Bash command runs, and it can block a Read call before it happens.
I could now set commandments to protect my precious.
First commandment: Thou shalt not read what succeeded
30 tests all passed, and there’s no need to read them again. I built a hook that filters for only failed cases and discards the rest. (I asked Claude to build it.)
| |
Where Claude once read all 30 test results, now it only sees failures. If everything passes, the reading amount is zero. 100% of unnecessary reads — eliminated.
Second commandment: Thou shalt not upload what isn’t an error
Hugo build log 180 lines, Docker build 80 lines — no need to upload everything just to find errors. Same logic: built a hook that filters for ERROR, WARN, failed only.
| |
180 lines became 5. Cut 97%. Docker went from 80 lines to around 10.
Third commandment: Thou shalt not even read what is useless
There’s an archive folder that’s no longer in use. No reason for Claude to open it while exploring files. Built a hook that intercepts Read tool calls and denies any path containing _archive.
| |
Simple, but effective.
But here’s the thing
The improvement was tangible. Compacting conversation... appeared less often. Context stayed much lighter even after running builds. Three hooks blocking Claude from reading unnecessary information.
But it was “tangible.” I didn’t know exactly how much I’d saved. Today felt better than yesterday, but I couldn’t brag about how much I’d cut! How was this any different from EP.1, where I believed “splitting agents would help” with zero evidence?
If you don’t measure it, you haven’t improved it. It was time to measure for real.
References