hafuture

Cut AI Coding Token Costs: Caveman & Ponytail Guide

Cut AI coding token costs in Claude Code and Codex using Caveman and Ponytail. Learn setup, 6 compression rocks, the 7-step ladder, and pstack eval.

Claude CodeCodexAIToken OptimizationCavemanPonytailpstackDeveloper Tools

Table of Contents


1. What Is a Token?

A token is a piece of text that an AI model reads or writes. Whenever coding agents like Claude Code or Codex work on your codebase, token consumption falls into three buckets:

  • Your prompt — input tokens from your instructions
  • Code, logs, and files read by the AI — context input tokens (by far the largest bucket)
  • The AI's written response — output tokens

Whether you are stretching a monthly subscription cap or paying per token via an API key, reducing tokens directly saves both money and waiting time. Caveman and Ponytail shrink different parts of that footprint.


2. Two Skills at a Glance

Caveman shrinks the volume of conversation (what the AI reads and says), while Ponytail shrinks the volume of work itself (how much new code the AI writes). Because their scopes do not overlap, you can run them side by side.

Pick the Right Token-Saver Setup for Your Workflow
Caveman

Say less + Read less without touching code

“why many token when few do trick”

What It Shrinks
AI verbosity + logs, JSON, CSV, and web pages fed into context
Core Mechanism
Terse replies + pre-read compression + Auto model routing + script reuse
Measured Results
33.2% fewer session input tokens; 1.4–2.4x Adobe cost cut; no quality loss in JetBrains A/B
Install Format
One-line CLI installer or agent skill/plugin
Ponytail

7-step reuse ladder for minimal working code

“Write one line in silence—and it works”

What It Shrinks
Generated diff size and unnecessary architectural bloat
Core Mechanism
Stops at the earliest rung of a 7-step ladder before writing new code
Measured Results (v5)
53% less code, 26% lower cost, 45% fewer tokens, 98% risky-logic test coverage (vs. 68%)
Install Format
Agent plugin or AGENTS.md / SKILL.md rule file
Caveman + Ponytail + pstack

Full-stack token & code discipline

“Prove (eval) → Optimize (hillclimb) → Lock in (authoring)”

Division of Labor
Caveman compresses I/O + Ponytail trims code + pstack validates on your repo
Built-In Synergy
If Ponytail's review/PR summaries feel wordy, Caveman's output mode trims them too
Recommended Order
Install Caveman + Auto login → add Ponytail → verify with pstack eval/hillclimb
Caveat
Rule prompts cost ~1,160 input tokens, so always A/B test on short-session workflows

3. Caveman — Say Less & Read Less

Named after the idea of speaking with caveman brevity, Caveman cuts what your AI reads and writes while leaving every character of your source code untouched.

How It Works: The 6 Rocks

Installing Caveman turns on all six rocks by default, and you can toggle any individual rock off with caveman off <rock>.

RockCLI NameWhat It DoesMeasured Savings
Say lessoutputCompresses AI replies while keeping code, commands, paths, and error messages intact. Never rewrites your prompt.Extra 3% over "answer concisely" (ultracave 35%)
Read lessinputCompresses logs, JSON, CSV, and test output before the AI reads them. Originals stay untouched on disk.Session input tokens 33.2% ↓ (CSV files 98.9% ↓)
AutoroutingRoutes easy prompts to lighter models/effort and hard prompts to stronger models automatically.0.46x cost vs. Opus xhigh (preliminary)
BlocksscriptsSaves and reuses repetitive helper scripts agents keep rewriting (8 built-in: test-summary, json-peek, etc.).Reading test results 397 → 76 tokens
Waste fixeswaste-fixesPinpoints token leaks and keeps the prompt cache warm while you step away.Not yet measured
BrowsebrowseCompresses web pages into clean text before feeding them to the agent.200-row table page 15,704 → 121 tokens

"Say Less" in Action

  • Standard AI (63 tokens equivalent): "Your React component is re-rendering likely because a new object reference is created on every render cycle. Passing an inline object as a prop causes React's shallow comparison to see a different object each time and trigger a re-render. We recommend memoizing the object with useMemo."
  • Caveman (20 tokens): "New object ref each render, so React re-renders. Wrap the prop in useMemo."

