Plugin: kochetkov-ma/claude-brewcode
Text Optimizer
Reduces token count in prompts, docs, and agent instructions by 20–40% without losing meaning. Applies 52 research-backed rules across 8 categories: Claude behavior, token efficiency, structure, deduplication, reference integrity, perception, LLM comprehension, aggressive lossy (deep only).
Benefits: cheaper API calls · faster model responses · clearer LLM instructions · fewer hallucinations
Examples:
Skill text is written for LLM consumption and optimized for token efficiency.
Text & File Optimizer
Step 0: Load Rules
REQUIRED: Read
references/rules-review.mdbefore ANY optimization. If file not found -> ERROR + STOP. Do not proceed without rules reference.
Modes
Parse $ARGUMENTS: -l/--light | -d/--deep | no flag -> medium (default).
Rule ID Quick Reference
ID-to-Rule Mapping
Mode-to-Rules Mapping
Loss Budget per Mode
Content essence is untouchable at light/medium; small deliberate loss only at deep — explicitly reported. Dedup-merged facts count as preserved, never as loss.
Deduplication Pass (All Modes)
Runs during analysis, BEFORE compression:
- Build fact inventory: one atomic fact per line, numbered
- Flag facts appearing 2+ times (exact, reworded, or cross-format)
- Classify each repeat: intentional emphasis (marked critical/blockquote, or start+end sandwich) vs accidental
- Accidental -> merge to single MOST SPECIFIC statement (D.1-D.3), best position wins
- Intentional -> cap at 2: full form early + <=1-line echo at END (D.4)
- Wrong-merge guard (D.6): differing scope/numbers/conditions = NOT duplicates — keep both
Usage
File Processing
Input Parsing
Execution Flow
- Read
references/rules-review.md— load all optimization rules - Read target file(s)
- Analyze: identify type (prompt, docs, agent, skill), note critical info and cross-references
3a. Dedup pass (D.1-D.6): fact inventory -> merge accidental dups -> cap intentional emphasis at 2/doc
3b. Deep only: aggressive lossy pass (A.1 fusion -> A.3 paraphrase -> A.2 word drop -> A.4 elision); A.2/A.4 drops -> loss ledger; A.4 counts as
elided-knownagainst the >=95% gate, A.2 is gate-neutral - Apply rules by mode (see Mode-to-Rules Mapping)
- Edit file with optimized content 5a. Medium: self-check — re-check fact inventory against output, zero loss required 5b. Deep mode: self-verify — fact inventory original vs compressed, (kept + merged)/total >= 95%; merged = preserved; warn with loss list if below
- Generate optimization report
Quality Checklist
Before
- Read entire text
- Identify type (prompt, docs, agent, skill)
- Note critical info and cross-references
During — Apply by Mode
After
- All facts preserved
- Logic consistent
- References valid (R.1-R.3)
- Tokens reduced


