savetokens.tips

Save tokens
Claude Code and Codex

Every word in your session gets reread on every turn.

Measured measured79.5%

of output tokens removed by filtering command output before the agent reads it.

rtk gain, snapshot 2026-07-20, 95,821 commands, 19.7M tokens saved

Estimate estimate~50%

shorter replies with caveman mode.

assumed 2x prose baseline, est ~69M saved, no before-and-after log

If you only do three things

  1. Compact early, then cut over to a fresh session. Run /compact once the context window is about 40% full. If you find yourself compacting a 3rd time, start a new session instead and hand the work over with a handoff-audit prompt so the fresh session can verify it independently.
  2. Run /clear between unrelated tasks. Anything left over keeps being reread.
  3. Keep caveman mode turned on.

Why long sessions get expensive

Every time you send a message, the whole conversation goes with it: your prompts, the agent's replies, and every line of tool output.

So the cost of a session compounds as it grows. Prompt caching cuts price but the tokens still fill the context window.

/compact to summarize the session.

Clear, compact, or start fresh?

/clear Between unrelated tasks

Wipes the conversation, keeps the session open.

/compact At a checkpoint

Avoid it mid-investigation, because summaries drop detail you still need.

new session When the task changes

Use the handoff-audit skill to get fresh eyes on what's been done so far.

Remember:

  • Never paste whole files. Name the path and let the agent read the ranges it needs. The agent reads once; a pasted file gets reread every turn.

The five-minute cache window

Prompt caching reduces your price bill.

The catch is timing. The cache lives for about five minutes, and the clock resets every time it is used. Reply within the window and you get the cheap rate.

  • Work in bursts. Reply within the 5 minute window and that saves money. Replies within 5 mins of the last only pay a tenth of the price.
  • A long break is a decision point. That is the natural moment to /compact or /clear.
  • Short transcripts make cold starts cheap. The caveman skill shrinks the penalty when the cache does expire.

Some setups use a one-hour cache at a higher write price, and the same logic applies with a longer clock.

Caveman mode: shorter replies, same facts

Caveman mode is a standing instruction that makes the agent's replies drastically shorter without losing technical content.

On ultra you can expect estimate~50% less tokens.

SettingWhat changesExample: why does my React component re-render
lite No filler or hedging. Full sentences kept. Professional but tight "Your component re-renders because you create a new object reference on each render. Wrap it in useMemo."
full Articles dropped, fragments allowed, short synonyms "New object ref each render. Inline object prop = new ref = re-render. Wrap in useMemo."
ultra Common words abbreviated, arrows for causality, one word when one word is enough. Code names never abbreviated "Inline obj prop → new ref → re-render. useMemo."

The rule that makes it safe: accuracy first, brevity second. A fact, caveat, or qualifier is never dropped to save tokens; only the wording compresses.

Copy these into your agent

The first two blocks go in the instruction file your agent reads at the start of every session: CLAUDE.md for Claude Code, AGENTS.md for Codex.

Context discipline rules
## Context discipline

- One task per session. When the conversation drifts to an unrelated task,
  say so and suggest /clear or a fresh session.
- Suggest /compact at natural checkpoints (after a fix lands, before a new
  area), never mid-investigation.
- When you need a file, read targeted ranges yourself instead of asking for a
  paste; a pasted file is reread every turn.
- Keep this file a thin kernel. Topical detail lives in reference files you
  load on demand.
- Subagents are not a discount. A subagent rereads context fresh and pays a
  summarize-back tax; dispatch only for large, genuinely independent scopes.
- Prefer filtered command output over raw dumps (diffs, logs, test runs).

The last rule is where output filtering plugs in; the measured numbers behind it are on the measurements page.

Caveman mode as a skill
Install this as a skill for me: save the file below, starting at the --- line,
as .claude/skills/caveman/SKILL.md for Claude Code or
.agents/skills/caveman/SKILL.md for Codex. Create the folder if needed, then
load it for prose replies.

---
name: caveman
description: >
  Ultra-compressed reply style. Cuts reply prose sharply while keeping
  full technical accuracy. Load for all prose replies.
---

