New:Microsoft Teams Notifications Are Now Available in Socket.Learn more →
Get Started

skitoken

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

skitoken

Open-source token consumption optimization engine. One command. Attach once. Track, audit, advise and auto-compress across every AI tool.

latest
Source
npmnpm
Version
0.1.1
Version published
Maintainers
1
Created
Source

Tokenly

npm license MCP Tawakkul Labs

Open-source token consumption optimization engine. One command. Attach once. Then it tracks, audits and advises forever, and auto-compresses before you burn tokens.

npm install -g skitoken gives you the tokenly command. Local-first. Private. Free. MIT licensed.

The problem

Hidden token tax

Developers now run several AI tools at once: Claude Code, Cursor, Codex, Gemini CLI, Windsurf, opencode, often simultaneously. Two facts hold in 2026:

  • Subscriptions stack up fast: $150-400+/month across tools, $1,800-4,800/year, with pricing models still shifting under you.
  • MCP servers hide a token tax: tool schemas load into context before a single message is processed. Verbose outputs and multi-turn call history pile on after every call. A naive setup can burn 30-50% of your context before real work starts.

Existing tools either track usage or optimize payloads. None do both, none attach automatically, and none compress your sessions for you. Tokenly does all three.

What Tokenly does

How Tokenly works

1. Attach with one command

tokenly install

Detects the AI clients on your machine, registers the Tokenly MCP server in each, installs hooks, and sets auto-start. Global everywhere, zero per-project config.

2. Track in one ledger

Every token and cost event from every tool lands in one local SQLite database. Full data ownership, no cloud, no telemetry.

3. Audit and advise like a financial advisor for AI spend

tokenly audit    # cross-tool usage and cost breakdown
tokenly advise   # concrete savings, for example "route X to mistral-small"
tokenly budget 50  # monthly cap with over-budget alerts

4. Auto-compress before you hit the ceiling

Sessions compress automatically at 60k tokens (default trigger), with a hard ceiling at 80k. Older turns fold into a compact digest, the last 5 turns stay verbatim, and critical facts are pinned so nothing important is lost.

Install

Requirements: Node.js 22.5 or newer (uses the built-in node:sqlite, zero native dependencies).

# global install (recommended)
npm install -g skitoken

# or run without installing
npx skitoken install

# or build from source
git clone https://github.com/AbduljabbarBXR/Tokenly.git
cd Tokenly
npm install
npm run build
npm link

Then attach:

tokenly install

Quickstart

# log usage from any tool
tokenly track --tool cursor --model claude-sonnet-4 --in 5000 --out 1200 --project myapp
# recorded cursor claude-sonnet-4: 5.0k in / 1.2k out, $0.0330

# see the live gauges
tokenly status

# cross-tool report for the last 30 days
tokenly audit

# get deterministic savings advice
tokenly advise

# set a monthly budget in USD
tokenly budget 50

Live status bars

Live gauges

tokenly install adds a two-bar gauge to every new terminal: token usage and compression level, live.

