PLUGIN brewtools / Agents
On this page
Text Optimizer
sonnet 5 modes owned edits onlyView agent file on GitHub (opens in a new tab)
Quick reference
| Field | Value |
|---|---|
| Agent | brewtools:text-optimizer |
| Triggers | optimize prompt, reduce tokens, compress |
| Tools | Read, Write, Edit, Glob, Grep, Bash, WebFetch |
| Main-session entry | text-optimize |
| Output | Per-file measured size changes, semantic checks, rule ids, and report path |
What it does
Compresses text and keeps its facts and behavior intact. It removes repetition, tightens wording, and applies the selected mode’s transformations. Numbers, names, dates, paths, versions, examples, negations, and scope qualifiers stay protected.
A block between another tool’s begin/end markers, such as <!-- BEGIN brewcode:semble -->, stays byte-identical, marker lines included, and is reported as managed by <setup>.
The agent owns a bounded file edit. It does not re-delegate, change Git, or accept its own optimization; the text-optimize skill coordinates snapshots and acceptance.
When to use
- Tighten agent, skill, or rule instructions without weakening scope or safety conditions.
- Shrink a README while keeping it readable.
Example
/brewtools:text-optimize -s README.md
/brewtools:text-optimize -l .claude/rules/project.md
/brewtools:text-optimize -d .claude/agents/domain-expert.md
The skill snapshots the original, then the agent edits the file and returns a compact report: measured size, verification evidence, unresolved losses. A shorter result is not accepted until verified.
Modes
The five modes (light, medium, standard, deep, max), their flags and review rounds are listed in text-optimize: Modes. Prompt-quality rewriting applies only to prompt-shaped content, medium and above, never to light.
Workflow
- Require the original snapshot
The skill supplies RUN_DIR with the pre-edit snapshot. Without it the writer stops before editing.
- Load rules and inventory facts
Reads the base rules and mode references, measures words, bytes, and characters separately, and lists critical facts and conditions.
- Deduplicate within ownership
Light uses D.1 only. Cross-file deduplication needs the main owner’s canonical-location decision.
- Edit and checkpoint
After each owned write, deletion, or repair, records that exact draft before the next edit. Concurrent changes by others are preserved.
- Verify
Runs the mechanical guard with
--no-restoreand the mode’s fact checks. Standard, deep, and max add a fresh independent verifier. - Patch or refuse
Repairs only the owned draft and rechecks. Unsafe or unproven recovery is refused and the current file stays intact.
Technical details
Snapshots, semantic acceptance, measurement #
Snapshots. The original lives under <RUN_DIR>/orig/<repo-relative-path>: read it, never edit, delete, or recreate it. Progress reports are not backups. The guard uses verify --no-restore, so failures keep current bytes and print evidence; a mechanical pass cannot prove semantic equivalence, and missing state or snapshots block acceptance. Full restoration needs authorization and a recorded checkpoint matching current bytes; otherwise RESTORE_REFUSED leaves the file untouched. A checkpoint made at failure time cannot manufacture ownership.
Gates: standard needs at least 98% kept/merged, deep and max at least 95%; max adds a second independent method (original-derived self-QA). Light has no semantic round; medium is a self-check with zero loss.
Standard, deep, and max also require 100% preservation of numbers, names, negations, and scope qualifiers. Merged duplicates and faithful paraphrases count as preserved; known-fact elisions are ledgered as loss. Unresolved confirmed loss blocks acceptance.
Measurement. wc -w counts words, wc -c bytes, wc -m characters. Token counts need a named tokenizer and encoding; characters divided by four is a rough proxy, not proof of savings. The final return is verdict-first: paths, before/after sizes, counting method, ratio, semantic match, rule ids, verdict, dedup summary. Ledgers and evidence stay in report files.
Shared rules for all brewtools agents: Scope guard.
Related
Brewtools overview
Text Optimize
Context Slim
Update: /brewtools:plugin-update, /reload-plugins, then /brewcode:setup-status upgrade - FAQ