Respond terse like smart caveman. All technical substance stays; only filler goes.
Accuracy first, brevity second: compress wording, never meaning. If terse risks
a misread, spend the words.

Rules: drop articles (a/an/the), filler, pleasantries, hedging. Fragments OK.
Short synonyms. Technical terms exact. Code blocks unchanged. Error messages
quoted exact.

Intensity levels:
- lite: no filler or hedging, full sentences kept
- full: articles dropped, fragments allowed, short synonyms
- ultra: prose words abbreviated (DB/auth/config/req/res/fn/impl), arrows for
  causality (X -> Y). Code symbols, function names, API names, and error
  strings are never abbreviated.

Auto-clarity: switch to plain prose for security warnings, irreversible-action
confirmations, and multi-step sequences where fragment order could be misread.
Resume caveman after the clear part is done.

Boundaries: code, commits, PR text, and file contents are written normally.
Off switch: "stop caveman" / "normal mode".

Paste the block into your agent and it installs the file for you. Prefer to do it by hand? Save it as .claude/skills/caveman/SKILL.md for Claude Code, or .agents/skills/caveman/SKILL.md for Codex.

Handoff audit as a skill
Install this as a skill for me: save the file below, starting at the --- line,
as .claude/skills/handoff-audit/SKILL.md for Claude Code or
.agents/skills/handoff-audit/SKILL.md for Codex. Create the folder if needed.

---
name: handoff-audit
description: >
  Draft a self-contained prompt for a fresh session to independently
  verify the current change. The prompt is the only deliverable.
---

When the user hands off work for verification, write ONE fenced markdown block
they can paste into a new session that has zero shared context. Do not run the
audit here or spawn a subagent: independence is the whole point.

Scope is the work on this branch. Capture the repo URL, the branch, and the
commit SHAs (git log --oneline main..HEAD, git diff --stat main..HEAD) verbatim.

Build the prompt from:
- Claims: what changed, what must still hold (the invariants), and why each
  risky call was safe, so the auditor can try to falsify each one.
- Fidelity reference: for a move or refactor, the pre-change git handle
  (git show <base-sha>:path) so they diff old against new instead of
  trusting a summary.
- Checks, each with an explicit pass/fail: no dangling consumers of moved or
  deleted symbols (grep -rw; warn about substring and pointer-comment false
  positives), deleted code was really dead, kept code is still wired, every
  reference site was updated, syntax balances.
- Constraints: what this environment cannot verify (installs, type-checks, a
  dev server) and the real signal that does (CI, deploy log, test suite).
- Output contract: PASS/FAIL per check with file:line evidence, re-verify each
  FAIL before reporting it, fix only real breaks, commit only touched files.

