text-optimizer

text-optimizer is an agent for Claude Code from kochetkov-ma/claude-brewcode. It costs 25 tokens per session (2,562 once invoked), scanned A, original, MIT.

An agent that shortens and restructures text or documentation so language models can process it using fewer tokens.

In plain words
What is it for?
Use it to optimize prompts, compress documentation, or reduce token usage in text.
Why use it?
It reduces unnecessary wording in prompts and documents while keeping their useful information.

Agent for Claude Code

Written for Claude Code: ${CLAUDE_PLUGIN_ROOT} variable. Also seen: model in frontmatter; mentions CLAUDE.md; mentions subagents.

Runs only inside its plugin — its command needs a path that Claude Code sets for a plugin’s own hooks and for nothing else. Install the plugin, not this.

Part of the brewtools plugin — 9 skills, 3 agents shipped together

Good fit Use it to optimize prompts, compress documentation, or reduce token usage in text.

Compare 6 agents from other repositories ↓
Install

Getting it into your agent

This one installs as part of its plugin. Adding the marketplace and installing the plugin brings it with everything else the plugin ships.

Claude Code
/plugin marketplace add kochetkov-ma/claude-brewcode
Claude Code
/plugin install brewtools

Made for: Claude Code.

Or install brewtools, the plugin that ships this one along with the rest of its 9 skills, 3 agents.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for text-optimizer

README.md
[![agentmods](https://agentmods.dev/badge/agents/kochetkov-ma/claude-brewcode/text-optimizer/github.svg)](https://agentmods.dev/agents/kochetkov-ma/claude-brewcode/text-optimizer)
Your own site
<a href="https://agentmods.dev/agents/kochetkov-ma/claude-brewcode/text-optimizer"><img src="https://agentmods.dev/badge/agents/kochetkov-ma/claude-brewcode/text-optimizer/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for text-optimizer

Your own site · 80×15
<a href="https://agentmods.dev/agents/kochetkov-ma/claude-brewcode/text-optimizer"><img src="https://agentmods.dev/badge/agents/kochetkov-ma/claude-brewcode/text-optimizer.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 25 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 2,562 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found 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.1 $0.00025 $0.02562
Opus 5.5 $0.00010 $0.01025
Sonnet 5.5 $0.00005 $0.00512
Haiku 4.5 $0.00003 $0.00256

Measured 7d ago against content hash e2f35c6909b8, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

text-optimizer 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 7d ago.

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.

brewtools/agents/text-optimizer.md · 170 lines

How it starts

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

Text Optimizer Agent

Compress text, prompts and docs for LLM consumption: load rules, measure, transform by mode, check facts, report metrics. Preserve names, numbers, dates, URLs, paths, versions, ports, sizes, examples, negations and scope; record explicitly authorized replacements separately from loss. A block between another tool's begin/end markers (e.g. <!-- BEGIN brewcode:semble -->) stays byte-identical, marker lines included; report it as managed by <setup>.

Return

Verdict first, <=30 lines, path:line. Per file: words/chars before -> after, change %, ratio | semantic match % | rule IDs | verify pass/fail | dedup N merged, N emphasis capped. Name counting methods; tokens require a named tokenizer/encoding. chars/4 is a rough proxy, never measured tokens or proven savings. No optimized text, before/after excerpts, full ledgers or preamble: repeating compressed content cancels savings, with or without a return-size guard.

Store dedup/loss ledgers (every A.2/A.4 drop -> reason), fact inventories and runs over ~3 files in .claude/reports/YYYYMMDD-HHMMSS_text-optimize/report.md; return path + headline metrics. Failed gate: match % + lost facts, never the inventory.

Installed agent-return guard: over ~2500 est-tokens (chars/4) -> blocked for compression; over ~6000 -> details in report, return path + verdict + <=3 lines.

Scope guard

More than one deliverable, ~5 files or ~10 steps -> stop; propose 2-N subtasks with scope/owner. Mid-flight -> stop at next clean boundary; report done/remaining/split. An unsupervised hour fails even if work succeeds. Do not re-delegate or write Git; preserve concurrent work.

Missing GOAL, SCOPE, CONTEXT, CONSUMER or acceptance -> record assumption, proceed within it. No subagent question channel: return open decisions to caller (named option + recommendation), never guess or invent beyond the assumption. Cover whole scope; output usable by CONSUMER as-is.

Checkpointing

maxTurns: 60 = anti-loop stop, not budget; on hit caller gets output marked partial, can resume (2.1.246+); edited files survive. Immediately append each finished file (path, before/after size, %) to the report; never wait until completion. Resume: read report first, continue files missing from it.

Read the full file on GitHub · 170 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. 7d ago Changed e2f35c6909b8
  2. 8d ago Changed 9c1167c84b4a
  3. 10d ago Changed 1d9658e92987
  4. 11d ago Changed 30f7e3dae1bf
  5. 12d ago Changed 4c2b700a275f
  6. 13d ago Changed f7a3b4304e70
  7. 19d ago Changed 72a1431f29f3
  8. 20d ago Changed 137f22306986
  9. 25d ago Changed f49f545ecf71
  10. 28d ago First seen · 170 lines · 25 tokens per session scan A 0950af36593e

Subscribe to this mod's changes

text-optimizer is an agent published in the GitHub repository kochetkov-ma/claude-brewcode (41 stars, last pushed yesterday), licensed MIT. It adds 25 tokens to every session and 2,562 once invoked, about $0.0001 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

text-optimizer compared with agents from other repositories

text-optimizer next to 6 agents from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
text-optimizerkochetkov-ma/claude-brewcodeAgent41yesterdayMITA25Claude Code
budgettonone-ai/tononeAgent843d agoMITA21Claude Code
prompttonone-ai/tononeAgent843d agoMITA22Claude Code
tokentonone-ai/tononeAgent843d agoMITA21Claude Code
tunetonone-ai/tononeAgent843d agoMITA23Claude Code
ai-llmafel6/section-teamAgent142d agoMITC31Claude Code
ai-engineerafel6/section-teamAgent142d agoMITC33Claude Code