Skip to main content

greedy-token

Route dev tasks through tool → python → ollama → RAG before escalating to Claude / ChatGPT / Codex / Cursor / etc.

Your task  →  greedy-token  →  rg/jq | scripts | Ollama | docs/rag | Cursor

Cursor vs greedy-token (token comparison)

Measured with greedy-token audit-context and greedy-token estimate against zero-design-system (tiktoken cl100k_base; order of magnitude, not API billing).

Cursor context overhead (every new chat)

Context Tokens Charged when
Always-on rules (.cursor/rules/*.mdc) 2,524 every chat
Skills on disk (.cursor/skills/*/SKILL.md) 26,386 if agent loads skill
Sampled docs (CONTEXT.md, migration-prompts.md) 3,349 if referenced
Sampled set total 32,259 full agent context
Naive agent baseline (rules + 6k overhead + task) ~8,530 default Cursor path

Rules ≥ 1024 tokens → stable prefix is cache-friendly for Claude API prompt caching.

Task routing: naive Cursor vs greedy-token

Task Naive Cursor greedy-token route Est. tokens Saved vs Cursor Savings Command
какой -D flag для baseUrl в e2e config ~8,534 rag (95%) 1,810 ~6,724 ~79% greedy-token rag "baseUrl -D flag"
ADR 002 baseUrl pattern ~8,530 rag (61%) 1,806 ~6,724 ~79% greedy-token rag "ADR 002 baseUrl"
find baseUrl in e2e properties ~8,532 tool (59%) 0 ~8,532 ~100% greedy-token run "…" --executerg
sync phase-manifest и skills-map ~8,532 python (65%) 0 ~8,532 ~100% greedy-token scripts --run check-meta-sync --execute
rsync template-project в monorepo ~8,533 python (60%) 0 ~8,533 ~100% dry-run script; run manually
batch inventory template-project ~8,532 ollama (66%) 0 cloud ~8,532 ~100% cloud scripts/ollama/batch-inventory.sh (local LLM)
refactor header layout and wire nav links ~8,535 cursor (82%) 8,535 0 new Cursor chat + skill from docs/skills-map.md

Tier order: tool (rg/jq) → python → ollama → rag → cursor — first match wins. Ollama tier is skipped when unavailable.

Takeaway: lookup / search / sync / bulk tasks save ~6.7k–8.5k tokens per request; wiring and architecture correctly stay on Cursor.

greedy-token audit-context                    # your workspace overhead
greedy-token estimate "your task here"        # route + savings before opening a chat

Install once, point at your workspace root, route every task through the cheapest tier that can handle it.

Install

pip install greedy-token
# or editable: pip install -e .
# or from git: pip install git+https://github.com/svasenkov/greedy-token.git

tiktoken (exact BPE counts via cl100k_base) is a required dependency. If install fails on an unsupported platform, use a Python version with a prebuilt tiktoken wheel or install from source with a Rust toolchain.

PyPI publish (maintainer)

  1. Create project greedy-token on pypi.org
  2. Add trusted publisher: Owner svasenkov, repo greedy-token, workflow publish.yml
  3. Publish: GitHub → Releases → re-run workflow or new tag

Workspace root

greedy-token runs against a project directory (monorepo, app repo, etc.):

export GREEDY_TOKEN_ROOT=/path/to/your-workspace

Auto-detect works when the workspace has docs/phase-manifest.json and scripts/check-meta-sync.sh (e.g. zero-design-system). Otherwise set GREEDY_TOKEN_ROOT explicitly.

Commands

Command Purpose
greedy-token route "…" Recommend: tool | python | ollama | rag | cursor + scoring
greedy-token estimate "…" Token-aware estimate: complexity, est_tokens, tier scan
greedy-token run "…" [--execute] Route + dry-run / read-only execute
greedy-token scripts --list List workspace script wrappers
greedy-token scripts --run ID [--execute] Dry-run / execute read-only wrapper
greedy-token audit-context Size of always-on rules/skills (tokens)
greedy-token tokens PATH… Count tokens in files/directories
greedy-token rag QUERY Search chunks in docs/rag/
greedy-token compress Short prompt version (stdin; --ollama for LLM)
greedy-token report [--since 7d] [--json] Aggregate usage telemetry

Global flag: --no-log disables telemetry for one invocation.

Usage telemetry (v0.3)

Commands route, estimate, run, rag, compress, and scripts --run append one JSONL line per invocation.

Variable Default
GREEDY_TOKEN_LOG ~/.greedy-token/usage.jsonl
GREEDY_TOKEN_LOG=0 disable logging
greedy-token estimate "find baseUrl"
greedy-token route "sync phase-manifest"
greedy-token report --since 7d
greedy-token report --since 24h --json
greedy-token --no-log estimate "find baseUrl"   # skip log for this run

Each event records: tier, est_tokens, cursor_baseline, cursor_saved, tier_scan, token_counter_method (tiktoken), and duration_ms.

Note: counts are tiktoken estimates vs naive Cursor chat — not Cursor/Anthropic API billing. Ollama local token usage is recorded when the API returns eval_count.

Tier order

tool (rg/jq) → python → ollama → rag → cursor

First matching tier wins. Ollama is optional — if unavailable, the tier is skipped.

Examples

greedy-token route "find baseUrl"
# → tool (rg)

greedy-token estimate "refactor header layout"
# → cursor, complexity=high

greedy-token route "batch inventory template-project"
# → ollama

greedy-token route "sync phase-manifest and skills-map"
# → python

greedy-token route "ADR 002 baseUrl pattern"
# → rag

Environment

Var Default
GREEDY_TOKEN_ROOT auto-detect or required
OLLAMA_URL http://localhost:11434
OLLAMA_MODEL qwen2.5-coder:14b

--execute

Read-only only: rg, jq, check-meta-sync.sh. Rsync/migrate/ollama — dry-run; run manually.

Route config

src/greedy_token/config/routes.yaml — customize patterns and commands for your workspace.

License

MIT

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

greedy_token-0.4.1.tar.gz (41.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

greedy_token-0.4.1-py3-none-any.whl (43.4 kB view details)

Uploaded Python 3

File details

Details for the file greedy_token-0.4.1.tar.gz.

File metadata

  • Download URL: greedy_token-0.4.1.tar.gz
  • Upload date:
  • Size: 41.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for greedy_token-0.4.1.tar.gz
Algorithm Hash digest
SHA256 86e7dfc0753694632bc4aee4ad7dc5c3b5f90b9517f8d1c79a890f3751e249da
MD5 53815ef18f786dbdb6cd3f2486aadaeb
BLAKE2b-256 53fce227e83809efc9eb5b13ccb6fd2e40e1a89706a0753eadc00071c237a941

See more details on using hashes here.

Provenance

The following attestation bundles were made for greedy_token-0.4.1.tar.gz:

Publisher: publish.yml on svasenkov/greedy-token

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file greedy_token-0.4.1-py3-none-any.whl.

File metadata

  • Download URL: greedy_token-0.4.1-py3-none-any.whl
  • Upload date:
  • Size: 43.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for greedy_token-0.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ceedd971e4673cfda3467675b46793dcc6268e19577a159830cf318c674a857c
MD5 4da31ae0b0d96d66e2bdde85ace89e39
BLAKE2b-256 c6ba825afa4f49cd9010e826636a35ce11dc3e881661387164cea02927f9e1c5

See more details on using hashes here.

Provenance

The following attestation bundles were made for greedy_token-0.4.1-py3-none-any.whl:

Publisher: publish.yml on svasenkov/greedy-token

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

0.16.2

2 files

0.16.1

2 files

0.16.0

2 files

0.15.0

2 files

0.14.1

2 files

0.14.0

2 files

0.13.0

2 files

0.11.1

2 files

0.11.0

2 files

0.10.0

2 files

0.9.0

2 files

0.8.0

2 files

0.7.0

2 files

0.6.3

2 files

0.6.2

2 files

0.6.1

2 files

0.6.0

2 files

0.5.8

2 files

0.5.7

2 files

0.5.6

2 files

0.5.5

2 files

0.5.4

2 files

0.5.3

2 files

0.5.2

2 files

0.5.1

2 files

0.4.6

2 files

0.4.5

2 files

0.4.4

2 files

0.4.3

2 files

0.4.2

2 files

This release

0.4.1 This release

2 files

0.2.2

2 files

0.2.1

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page