Estimate tokens
Heuristic BPE-aware estimation across prompt, code, files, and project context. Shows input/output ranges with confidence level.
ctok is a free, open-source toolkit for everyone who builds with Claude. Long coding sessions drift, the wrong model burns money, and you hit your quota mid-task. ctok runs before you send, wrapping a simple Plan → Execute → Verify loop around every prompt:
It runs everywhere a developer already works: a CLI on the terminal, an MCP server inside Claude Code / Cursor / Zed, and a web playground in the browser. The CLI and MCP server are on npm; the browser extension and desktop app build straight from a clone - no app store or account required.
Estimate tokens
Heuristic BPE-aware estimation across prompt, code, files, and project context. Shows input/output ranges with confidence level.
Recommend model & effort
Picks Haiku / Sonnet / Opus based on task complexity. Suggests effort level (low → xhigh) with written reasoning.
Refine prompts
7-pass pipeline strips filler words, replaces vague verbs, deduplicates blocks, and scores specificity 0-100.
Works everywhere
CLI · Web playground · MCP server · Desktop app · Browser extension. Same engine, every surface.
No store, no account. Clone and you have the whole toolkit working locally:
git clone https://github.com/ctok-cli/ctok.gitcd ctok
# macOS / Linux./scripts/setup.sh
# Windows (PowerShell)./scripts/setup.ps1
# any OS, after `corepack enable`pnpm setupPrefer npm? The CLI is published there too:
npm install -g @ctok/cli$ ctok check "Refactor the auth middleware to use the new session store"
Input tokens ~367 (range 365-369, high confidence) Output tokens ~400 (range 400-551) Estimated cost $0.035 at Opus 4.7
Recommendation opus-4-7 · high effort Why Deep / architectural work. Opus 4.7 has the strongest reasoning and is worth the premium when correctness matters.
$ ctok refine "please can you kindly help me to handle the auth thing somehow"
Score 12 → 45 (+33) · saved 4 tokens Refined: Handle the auth flow.