yuseferi

Token Defrag — Development skill for Claude Code

Development community

See what Claude Code and OpenCode spend re-reading their own context, and estimate what you could save.

How to install Token Defrag

This entry records only its repository, not the path inside it, so there is no exact command to give. Open yuseferi/token-defrag and copy the folder into ~/.claude/skills/, or the file into ~/.claude/agents/.

What Token Defrag does

See what Claude Code and OpenCode spend re-reading their own context, and estimate what you could save. Offline estimate + shadow mode, one static Go binary, no telemetry.

Alternatives in Development

  • JWT Scan — JWT attack toolkit (offline) — alg:none forgery, RS256→HS256 algorithm confusion, weak-secret crack, static cl 4.5k ★
  • Edgee — Official Edgee CLI to interract with Edgee's Agent Gateway 127 ★
  • Unleash — Unleash Claude Code - 113 patches, zero refusals/telemetry, 42 gates 67 ★

README

![TokenDefrag: less re-reading, more building](docs/assets/hero.png)

**Most of what a long coding-agent session costs goes to re-reading itself.**
TokenDefrag shows how much of that you could cut, and measures it live without changing a thing.

[![CI](https://github.com/yuseferi/token-defrag/actions/workflows/ci.yml/badge.svg)](https://github.com/yuseferi/token-defrag/actions/workflows/ci.yml) [![Release](https://img.shields.io/github/v/release/yuseferi/token-defrag?color=69e5bd)](https://github.com/yuseferi/token-defrag/releases) [![Go version](https://img.shields.io/github/go-mod/go-version/yuseferi/token-defrag)](go.mod) [![License: MIT](https://img.shields.io/badge/license-MIT-69e5bd)](LICENSE) [![Status](https://img.shields.io/badge/status-shadow_mode-6bb5ff)](#roadmap)

Works with **Claude Code** and **OpenCode** (any provider, Bedrock included) · one static Go binary · no account · no telemetry

[Quick start](#quick-start) · [Benchmarks](#benchmarks) · [How it works](#how-it-works) · [Why trust the number](#why-trust-the-number) · [Compared](#how-it-compares) · [Roadmap](#roadmap)

tokendefrag estimate running on the synthetic benchmark corpus

Real CLI output on the synthetic benchmark corpus, not on private sessions.


[!IMPORTANT] **TokenDefrag measures; it does not rewrite yet.** `estimate` replays your past sessions offline, and shadow mode (`tokendefrag claude`, the OpenCode plugin) measures real requests while forwarding them unchanged. Live rewriting comes after shadow numbers and a paired eval back it up, so every saving below is an estimate or a would-be measurement, not a reduced bill.

The problem

Every turn of an agent session sends the whole conversation again. With prompt caching that re-read is cheaper per token, but it happens on every call, and the conversation only grows.

![The re-reading tax: