token-optimization

A set of rules for making coding-agent tool use more efficient.

In plain words
What is it for?
Use it to choose targeted searches and reads, plan tool calls, and avoid rerunning costly operations.
Why use it?
It helps avoid oversized search results, repeated expensive checks, and unnecessary context.

Cursor rule for Cursor

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add rules/arxdsilva/vault/token-optimization
Clone the repo
git clone --depth 1 https://github.com/arxdsilva/vault

Made for: Cursor.

Per session 845 This file is loaded in full into every session.
When invoked 845 The same file — it is already loaded in full.
Security scan A 0 findings. Scan, not verified.
Origin 100% copy Near-identical to another mod in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00845 $0.00845
Opus 5 $0.00423 $0.00423
Sonnet 5 $0.00169 $0.00169
Haiku 4.5 $0.00085 $0.00085

Measured yesterday against content hash 9fc0fc3dd8ed, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

token-optimization scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

Origin

This is a copy

100% identical to token-optimization — 0 lines differ, which has more behind it and is treated as the original. This page carries a canonical link to it rather than competing with it.

.cursor/rules/token-optimization.mdc · 91 lines

How it starts

The opening of the file, as written. The whole thing — 91 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Agent Efficiency Rules

In agent mode, response tokens are usually NOT the dominant cost. The dominant costs are:

  1. Tool-call results piped back into context (a single read_file of a 2,000-line file can cost more than the entire response).
  2. Re-running expensive tools (semantic search, repo-wide grep, full builds).
  3. Multi-turn ping-pong when one well-formed turn would have sufficed.

These rules attack all three.


1. Plan Before Acting

Before issuing tool calls, state internally (or briefly to user, max 1 line):

  • What file or symbol you're targeting
  • Which tool is the cheapest way to find it

Skip planning chatter for trivial tasks (one-line edits, single-file reads).

2. Cheapest Tool Wins

You need to… Use… Don't use…
Find an exact symbol or string grep / ripgrep Semantic search, full file reads
Locate a file by name pattern glob find recursive shell, listing all
Understand "how does X work" Semantic search, then targeted read Reading 10 files speculatively
Read a known function in a known file Targeted read (offset/limit) Full-file read on a 1k-line file
Check a single command's output Run it once Run it, then --help, then again

3. Batch Independent Calls

If two reads/searches don't depend on each other, fire them in the same message. Serial chains of independent calls double latency and inflate context-handoff tokens.

4. Don't Re-Read

  • A file read in this session stays read. Refer back to it from memory.
  • A directory listed once stays listed.
  • If you genuinely think the file changed (e.g., you just edited it and need to verify), re-read only the changed range.

Read the full file on GitHub · 91 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday First seen · 91 lines · 845 tokens per session scan A 9fc0fc3dd8ed

Subscribe to this mod's changes

token-optimization is a cursor rule published in the GitHub repository arxdsilva/vault (3 stars, last pushed 1mo ago), licensed MIT. It adds 845 tokens to every session, about $0.0042 per session on Opus 5. A static security scan graded it A with 0 findings. It is 100% identical to token-optimization, differing in 0 lines, and is treated as a copy.