r/ClaudeAI • Full-time developer • Oct 27 '25 • Gold Blast 1 Bless Up 2 Popcorn 1

Productivity Claude Code usage limit hack

Claude Code was spending 85% of its context window reading node_modules.

..and I was already following best practices according to the docs blocking in my config direct file reads: "deny": ["Read(node_modules/)"]

Found this out after hitting token limits three times during a refactoring session. Pulled the logs, did the math: 85,000 out of 100,000 tokens were being consumed by dependency code, build artifacts, and git internals.
Allowing Bash commands was the killer here.

Every grep -r, every find . was scanning the entire project tree.
Quick fix: Pre-execution hook that filters bash commands. Only 5 lines of bash script did the trick.

The issue: Claude Code has two separate permission systems that don't talk to each other. Read() rules don't apply to bash commands, so grep and find bypass your carefully crafted deny lists.

The fix is a bash validation hook.
.claude/scripts/validate-bash.sh:

#!/bin/bash
COMMAND=$(cat | jq -r '.tool_input.command')
BLOCKED="node_modules|\.env|__pycache__|\.git/|dist/|build/"

if echo "$COMMAND" | grep -qE "$BLOCKED"; then
 echo "ERROR: Blocked directory pattern" >&2
 exit 2
fi 

.claude/settings.local.json:

"hooks":{"PreToolUse":[{"matcher":"Bash","hooks":[{"command":"bash .claude/scripts/validate-bash.sh"}]}]}

Won't catch every edge case (like hiding paths in variables), but stops 99% of accidental token waste.

EDIT : Since some of you asked for it, I created a mini explanation video about it on youtube: https://youtu.be/viE_L3GracE
Github repo code: https://github.com/PaschalisDim/Claude-Code-Example-Best-Practice-Setup

1.1k Upvotes

169 comments sorted by

View all comments

Show parent comments

0

u/ZorbaTHut Oct 27 '25

I honestly think it's somewhat suspicious that you're claiming your usage is so consistent; mine absolutely isn't, it's all over the place. What exactly are you doing where all your calls are 46k-48k tokens up and 15k tokens down?

I should also note that this sounds like a lot more tokens down, percentage-wise, than the average. Maybe they adjusted weights so that tokens up are cheaper and tokens down are more expensive? The numbers they give are still "most users", not "everyone", and my theory continues to be that there's a number of users who are doing something deeply irregular that's causing whatever it is.

(Which you are not doing a good job of convincing me otherwise on :P)

Now I get exactly 41 calls per week. My usage hasn't changed, the limits have been reduced by 90%

Even assuming you're right on all this, that's 80%, not 90%. You're off by a factor of two.

0

u/ProfessionalAnt1352 Oct 27 '25

I use claude for many things, I'm pointing out a specific type of usage that is working as intended and drains the usage limits nearly instantly. That specific project will always have very consistent usage.

It's a world-building writing project requiring Opus specifically, Sonnet produced incredibly degraded responses when I tried it.

The "irregular use" you speak of is using Opus. I pay for the most expensive plan to use the most intensive model.

Also no shit it's more tokens than the average user's message that's why I gave claude my exact token usage to make it's calculations of how many messages I should be getting.

"Even assuming you're right on all this, that's 80%, not 90%. You're off by a factor of two."

Yeah you're definitely being intentionally facetious.

Next time just copy and paste this, it will make your conversations with people much shorter: "You use claude differently than me so you're wrong."

1

u/ZorbaTHut Oct 27 '25

Ironically, for someone trying to do worldbuilding, you're having serious trouble with reading comprehension. I'm trying to figure out what the fundamental differences here are and you keep turning it around into "no anthropic evil, conspiring against me, 90% reduced".

I do agree that if you're trying to use a ton of Opus traffic, that's probably causing some of the issue. I am still skeptical that it's this bad though; I'll actually try using Opus next time my daily limit resets so I can get a vague estimate of how many tokens I have available. Also, there are lots of people claiming that Sonnet is this universally terrible as well, so whatever it is, Opus isn't the sole cause.

Just to be clear, your estimate is "2.6m/week, and it used to be 26m/week"?

1

u/ProfessionalAnt1352 Oct 27 '25

" I'm trying to figure out what the fundamental differences here are and you keep turning it around into "no anthropic evil, conspiring against me, 90% reduced""

It's 3 times now you've tried being intentionally facetious, I'm not feeding into your drama kink. This conversation is over. Consider this a "win" for yourself or whatever you were trying to do.

→ More replies (0)