Usage     [############........................] 30%   (green)
Compress  [###############.....................] 38%   (green)
tokenly ctx=30.0k/100.0k state=ok
ZoneMeaning
Green at the startHealthy headroom, state ok
Orange in the middlePast the 60k trigger, compression advised, state warm
Red when fullPast 80k/90%, compression begins automatically, state COMPRESSING

Run tokenly status any time for the live view. All thresholds are configurable (see Configuration). New shells show the bars on startup; remove the two tokenly lines from ~/.bashrc to disable.

CLI reference

CommandWhat it does
tokenly installDetect clients, register MCP server, install hooks, enable autostart
tokenly track --tool T --model M --in N --out N [--project P]Log one usage event into the ledger
tokenly auditCross-tool usage and cost report, last 30 days, split by tool and model
tokenly adviseDeterministic recommendations: overpay detection, compression savings, budget alerts
tokenly budget [amount]Set the monthly budget in USD, or show spend versus budget
tokenly compress [session]Evaluate and apply context compression for a session
tokenly statusRender the live usage plus compression gauges
tokenly mcpStart the MCP server over stdio
tokenly versionPrint the version

MCP server

MCP tools

One server, 8 tools, stdio transport. Any agent or MCP client can call them for deterministic answers about usage, cost, and compression. No guessing about your bill.

ToolPurposeKey params
tokenly.trackLog a usage eventtoolName, model, inputTokens, outputTokens, project?
tokenly.audit30-day usage and cost breakdownnone
tokenly.adviseOptimization recommendations as JSONnone
tokenly.statusLive context tokens, headroom, compress statenone
tokenly.compressCompress a session nowsessionId, turns?, pinFacts?
tokenly.budgetSet or check monthly budgetamountUSD?
tokenly.modelsSupported models with pricing and tiernone
tokenly.count_tokensEstimate tokens plus cost, suggest cheaper modelprompt, model

Add it to any client manually:

{
  "mcpServers": {
    "tokenly": {
      "command": "node",
      "args": ["/path/to/skitoken/dist/mcp.js"]
    }
  }
}

tokenly install writes this for you in every client it detects.

Cursor hooks: when Cursor is detected, Tokenly adds an observational beforeSubmitPrompt hook in ~/.cursor/hooks.json. It only reads context size and never blocks.

Compression design

SettingDefaultMeaning
compress.trigger_tokens60,000Context crossing this is compressed
compress.aggressive_tokens80,000Hard ceiling, compress immediately
compress.keep_recent_turns5Turns kept verbatim after compression
compress.pin_factstrueCritical facts survive compression

What happens on compress: earlier turns fold into a structured digest ([Tokenly-compressed digest: N earlier turns summarized. Key facts: ...]), recent turns stay untouched, the session record updates with the smaller context size, and a ledger entry records the tokens saved. The gauges drop back to green.

Beyond compression, the roadmap automates: tool-search schema loading (80-95% schema cut), code-execution consolidation (80-90%), TOON output compression (50-70%), semantic caching (80%+ on repeats), and model routing (up to 60%).

Configuration

Config file: ~/.config/tokenly/config.json (override dir with TOKENLY_CONFIG_DIR). Data: ~/.local/share/tokenly/tokenly.db (override with TOKENLY_DATA_DIR).

Env varDefaultMeaning
TOKENLY_TRIGGER_TOKENS60000Compression trigger
TOKENLY_AGGRESSIVE_TOKENS80000Hard compression ceiling
TOKENLY_KEEP_RECENT5Turns kept verbatim
TOKENLY_PIN_FACTStruePin facts through compression
TOKENLY_ROUTINGtrueEnable model routing advice
TOKENLY_CACHE_TTL300Tool-output cache lifetime (s)
TOKENLY_CONTEXT_WINDOW100000Context window the gauges measure against
TOKENLY_DATA_DIR~/.local/share/tokenlyLedger location
TOKENLY_CONFIG_DIR~/.config/tokenlyConfig location

Privacy

Everything stays on your machine. SQLite ledger, local config, no accounts, no telemetry, no cloud calls. Uninstall removes tracking; your data files remain yours to delete.

Tech stack

TypeScript on Node 22, node:sqlite ledger (zero native deps), official @modelcontextprotocol/sdk, zero-dependency CLI parser, Cursor hooks.json plus opencode MCP integration. 25 unit tests plus end-to-end CLI and MCP verification.

Roadmap

Roadmap

  • v0.1 (shipped): install/track/audit/advise/budget/compress/status CLI, SQLite ledger, 13-model cost math, MCP server with 8 tools, live gauges with autostart, opencode auto-attach plus Cursor hooks.
  • v0.2: model routing engine, semantic caching, TOON output optimization, tool-search schema loading.
  • v0.3: code-execution consolidation, raw-API transparent proxy, Antigravity/Windsurf/Codex/Claude Code adapters, self-hosted dashboard.

Development

git clone https://github.com/AbduljabbarBXR/Tokenly.git
cd Tokenly
npm install
npm run build   # compile src/ to dist/
npm test        # 25 unit tests

Project layout: src/ (config, costs, ledger, compression, advice, statusbar, cli, mcp, install, status, hooks), test/ (unit tests), assets/ (logo, diagrams, badges), dist/ (build output, gitignored).

Uninstall

npm uninstall -g skitoken
# remove autostart: delete the two tokenly lines from ~/.bashrc
# optional: rm -rf ~/.local/share/tokenly ~/.config/tokenly

Supported tools

Cursor Claude Code opencode Antigravity Windsurf Codex CLI MCP Raw API

ClientIntegrationStatus in v0.1
Cursor (IDE)hooks.json observer plus MCPWorking
Cursor CLIPartial hooksTracking
Claude CodeHooks plus MCP configTracking
opencodeMCP auto-attachWorking
AntigravityMCP / CLIVia MCP
WindsurfMCP / CLIVia MCP
Codex CLISession log parsingTracking
Any MCP clientMCP server discoveryWorking
Raw API (any provider)Unified ledger via trackWorking, transparent proxy in v0.3

Supported providers and models

OpenAI Anthropic Google DeepSeek Mistral

ModelProviderInput / 1MOutput / 1MTier
gpt-5OpenAI$1.25$10.00frontier
gpt-4oOpenAI$2.50$10.00frontier
gpt-4o-miniOpenAI$0.15$0.60budget
gpt-4.1-miniOpenAI$0.40$1.60budget
claude-opus-4Anthropic$15.00$75.00frontier
claude-sonnet-4Anthropic$3.00$15.00frontier
claude-haiku-4.5Anthropic$1.00$5.00budget
gemini-2.5-proGoogle$1.25$10.00mid
gemini-2.5-flashGoogle$0.30$2.50budget
deepseek-chatDeepSeek$0.27$1.10budget
deepseek-reasonerDeepSeek$0.55$2.19mid
mistral-largeMistral$2.00$6.00mid
mistral-smallMistral$0.10$0.30budget

Pricing is compiled into the cost engine so audits and advice work offline. Validate against live provider pricing for billing decisions.

License

MIT. See LICENSE.

Local-first. Private. Free.

Links: npm | GitHub | Tawakkul Labs

Keywords

tokens

FAQs

Package last updated on 22 Sep 2026

Related posts