Estimate Claude token counts, analyze costs, and refine prompts directly in Zed's AI assistant panel.
All heavy lifting is delegated to the ctok CLI; this extension is a thin Rust/WASM wrapper that runs the binary and formats results as Markdown.
- Zed 0.150+
ctokCLI installed:npm i -g @ctok/cli
- Open Zed → Extensions (
Cmd+Shift+X) - Search for ctok
- Click Install
cd apps/zed
cargo build --release --target wasm32-wasip1
# Then load the extension directory in Zed's dev extension pathOpen the AI assistant panel (Cmd+?) and type a slash command:
| Command | Description |
|---|---|
/ctok-check <text> |
Estimate tokens and cost for the given text |
/ctok-refine <text> |
Refine a prompt - shows the improved version + savings |
/ctok-scan |
Scan the current project directory |
Estimate tokens for a prompt:
/ctok-check Refactor the authentication middleware to use Postgres sessions
Refine a vague prompt:
/ctok-refine Please help me handle the auth thing somehow in a better way
Scan the current project:
/ctok-scan
Build the WASM target:
# Install the wasm32-wasip1 target
rustup target add wasm32-wasip1
# Build release
cargo build --release --target wasm32-wasip1Check types without WASM compilation:
cargo checkMIT