Token estimation plugin for Claude Code. Shows how many tokens your prompt will consume before it's sent.
npx usage-estimate installThen 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.
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.
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 |
npx usage-estimate uninstallUses 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).