Same exact fix, roughly one-third the output tokens.


4. Installing Caveman

Requires Node.js 22.13+ and works across macOS, Linux, and Windows. Choose the installation method that fits your setup.

bash
npx @caveman-ai/cli@latest
Auto-detects 30+ coding agents (Claude Code, Codex, Gemini CLI, OpenCode, etc.) and applies Caveman globally. After setup, just run claude as usual.

5. How to Actually Save Tokens with Caveman

5.1 Check Status First

Run caveman status to see which rocks are active, which agents are patched, and the recommended next action. To disable a single rock, pass its name—for example, caveman off browse (output, input, waste-fixes, routing, scripts, browse).

5.2 Start Where Savings Are Largest: Read Less

  1. High-volume logs, tests, and data files: Teams handling large test suites or data files see the biggest wins—over 50% session input token reduction in measured runs.
  2. CLI helpers:
    • caveman shrink -- pnpm test: Compresses noisy test or build output before the agent reads it.
    • caveman browse <url>: Fetches and compresses web documentation.
    • caveman learn: Ranks where your tokens go, then lets you apply fixes step by step with caveman learn implement.
  3. Compress bloated memory files: Run /caveman-compress <file> on oversized CLAUDE.md or instruction files (a backup of the original is preserved).

5.3 Pick Your Brevity Intensity

CommandIntensityWhen to Use
/cavemanNormal (63 → 20 tokens example)Everyday default
/ultracaveStronger (extra 35% savings)When answers still feel wordy
/megacaveMaximum (ultra-dense shorthand)Extreme compression mode—looks like a meme, actually works
/caveman offOffWhen you want full, detailed prose

5.4 Cut Model Bills with Auto & Stop Rewriting Scripts with Blocks

  • Auto Routing (caveman login): Creating a free account unlocks Auto in your model picker. It selects the model and reasoning effort per request, cutting costs to 0.46x and latency to under half compared to Opus xhigh (if you do not log in, Auto stays hidden and nothing is transmitted).
  • Blocks (caveman-blocks scan / caveman-blocks init): Telemetry from real machines showed agents rewriting the exact same helper script up to 394 times in a single week. Initializing Blocks cuts test-result reading from 397 to 76 tokens.
  • Measure your own sessions: Use caveman stats for history and caveman trial -- claude to run live A/B comparisons on your own tasks.

5.5 Output Savings vs. Your Actual Total Bill (Honest Numbers)

Understanding where savings happen prevents disappointment, especially if you work in multilingual teams or short Q&A sessions:

ComponentExpected ImpactEvidence & Benchmark Context
Read less · Blocks · Browse · /caveman-compressLanguage-agnostic: ~25–55% session input ↓Targets code, logs, JSON (26.4% ↓), logs (50.2% ↓), and CSV (55.1% ↓), yielding 33.2% average total session input reduction regardless of language.
Auto (model routing)Language-agnostic: up to 0.46x costRoutes based on task complexity rather than prose style.
Say less (reply brevity)English: ~41% output ↓ (6,983 → 4,119 tokens); Non-English: ~8–30% output ↓Structural rules ("answer first, skip pleasantries, one idea per sentence") drive most gains. English adds extra +3–35% from dropping articles and STE word shortening. In a Portuguese 10-question benchmark on top of an already concise CLAUDE.md, output fell 8% (median -5%) (issue #733).

Crucially, look at total session cost: in a 662-session Claude Code analysis, output tokens accounted for just 0.3% of total tokens, keeping Say Less's net bill impact within ±0.2% (issue #733). Another benchmark cut output by 44% while total cost shifted +0.06% (issue #727). Because rule instructions add roughly 1,160 input tokens, short Q&A sessions or per-request billing plans (such as GitHub Copilot) can actually see a net loss (issue #145).

Bottom line: Even in English sessions, Read less, Blocks, Browse, and Auto drive the lion's share of real-world savings. Always verify with caveman trial -- claude, /caveman-stats, and your provider's billing dashboard.


6. Ponytail — Write Less Code

Ponytail channels the veteran engineer who has been at the company longer than the version control system—the one who silently replaces your 50-line function with a clean 1-liner that just works.

The rule is not "fewest tokens at any cost," it is "write only what is necessary." Ponytail never cuts input validation, error handling, security checks, or accessibility. Code shrinks because unnecessary reinvention disappears, and lower token bills follow as a welcome side effect.

How It Works: The 7-Step Ladder

Before writing a single line, Ponytail reads the target files and traces real execution flow, then stops at the earliest rung that solves the problem:

  1. 1
    Is this even needed?

    Check whether the problem can be solved without writing new code at all.

  2. 2
    Does this codebase already have it?

    Search for existing utilities, UI components, hooks, or helpers before creating anything new.

  3. 3
    Can the standard library do it?

    Use built-in language and runtime APIs rather than custom implementations.

  4. 4
    Can the platform do it natively?

    Prefer native HTML elements, browser APIs, and framework primitives.

  5. 5
    Does an installed dependency already handle it?

    Leverage packages already in your lockfile instead of adding new dependencies.

  6. 6
    Can it be a one-liner?

    Avoid wrapper abstractions and boilerplate layers when a direct expression suffices.

  7. 7
    Write the minimal working code

    Only if rungs 1–6 cannot solve it, write the smallest clean implementation (+ 1 focused test if it contains logic).

For example, when asked to "add a date picker," a standard AI often builds a custom calendar widget or installs a heavy package (335 lines). Ponytail combines your existing Input component with the browser's native date input (10 lines).


7. Installing Ponytail

bash
/plugin marketplace add DietrichGebert/ponytail
/plugin install ponytail@ponytail
Stays active across sessions and adds intensity controls, review, audit, and debt tracking commands.

8. How to Actually Save Tokens with Ponytail

8.1 Intensity Modes: /ponytail

  • /ponytail lite: Light touch for simple projects or unfamiliar codebases
  • /ponytail full: Default everyday mode
  • /ponytail ultra: Maximum cleanup mode—"when the codebase feels like it personally betrayed me"
  • /ponytail off: Temporarily disable

8.2 Review, Repo Audit & Debt Tracking

  • /ponytail-review: Instead of inspecting only the diff, it reads surrounding code to catch bugs, security gaps, real-world load issues, untested risky logic, slow paths, and dead code to delete. In benchmarks, it caught 100% of planted bugs (87% without) and 100% of outside-diff issues (78% without). Target uncommitted, staged, branch, or a PR URL.
  • /ponytail-audit: Scans the entire repository under the same rules and prioritizes what to fix first.
  • /ponytail-debt: Collects shortcut: comments left in your code so intentional shortcuts don't turn into permanent tech debt.

8.3 Live Cost & Reuse Telemetry (Claude Code)

  • Band (/ponytail band): Displays live session cost, tokens, elapsed time, existing-code reuse rate, and test pass status right above your prompt input, with quick buttons for review and audit (requires Claude Code 2.1.290+; not shown in VS Code chat panel or cloud sessions).
  • Board: Local web dashboard showing cumulative cost, tokens, and time per project. All data stays locally in ~/.config/ponytail/band/, and past sessions can be imported via /ponytail band import.
  • /ponytail-gain: Prints a benchmark-based savings scorecard.

9. Which One Should You Use—or Both?

ComparisonCavemanPonytail
Primary TargetAI conversation — reply length & read logs/filesCode output — lines written & complexity
ApproachTerse output rules + input compression + Auto routing + Blocks7-step ladder forcing reuse before creation
PackagingOne-line terminal CLI (or skill/plugin)Agent plugin / AGENTS.md rule file
BenchmarksInput tokens 33.2% ↓, cost up to 0.46x (Auto)Code 53% ↓, cost 26% ↓, tokens 45% ↓ (v5)
Go-To Commandscaveman status, /ultracave, caveman shrink/ponytail full, /ponytail-review, /ponytail-audit
Best ForDevelopers working with heavy logs, tests, CSVs, and long sessionsDevelopers building new features who want cleaner, smaller diffs

If budget is your top concern, start with Caveman full install + Auto login. When you also want leaner code and fewer over-engineered diffs, layer Ponytail on top. If Ponytail's review explanations feel verbose, Caveman's Say Less trims those too.

Command Cheat Sheet (Click to Copy)

Click any command to copy it to your clipboard

Caveman CLI · Compression · Stats

Caveman Modes · Memory Compression

Ponytail Modes · Review · Debt


10. Pairing with pstack Playbooks

pstack is an engineering skill plugin for Cursor and Claude Code that routes tasks through 23 structured playbooks. Three playbooks—eval, hillclimb, and authoring a skill—form a repeatable optimization loop: Prove quality holds → Cut costs further → Slim down the rule files themselves.

30-Second Setup

  • Cursor: Type /add-plugin pstack in chat
  • Claude Code: Run /plugin marketplace add cursor/plugins then /plugin install pstack@cursor-plugins
  1. 1
    eval — Prove quality doesn't drop in your repo/poteto-mode (eval)

    Runs identical prompts with skills on vs. off, hides candidate labels from the grader, and inspects real transcripts instead of self-reports.

  2. 2
    hillclimb — Drive down cost per task systematically/poteto-mode (hillclimb)

    Locks a measurement harness first, then toggles one Caveman rock or Ponytail intensity per iteration—keeping only verified wins.

  3. 3
    authoring a skill — Trim rule files for your project/poteto-mode (authoring a skill)

    Cuts redundant examples from Caveman's ~1,160-token rules or Ponytail's SKILL.md, tailors project conventions, and validates frontmatter and links.

Step 1: eval — Blind Quality & Token A/B Test
/poteto-mode Run a blind eval comparing caveman and ponytail ON vs OFF on the same bug-fix task. Compare quality differences and token usage, then summarize the results.
Step 2: hillclimb — Iterative Cost Reduction
/poteto-mode Cut average cost per task by 40% from baseline. Run at least 10 iterations, changing one caveman setting or ponytail mode per step, and keep only verified improvements.
Step 3: authoring a skill — Slim Down Rules Safely
/poteto-mode Tailor the caveman skill for our repository. Remove redundant examples to minimize input tokens while keeping our project rules intact, then validate the edited skill.

11. Precautions & FAQ

Q1. Are Caveman and Ponytail completely free?
Yes. Both are free open-source tools (Caveman: Apache-2.0, Ponytail: MIT). Caveman's Auto routing requires a free account login but carries no extra charge. Your underlying AI subscription or API model rates remain unchanged.
Q2. Does my code or prompt leave my machine?
Caveman's skill runs locally (except /caveman-compress, which sends the target file to your chosen model provider). Anonymous CLI usage counts can be disabled via caveman telemetry off, and Auto routing only sends recent prompt/answer snippets to Caveman Cloud when logged in (disable with caveman off routing). Ponytail is pure prompt rules with zero external telemetry—even Band/Board logs stay locally in ~/.config/ponytail/band/.
Q3. Will brevity hurt answer or code quality?
In JetBrains' A/B test across 86 real tasks, Caveman showed no statistically significant quality loss (p=0.82, 8.5% fewer output tokens), and Elastic reported zero information loss with 63.6% fewer response tokens. Still, HONEST-NUMBERS.md transparently notes caveats: HTML compression currently underperforms, per-request billing tools like GitHub Copilot don't benefit from shorter answers, and the rule prompt itself uses ~1,160 input tokens.
Q4. Why not just write 'answer concisely' in my prompt?
Manual prompts only get you part of the way. In identical benchmarks, 'answer concisely' cut 6,983 baseline tokens down to 4,334, whereas /ultracave reached 2,693 tokens. Adobe research also found that shortening user prompts degrades output quality—which is why neither tool ever alters your prompt.
Q5. What if my installation breaks?
For Caveman, simply tell your agent: 'Read INSTALL.md, install caveman for me.' For Ponytail, check INSTALL.md in the repository for per-editor troubleshooting and setup steps.

Validate Agent Configs & JSON Logs Locally with Hafuture

Inspect Claude Code, Cursor, or MCP JSON configurations and clean up test payloads 100% locally in your browser—zero uploads, zero cost.

Open JSON Formatter