← Back to Blog Optimization Guide

12 Token Optimization Techniques for 2026

Last updated: July 2026

The most effective way to optimize tokens is to send less and re-send nothing. Compress prompts, include only relevant context, cache and compact what repeats, dedupe file reads, right-size the model, cap output, and watch per-turn usage. Some techniques are lossless; a few are lossy and belong only where meaning stays intact.

Token cost is not one big lever — it is a dozen small ones. Most waste hides in context that gets re-billed every turn and in prompts padded with words the model never needed. Below are twelve concrete token optimization techniques, ordered from the prompt you type to the session you run, with a note on which are lossless (no meaning lost) and which are lossy (they trade a little fidelity for savings).

Table of Contents

  1. Compress the Prompt
  2. Telegraph / Lexical Shortening
  3. Selective Context
  4. Prompt Caching
  5. Compaction
  6. Clear Between Tasks
  7. Eliminate Redundant Reads
  8. Right-Size the Model
  9. Concise Output
  10. Lean Instruction Files
  11. Reference, Don't Paste
  12. Monitor Per-Turn Usage
  13. FAQ

If you want the conceptual foundation first, our primer on what token optimization is explains why these tokens cost what they do. Otherwise, start at the top.

1 Compress the Prompt

The cheapest tokens are the ones you never send. Cut filler ("basically," "just," "actually"), hedging ("I was kind of wondering if maybe"), and politeness padding ("please could you be so kind as to"). None of it changes what the model does — it only adds tokens that get re-sent on every following turn. Lossy, but barely: when you keep every instruction and identifier intact, compression tends to sharpen focus rather than lose it. See telegraph compression for the mechanics.

2 Telegraph / Lexical Shortening

Beyond removing filler, you can drop articles and redundant words where the meaning is unmistakable — "fix the bug in the parser function" becomes "fix bug in parser fn." This is telegraphing, the same instinct behind headlines and commit messages. Lossy: push it too far and you introduce ambiguity, so apply it only where a human would still read it one way. Our NLP analysis covers which word classes are safe to drop.

3 Selective Context

Most tasks need two or three files, not the whole repository. Handing the model your entire codebase to change one function means paying to re-send thousands of irrelevant lines on every request. Include only the snippets that matter to the task in front of you. Near-lossless when done well — you lose nothing the model needed. Our selective context guide shows how to pick the right slices.

4 Prompt Caching

When a stable block of context — system prompt, style guide, or a large reference file — repeats across requests, prompt caching lets the provider reuse it at a steep discount instead of re-billing the full input rate. Structure your requests so the unchanging part sits at the front and stays byte-identical. Lossless: nothing is dropped; you simply stop paying full price for the same tokens twice.

5 Compaction

Long agent sessions accumulate history that rides along on every turn. Compaction summarizes that history into a compact digest — in many tools a /compact command — so the essentials survive while the raw transcript is dropped. Lossy: detail is deliberately discarded, so compact at natural boundaries and re-state anything critical the summary might blur.

6 Clear Between Tasks

When you finish one task and start an unrelated one, the old conversation is pure dead weight — re-sent and re-billed for no reason. A /clear (or a fresh session) resets context to zero. Lossy by design: you are throwing history away, which is exactly what you want between independent tasks. Clearing is often the single biggest one-click saving in a long working day.

7 Eliminate Redundant Reads

Agents frequently re-read a file they already have in context, or fire two tool calls that return the same result. Each duplicate is a full payload re-billed for information the model already holds. Catch these — good tooling flags a duplicate read before it fires. Lossless: removing a duplicate removes nothing but cost. This is one of the purest wins available.

8 Right-Size the Model

Frontier models can cost many times more per token than an efficient mid-tier model. Renaming a variable, writing a small test, or fixing a typo does not need top-tier reasoning. Reserve the expensive model for genuinely hard problems and let a cheaper one handle routine work. Lossless for the cost math — you pay less per token for tasks that never needed the premium model.

9 Concise Output

Output tokens are billed too, often at a higher rate than input. Ask for terse answers, request "code only, no explanation" when that is all you need, and cap length where the tool allows it. A model told to be brief stops narrating every step. Lossy: you are trading away prose you did not want anyway, but be explicit when you actually need the reasoning shown.

10 Lean Instruction Files

Files like CLAUDE.md or a rules file are loaded into context on every turn, so every wasted line is paid for continuously. Keep them tight: durable project facts and conventions, not a changelog or a wall of edge cases. Near-lossless — a lean instruction file that keeps the load-bearing rules loses nothing the agent relied on, while trimming a fixed cost off every single request.

11 Reference, Don't Paste

Pasting an entire 2,000-line file inlines 15,000-25,000 tokens that then ride every following turn. Where the tool can read files on demand, point it at the path instead — see src/parser.ts — and let it pull only what it needs. Near-lossless: the model still gets the content, but only once and only the parts it opens, instead of carrying the whole dump forward.

12 Monitor Per-Turn Usage

You cannot cut what you cannot see. Watching token count per turn turns a mystery invoice into an early warning — a turn that suddenly spikes is usually a fat file read or bloated context you can fix on the spot. Lossless: monitoring changes nothing about the request; it just makes the waste visible so the other eleven techniques get applied where they matter.

Automate the Prompt Layer, On-Device

Terse applies several of these techniques automatically — light-touch prompt compression, telegraph shortening, and per-request cost tracking — all on-device, zero latency, no API calls. It cuts the wordiness before it compounds across every turn.

See Terse in Action

Lossless vs Lossy at a Glance

TechniqueType
Prompt cachingLossless
Eliminate redundant readsLossless
Right-size the modelLossless
Monitor per-turn usageLossless
Selective contextNear-lossless
Reference, don't pasteNear-lossless
Lean instruction filesNear-lossless
Compress the promptLossy (light)
Telegraph shorteningLossy
Concise outputLossy
CompactionLossy
Clear between tasksLossy (by design)

Reach for the lossless techniques first — they cut cost with no downside — then apply the lossy ones where the trade is obviously worth it. If you want to see how these play out across a full agent session, our breakdown of AI coding agent costs quantifies where the tokens actually go.

Frequently Asked Questions

How do I optimize tokens in AI coding tools?

Compress prompts, send only relevant context, use prompt caching, compact long histories, clear between tasks, avoid duplicate file reads, right-size the model, cap output length, keep instruction files lean, reference files instead of pasting them, and monitor per-turn usage. Some of these are lossless and some are lossy — reach for the lossless ones first.

Which token optimization techniques are lossless?

Prompt caching, eliminating duplicate tool calls and redundant file reads, right-sizing the model, and monitoring usage are lossless. Selective context, referencing files instead of pasting, and lean instruction files are near-lossless. Prompt compression, telegraphing, concise output, compaction, and clearing history are lossy to varying degrees.

Does compressing prompts hurt output quality?

Light-touch compression — removing filler, hedging, and politeness while keeping every instruction and identifier intact — usually improves focus rather than hurting it. Aggressive telegraphing that drops necessary articles or context can introduce ambiguity, so apply it only where meaning is unmistakable.

What is the biggest source of wasted tokens?

Context that rides along on every turn — long chat history, duplicate file reads, and whole-repo dumps — because it is re-billed on each request. Compaction, clearing, selective context, and prompt caching all target this compounding cost.

Further Reading

Related articles

How to Reduce Your Claude Code Context Window How to Reduce Your Cursor Costs How to Reduce GitHub Copilot Costs