Skip to content

anistark/usage-estimate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

usage-estimate

npm version license downloads

Token estimation plugin for Claude Code. Shows how many tokens your prompt will consume before it's sent.

Install

npx usage-estimate install

Then enable the plugin in Claude Code (/plugins) and restart the session.

To verify it's working, type any prompt and press Enter — you should see an estimated token count (e.g. ~142 tokens) appear as a system message.

What it does

Every prompt you submit shows an estimated token count like ~142 tokens.

If a prompt exceeds the blocking threshold (default: 10,000 tokens), it pauses and asks you to press Enter again to confirm.

Configuration

Set the threshold with a slash command:

/usage-estimate maxToken 5000
/usage-estimate maxToken off
/usage-estimate status

Note: Restart Claude Code after changing the threshold for it to take effect.

Or add to ~/.claude/settings.json manually:

{
  "usage-estimate": {
    "blockThreshold": 10000
  }
}
Value Behavior
10000 (default) Block prompts over 10k tokens
Any number Block prompts over that many tokens
0 or null Never block, just show the estimate

Uninstall

npx usage-estimate uninstall

How it works

Uses a UserPromptSubmit hook that intercepts prompts after you press Enter but before they're sent to Claude. Tokens are counted locally using js-tiktoken with the cl100k_base encoding — no API calls, no latency. The count is an approximation (~10-15% margin).

License

MIT

About

Token estimation plugin for Claude Code

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors