Text Optimize
sonnet sessionQuick reference
| Field | Value |
|---|---|
| Command | /brewtools:text-optimize |
| Arguments | [-l|-d] [file|folder|path1,path2] — -l light, -d deep, no flag = medium |
| Model | sonnet |
| Context | session |
| Tools | Read, Write, Edit, Grep, Glob, Task |
Modes
| Mode | Flag | Best for | What changes |
|---|---|---|---|
| Light | -l | Critical files, production prompts | Filler removal, tone fixes, reference checks — structure untouched |
| Medium | (default) | General docs, agents, skills | Tables, bullets, merged sections, full rule set |
| Deep | -d | Large prompts where every token counts | Aggressive 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
| Category | Rule IDs | Scope |
|---|---|---|
| Claude behavior | C.1-C.6 | Literal following, avoid “think”, positive framing, match style, descriptive instructions, overengineering |
| Token efficiency | T.1-T.8 | Tables, bullets, one-liners, inline code, abbreviations, filler, comma lists, arrows |
| Structure | S.1-S.8 | XML tags, imperative, single source, context/motivation, blockquotes, progressive disclosure, consistent terminology, ref depth |
| Reference integrity | R.1-R.3 | Verify file paths, check URLs, linearize circular refs |
| Perception | P.1-P.6 | Examples near rules, hierarchy, bold keywords, standard symbols, instruction order, default over options |
Mode-to-rules mapping
| Mode | Applies | Notes |
|---|---|---|
| Light | C.1-C.6, T.6, R.1-R.3, P.1-P.4 | Text cleanup only — no restructuring |
| Medium | All rules (C + T + S + R + P) | Balanced transformations |
| Deep | All rules + aggressive rephrasing | Merge sections, max compression |
Output
Each file produces an optimization report:
| Section | Contents |
|---|---|
| Metrics | Lines and tokens — before, after, percent reduction |
| Rules Applied | Which rule IDs were used and what changed |
| Issues Found | Broken references, redundancies, structural problems — and how they were fixed |
| Cross-Reference Check | Verification 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.