Text Optimize

sonnet session

Quick reference

FieldValue
Command/brewtools:text-optimize
Arguments[-l|-d] [file|folder|path1,path2]-l light, -d deep, no flag = medium
Modelsonnet
Contextsession
ToolsRead, Write, Edit, Grep, Glob, Task

Modes

ModeFlagBest forWhat changes
Light-lCritical files, production promptsFiller removal, tone fixes, reference checks — structure untouched
Medium(default)General docs, agents, skillsTables, bullets, merged sections, full rule set
Deep-dLarge prompts where every token countsAggressive rephrasing, max compression — always review diff after

Usage examples

# Single file, medium mode (default)
/brewtools:text-optimize CLAUDE.md

# Light mode on a production agent -- safe, minimal changes
/brewtools:text-optimize -l .claude/agents/reviewer.md

# Deep mode on a verbose prompt you want compressed
/brewtools:text-optimize -d prompts/analysis-prompt.md

# Multiple files processed in parallel
/brewtools:text-optimize agents/planner.md, agents/executor.md, CLAUDE.md

# All markdown files in a directory
/brewtools:text-optimize -d agents/

What it does

  • Converts verbose prose to dense tables (up to 3x more token-efficient)
  • Removes filler words and passive constructions
  • Restructures numbered lists to bullets where order does not matter
  • Converts multi-line code blocks to inline code when a single expression suffices
  • Merges redundant or overlapping sections
  • Applies positive framing (“do Y” instead of “don’t do X”)
  • Verifies all file paths (R.1), URLs (R.2), and circular references (R.3)
  • Uses standard abbreviations in tables only (full words in prose)

Rule categories

CategoryRule IDsScope
Claude behaviorC.1-C.6Literal following, avoid “think”, positive framing, match style, descriptive instructions, overengineering
Token efficiencyT.1-T.8Tables, bullets, one-liners, inline code, abbreviations, filler, comma lists, arrows
StructureS.1-S.8XML tags, imperative, single source, context/motivation, blockquotes, progressive disclosure, consistent terminology, ref depth
Reference integrityR.1-R.3Verify file paths, check URLs, linearize circular refs
PerceptionP.1-P.6Examples near rules, hierarchy, bold keywords, standard symbols, instruction order, default over options

Mode-to-rules mapping

ModeAppliesNotes
LightC.1-C.6, T.6, R.1-R.3, P.1-P.4Text cleanup only — no restructuring
MediumAll rules (C + T + S + R + P)Balanced transformations
DeepAll rules + aggressive rephrasingMerge sections, max compression

Output

Each file produces an optimization report:

SectionContents
MetricsLines and tokens — before, after, percent reduction
Rules AppliedWhich rule IDs were used and what changed
Issues FoundBroken references, redundancies, structural problems — and how they were fixed
Cross-Reference CheckVerification status for file paths, URLs, circular refs

Files are modified in-place. The report is printed to the conversation.

Tips

Start with light mode (-l) on important files to preview changes. Review deep mode diffs carefully — aggressive rephrasing can alter meaning in domain-specific content. Parallel processing kicks in automatically for multiple files or directories.