Open with an adversarial role ("skeptical auditor; assume the change is wrong
until your own grep and read prove otherwise") and a grounding line ("ground
every verdict in files you open yourself; do not trust this prompt's summary").
Wrap each part in its own tag: <audit_target>, <claims>,
<fidelity_reference>, <checks>, <constraints>,
<output_contract>.

Paste the block into your agent to install it. It writes the verification prompt when you hand a task to a fresh session; it does not run the audit itself. To install by hand, save it as .claude/skills/handoff-audit/SKILL.md (or under .agents/skills/ for Codex).

Advanced: models, subagents, workflows

Once the basics are habit, the next savings come from routing work to the right place. These matter most on big projects and long working days.

Audit before you optimize

Look at where the tokens actually go before changing habits. In Claude Code, /context shows what is filling the window right now: system prompt, connected tools, instruction files, and conversation. Disable connected tools/MCP you rarely use.

Keep your instruction file thin

Your CLAUDE.md or AGENTS.md is reloaded into context every single session, so every line in it is a recurring cost. Keep it as a wiki, and move detailed context into subfiles that are referenced only when the agent needs it.

For memory, using AI Firmware will have the model use its recall command. This points at short wiki-style notes and lets a session pull in only the note it needs. This keeps the always-on CLAUDE.md optimized and lean.

AI-Firmware is my project template built around a short rule-only kernel, a .claude/reference/ index for more detail, auto memory with /recall save, and an AGENTS.md mirror so the same setup works in Codex. Use or clone as a starting point.

Prune connectors and tools you are not using

Tools: every MCP server you connect wastes tokens immediately, used or not. Disconnect servers the current project does not use.

/context will show you exactly what each one costs.

Trim your skills, and drop the ones you never use

Skills: models read a skill's description to decide whether it applies. That context is loaded every session whether or not the skill ever runs. Remove the ones a project does not use and shorten descriptions.

Skill descriptions: keep the trigger words that decide when the skill should fire and cut the rest. Skills on GitHub tend to ship with setup notes, examples, and options that may not apply to your repo, so cutting irrelevant = fewer tokens & better output.

Compress the skill wording the same way caveman mode compresses replies.

When a skill's body is very large, split it into an instruction file: just a rule that points at subfiles that have all the detail, loaded only when needed.

Match the model to the task

Efficiency: Avoid xhigh unless it's needed. Avoid max. Mechanical bulk work should be a cheaper model at reduced thinking.

The default (high) is the sweet spot for most work. Save xhigh for the hardest coding and long agentic tasks.

What a subagent really costs

A subagent starts with fresh context, rereads files your session already read, then spends more tokens reporting what it found back to you.

But the main transcript stays clean. Dispatch subagents for big projects.

Workflows, for jobs that outgrow one context

Claude Code /workflows with Opus on medium thinking is great, for jobs that outgrow one context.

Subagents have fresh context and can bring different perspectives and angles that a single worker may miss.

Move repeatable work into scripts

For deterministic work, have the agent write a script once. Only writing costs tokens; every later run is free & more reliable.

For example I've run python scripts for hours that collect data, and then at the very end the model reviews.

Filter command output before the agent reads it

Shell output is the biggest silent cost: a large diff or test run can dump thousands of lines the agent never needed. Filtering removed measured79.5% of output tokens across 95,821 commands (snapshot 2026-07-20). Per-command numbers and how it works are on the measurements page.

The tool behind those numbers is RTK, an open-source proxy that condenses command output before the agent reads it.

Frequently asked questions

Q1

Why do long agent sessions cost more tokens?

The whole conversation is resent and reprocessed on every request, so long sessions compound.

Prompt caching can cut the billed price of that reread, but the tokens still dilute attention.

Q2

When should I use /clear, /compact, or a new session?

Match the move to how much of the conversation still matters:

  • /clear when the next task shares nothing with the current conversation. It wipes context and costs the least.
  • /compact at a natural checkpoint, after a fix lands and before a new area, when you need the conclusions but not the transcript.
  • A new session when the task changes entirely. Carrying an old transcript into new work makes every future turn pay for it.
Q3

How much does caveman mode save?

The logged caveman replies total 69.4 million tokens across 674 sessions, saving at roughly 69 million tokens.

The style compresses wording, but caveats, code, and error strings are preserved exactly.

Q4

Do subagents and workflows save tokens?

Not by default. A subagent starts with fresh context, rereads the files your session already read, then spends more tokens reporting back.

What subagents buy is a short main transcript. Dispatch for big projects.

Q5

What should I check first when I keep hitting the limit?

Audit before changing anything: /context shows what fills the window at session start, connected tools and instruction files are common surprises, and /usage shows plan spend. Then apply the fix that matches what you find:

  • The session starts heavy: prune preloaded tools and instruction files.
  • The transcript is the weight: shorten and split sessions.
  • Shell dumps dominate: filter command output.
Q6

Do unused skills still cost tokens?

Yes, always from the description. The full skill loads when it actually runs though.

If /context shows the Skills taking a lot of space, drop the ones a project does not need and sharpen the descriptions on the ones you keep.

Further reading

  • Stop Hitting Your Token Limit (CoreWise Academy): the same problem worked from the budget side. Audit your usage, cut consumption, downshift models for routine work, and weigh the riskier tactics honestly. Covers caveman mode and output filtering too.
  • Claude Code best practices (Anthropic): the vendor's own guidance on context management, instruction files, and workflow.
  • RTK on GitHub: the open-source output filter behind the measured figures on this site.