TokenLens - A CLI tool to check token usage for Cursor and other AI providers.
Source: Dev.to
Introduction
TokenLens is a CLI tool for developers who switch between multiple AI providers (Cursor, Codex, Gemini Code Assist) and need a quick view of their token usage, limits, and reset times—all from the terminal.
Features
- Unified status view for Cursor, Codex, and Gemini Code Assist.
- Shows usage, limits, and reset dates in a single terminal command.
- Optional config setup (e.g., storing a Copilot token).
- No dashboards or manual navigation required.
Installation
Homebrew
brew tap ctzeero/tap && brew install tokenlens
Build from source
git clone https://github.com/ctzeero/tokenlens.git
cd tokenlens
npm install
npm run build
Standalone binary
A pre‑built binary is available, so you don’t need Node installed.
Usage
tlens status
The command displays:
- Cursor – Pro/Fast request usage + reset date (pulled from browser cookies).
- Codex – Session (5 h), weekly usage, credits (from
~/.codex/auth.json+ usage endpoint). - Gemini Code Assist – Pro + Flash usage + reset dates (via CLI OAuth + Code Assist APIs).
Implementation Details
- Language & Runtime: TypeScript + Node.js.
- CLI framework:
commander(subcommands:status,config,providers). - Packaging:
pkgto ship standalone binaries (Node bundled). - Interactive setup:
inquirer. - Terminal UI:
chalk+ a tiny ASCII banner. - Data sources:
- Cursor: reads browser cookie databases (Chrome, Arc, Edge, Safari, Firefox) via
sql.js. - Codex & Gemini: reads auth files and uses OAuth auto‑refresh.
- Cursor: reads browser cookie databases (Chrome, Arc, Edge, Safari, Firefox) via
- Config storage: Local settings stored in
~/.config/tokenlens(viaconf), with optional saved tokens (e.g., Copilot).
What’s Next
- Add more providers (Claude, OpenAI Platform, etc.).
- Export usage data as JSON for dashboards or custom scripts.
Contributing & Feedback
If TokenLens makes your development workflow easier, feel free to:
- Visit the repository:
- Drop feedback, suggest new providers, or contribute improvements.