Back to articles
Claude Code used 2.5M tokens on my project. I got it down to 425K with 6 hook scripts.
How-To

Claude Code used 2.5M tokens on my project. I got it down to 425K with 6 hook scripts.

via Dev.toDr. Farhan

My team and I have been using Claude Code as our primary coding agent for about six months now. Somewhere around last month, I started hitting limits on my MAX plans. My prompts weren't unusually long and my projects aren't massive, so I couldn't figure out where the tokens were going. So I did what any developer would do when something doesn't make sense - I started logging. The Setup Claude Code supports lifecycle hooks - PreToolUse , PostToolUse , SessionStart , Stop . I wrote a simple PreToolUse hook on the Read tool that appends every file read to a JSON log with a timestamp, file path, and a rough token estimate based on file size. Nothing fancy. Just a log. What I Found After 132 sessions across 20 projects, the numbers were consistent: 71% of all file reads were files Claude had already opened in that same session. In one project, Claude read server.ts four times in a single session. It read package.json three times. Not because the files changed - because it had no awareness o

Continue reading on Dev.to

Opens in a new tab

Read Full Article
6 views

Related Articles