PLUGIN brewtools / Skills
On this page
Text Optimize
sonnet 5 modes model-invocable
Illustrative animation: prompt, snapshot then one optimizer agent per file, measured before/after report, summary card.
View README on GitHub (opens in a new tab)
Quick reference
| Field | Value |
|---|---|
| Command | /brewtools:text-optimize |
| Input | Free-text prompt, optional depth flag, file/folder/comma-separated targets |
| Invocation | Model-invocable (disable-model-invocation: false): type the command or ask Claude (“compress this prompt”, “optimize CLAUDE.md”). Claude-started runs must name targets: empty arguments stop with “no target”; --allow-dirty authorizes uncommitted targets |
| Mutation | Every mode edits files in place after a pre-edit snapshot |
| Output | Edited targets, measured size changes, acceptance verdicts, evidence paths |
What it does
The skill cuts repetition and wording overhead in instructions and documents while keeping their behavior. One file owner per target snapshots the original bytes, checks the draft mechanically, and applies a mode-specific semantic review. A shorter file is not accepted just because it is shorter.
Numbers, names, examples, negations, scope, paths, versions, flags and conditions stay protected.
When to use
| Scenario | Command |
|---|---|
| Tighten a rule, agent or skill file, same behavior | /brewtools:text-optimize -d .claude/agents/domain-expert.md |
| Shorten a README or guide, keep it readable | /brewtools:text-optimize -s README.md |
| Minimal cleanup of a production prompt | /brewtools:text-optimize -l .claude/rules/project.md |
| Several files in one run | /brewtools:text-optimize -s README.md,docs/guide.md |
Modes
| Mode | Flag | Transformation | Required review | Rounds |
|---|---|---|---|---|
| Light | -l | Minimal cleanup, exact-duplicate D.1 only, no restructuring | Mechanical sub-gate; no semantic agent | none |
| Medium | Default or detected | General compression | Zero-loss fact self-check and skill review | self-check |
| Standard | -s | Human-readable compression | Fresh independent review; at least 98% kept/merged | 1 |
| Deep | -d | Dense instruction rewriting with ledgers | Fresh independent review; at least 95%; repair failed gates | 1-2 |
| Max | -x / --max | Opt-in atomic claims and deep techniques | At least 95% plus a second independent self-QA method | 2 |
All modes run the mechanical gate. Standard, deep and max also require 100% preservation of numbers, names, negations and scope qualifiers; confirmed loss blocks acceptance.
Without a flag, the skill can pick deep for instruction files and standard for human-facing docs. Unknown or mixed content gets one question; unanswered or headless runs use medium. Max needs a flag or maximum-compression intent; file type never selects it.
Prompt hints pick a mode without a flag: “compress for LLM” and “super compress” select deep, “safe compress” selects standard.
Good to know
- Deep and max rephrase and merge sections for LLM-only files (
CLAUDE.md, system prompts, agent and skill files). Never run them on user-facing docs such as a README or on precise API reference files; use standard or light there. - Review the diff after every deep or max run. Optimize only files you maintain: third-party files are overwritten on update.
Example
/brewtools:text-optimize -s README.md,docs/guide.md
The skill prints a PLAN block, snapshots both files, compresses each in place and reports lines, tokens and semantic match per file. Explicit depth flags win; ambiguous scope gets one question.
How it works
- Resolve
Parse the prompt, load the mode references, print the PLAN block with targets and depth.
- Snapshot
Require clean targets (or authorization), save original bytes in a private run directory.
- Assign
One writer per file, independent files in parallel.
- Compress
Inventory facts, deduplicate, rewrite per mode; checkpoint each owned draft.
- Verify
Run
text-guard.sh verify --no-restore, then the semantic review the mode requires. - Repair or refuse
Patch confirmed losses and re-review; unresolved loss blocks acceptance. Report measurements, not file bodies.
Snapshots and recovery #
Originals live under <RUN_DIR>/orig/<repo-relative-path>: readable, never rewritten or deleted. The report names the run directory.
verify --no-restore reports missing protected tokens and keeps the current file. A mechanical pass alone does not prove equivalence. Missing snapshot or state blocks acceptance.
Full restoration needs authorization and an owned-draft checkpoint matching current bytes. Without proof, or after intervening changes, the guard answers RESTORE_REFUSED: the file stays and the gap is reported. A checkpoint is never created at failure or restore time to get around this.
Deduplication and measured results #
- Same-file dedup keeps each distinct fact once; different numbers, conditions or scope are different facts. Cross-file dedup belongs to the main coordinator, which names the canonical owner.
- Faithful fusions and paraphrases count as kept/merged. Known-fact elisions count against the deep/max loss gate; word drops that distort meaning fail the fact check.
- Rule C.2 deletes “think step by step” phrasing.
- Reports give words, bytes and characters as separate measurements with the counting method. Token counts need a named tokenizer; characters divided by four is a rough proxy, never proven savings.
Permissions and marker blocks #
Pre-approved tools: Read, Bash(bash ${CLAUDE_SKILL_DIR}/scripts/text-guard.sh *), Grep, Glob, Agent, AskUserQuestion. The snapshot guard runs without a prompt; edits to your files follow your permission mode. When Claude starts the skill, Claude Code asks once for the Skill call in default mode; headless and dontAsk runs need Skill(brewtools:text-optimize *) in settings.
A block between another tool’s begin/end markers (for example <!-- BEGIN brewcode:semble --> … <!-- END brewcode:semble -->) belongs to the setup that wrote it. The skill and the text-optimizer agent never compress, move or delete it, and report it as managed by <setup>.
Related
Brewtools overview
Text Optimizer
Context Slim
Update: /brewtools:plugin-update, /reload-plugins, then /brewcode:setup-status upgrade - FAQ