text-optimizer by kochetkov-ma/claude-brewcode
npx skills add https://github.com/kochetkov-ma/claude-brewcode --skill text-optimizerPlugin: kochetkov-ma/claude-brewcode
在不损失原意的前提下,将提示词、文档和智能体指令的令牌数量减少 20–40%。应用 41 条基于研究的规则,涵盖 6 个类别:Claude 行为、令牌效率、结构、引用完整性、感知、LLM 理解。
优势: 降低 API 调用成本 · 加速模型响应 · 使 LLM 指令更清晰 · 减少幻觉
示例:
/text-optimize prompt.md # 单个文件,中等模式(默认)
/text-optimize -d agents/ # 深度模式 — 处理目录下所有 .md 文件
技能文本专为 LLM 理解而编写,并针对令牌效率进行了优化。
必需: 在进行任何优化之前,请先阅读
references/rules-review.md。如果文件未找到 -> 报错并停止。没有规则参考文件不得继续。
解析 $ARGUMENTS:-l/ | / | 无标志 -> 中等模式(默认)。
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
--light-d--deep| 模式 | 标志 | 范围 |
|---|---|---|
| 轻量 | -l, --light | 仅文本清理 — 结构、列表、流程保持不变 |
| 中等 | (默认) | 平衡重构 — 应用所有标准转换 |
| 深度 | -d, --deep | 最大密度 — 积极地进行重述、合并、压缩 |
| 类别 | 规则 ID | 范围 |
|---|---|---|
| Claude 行为 | C.1-C.6 | 字面遵循、避免"思考"、积极措辞、匹配风格、描述性指令、过度工程 |
| 令牌效率 | T.1-T.8 | 表格、项目符号、单行规则、行内代码、缩写、填充词、逗号分隔列表、箭头 |
| 结构 | S.1-S.8 | XML 标签、祈使句、单一信息源、上下文/动机、块引用、渐进式披露、术语一致、引用深度 |
| 引用完整性 | R.1-R.3 | 验证文件路径、检查 URL、线性化循环引用 |
| 感知 | P.1-P.6 | 规则旁附示例、层级结构、关键词加粗、标准符号、指令顺序、默认优于选项 |
| ID | 规则 | ID | 规则 |
|---|---|---|---|
| C.1 | 字面遵循指令 | C.2 | 避免使用"思考"一词 |
| C.3 | 积极措辞(做 Y 而不是不要做 X) | C.4 | 使提示风格与输出匹配 |
| C.5 | 描述性而非强调性指令 | C.6 | 防止过度工程 |
| T.1 | 表格优于段落(多列) | T.2 | 项目符号优于编号列表(约 5-10%) |
| T.3 | 规则使用单行表述 | T.4 | 行内代码优于代码块 |
| T.5 | 标准缩写(仅限表格) | T.6 | 移除填充词 |
| T.7 | 逗号分隔的行内列表 | T.8 | 使用箭头表示流程 |
| S.1 | 使用 XML 标签划分章节 | S.2 | 使用祈使句形式 |
| S.3 | 单一信息源 | S.4 | 添加上下文/动机 |
| S.5 | 关键信息使用块引用 | S.6 | 渐进式披露 |
| R.1 | 验证文件路径 | R.2 | 检查 URL |
| R.3 | 线性化循环引用 | P.1 | 规则旁附示例 |
| P.2 | 通过标题建立层级(最多 3-4 级) | P.3 | 关键词加粗(每 100 行最多 2-3 个) |
| P.4 | 使用标准符号(→ + / ✅❌⚠️) | ||
| S.7 | 术语一致 | S.8 | 一级引用深度 |
| P.5 | 指令顺序(锚定) | P.6 | 默认优于选项 |
| 模式 | 应用的规则 | 备注 |
|---|---|---|
| 轻量 | C.1-C.6, T.6, R.1-R.3, P.1-P.4 | 仅文本清理 — 无结构重构 |
| 中等 | 所有规则(C + T + S + R + P) | 平衡的转换 |
| 深度 | 所有规则 + 积极重述 | 合并章节,最大压缩 |
| 输入 | 操作 |
|---|---|
| 无参数 | 提示用户输入文件或文件夹路径 |
| 单个路径 | 直接处理文件 |
path1, path2 | 顺序处理文件 |
-l file.md | 轻量模式 — 仅文本清理 |
-d file.md | 深度模式 — 最大压缩 |
folder/ | 处理目录下所有 .md 文件 |
| 输入 | 操作 |
|---|---|
| 无参数 | 提示用户输入文件或文件夹路径 |
| 单个路径 | 直接处理 |
path1, path2 | 顺序处理文件 |
references/rules-review.md — 加载所有优化规则| 检查项 | 轻量 | 中等 | 深度 |
|---|---|---|---|
| C.1-C.6 (Claude 行为) | 是 | 是 | 是 |
| T.6 (移除填充词) | 是 | 是 | 是 |
| T.1-T.5, T.7-T.8 (令牌压缩) | - | 是 | 是 |
| S.1-S.8 (结构/清晰度) | - | 是 | 是 |
| R.1-R.3 (引用完整性) | 是 | 是 | 是 |
| P.1-P.4 (LLM 感知) | 是 | 是 | 是 |
| 积极重述 | - | - | 是 |
| 无信息丢失 | 是 | 是 | 是 |
## 优化报告:[文件名]
| 指标 | 优化前 | 优化后 | 变化 |
|--------|--------|-------|--------|
| 行数 | X | Y | -Z% |
| 令牌数 | ~X | ~Y | -Z% |
### 应用的规则
- [规则 ID]:[变更描述]
### 发现并修复的问题
- [问题]:[解决方案]
### 交叉引用验证
- [x] 所有文件引用有效(R.1)
- [x] 所有 URL 已检查(R.2)
- [x] 无循环引用(R.3)
---
**完整开发平台:** [brewcode](https://github.com/kochetkov-ma/claude-brewcode) — 无限聚焦任务,14 个智能体,法定人数评审,知识持久化。
安装:`claude plugin marketplace add https://github.com/kochetkov-ma/claude-brewcode && claude plugin install brewcode@claude-brewcode`
| 避免 | 原因 |
|---|---|
| 移除所有示例 | 损害泛化能力(P.1) |
| 过度缩写 | 降低可读性(T.5 注意事项) |
| 通用压缩 | 领域术语很重要 |
| 过度激进的语言 | Opus 4.5 容易过度触发(C.5) |
| 扁平化层级 | 失去结构(P.2) |
| "不要做 X" 的措辞 | 不如"做 Y"有效(C.3) |
| 过度设计提示词 | Opus 4.5 会字面遵循(C.6) |
| 单条提示词承载过多 | 注意力分散,产生幻觉(S.3) |
| 过度关注措辞 | 结构 > 措辞选择(T.1) |
每周安装量
1.8K
仓库
GitHub 星标数
16
首次出现
2026年2月22日
安全审计
安装于
cursor1.7K
opencode1.7K
codex1.7K
github-copilot1.7K
kimi-cli1.7K
amp1.7K
Plugin: kochetkov-ma/claude-brewcode
Reduces token count in prompts, docs, and agent instructions by 20–40% without losing meaning. Applies 41 research-backed rules across 6 categories: Claude behavior, token efficiency, structure, reference integrity, perception, LLM comprehension.
Benefits: cheaper API calls · faster model responses · clearer LLM instructions · fewer hallucinations
Examples:
/text-optimize prompt.md # single file, medium mode (default)
/text-optimize -d agents/ # deep mode — all .md files in directory
Skill text is written for LLM consumption and optimized for token efficiency.
REQUIRED: Read
references/rules-review.mdbefore ANY optimization. If file not found -> ERROR + STOP. Do not proceed without rules reference.
Parse $ARGUMENTS: -l/--light | -d/--deep | no flag -> medium (default).
| Mode | Flag | Scope |
|---|---|---|
| Light | -l, --light | Text cleanup only — structure, lists, flow untouched |
| Medium | (default) | Balanced restructuring — all standard transformations |
| Deep | -d, --deep | Max density — rephrase, merge, compress aggressively |
| 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 |
| ID | Rule | ID | Rule |
|---|---|---|---|
| C.1 | Literal instruction following | C.2 | Avoid "think" word |
| C.3 | Positive framing (do Y not don't X) | C.4 | Match prompt style to output |
| C.5 | Descriptive over emphatic instructions | C.6 | Overengineering prevention |
| T.1 | Tables over prose (multi-column) | T.2 | Bullets over numbered (~5-10%) |
| T.3 | One-liners for rules | T.4 | Inline code over blocks |
| T.5 | Standard abbreviations (tables only) | T.6 | Remove filler words |
| T.7 | Comma-separated inline lists | T.8 |
| 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 |
| Input | Action |
|---|---|
| No args | Prompt user for file or folder path |
| Single path | Process file directly |
path1, path2 | Process files sequentially |
-l file.md | Light mode — text cleanup only |
-d file.md | Deep mode — max compression |
folder/ | All .md files in directory |
| Input | Action |
|---|---|
| No args | Prompt user for file or folder path |
| Single path | Process directly |
path1, path2 | Process files sequentially |
references/rules-review.md — load all optimization rules| Check | Light | Med | Deep |
|---|---|---|---|
| C.1-C.6 (Claude behavior) | Yes | Yes | Yes |
| T.6 (filler removal) | Yes | Yes | Yes |
| T.1-T.5, T.7-T.8 (token compression) | - | Yes | Yes |
| S.1-S.8 (structure/clarity) | - | Yes | Yes |
| R.1-R.3 (reference integrity) | Yes | Yes | Yes |
| P.1-P.4 (LLM perception) | Yes | Yes | Yes |
| Aggressive rephrasing | - | - | Yes |
| No information loss |
## Optimization Report: [filename]
| Metric | Before | After | Change |
|--------|--------|-------|--------|
| Lines | X | Y | -Z% |
| Tokens | ~X | ~Y | -Z% |
### Rules Applied
- [Rule IDs]: [Description of changes]
### Issues Found & Fixed
- [Issue]: [Resolution]
### Cross-Reference Verification
- [x] All file refs valid (R.1)
- [x] All URLs checked (R.2)
- [x] No circular refs (R.3)
---
**Full development platform:** [brewcode](https://github.com/kochetkov-ma/claude-brewcode) — infinite focus tasks, 14 agents, quorum reviews, knowledge persistence.
Install: `claude plugin marketplace add https://github.com/kochetkov-ma/claude-brewcode && claude plugin install brewcode@claude-brewcode`
| Avoid | Why |
|---|---|
| Remove all examples | Hurts generalization (P.1) |
| Over-abbreviate | Reduces readability (T.5 caveat) |
| Generic compression | Domain terms matter |
| Over-aggressive language | Opus 4.5 overtriggers (C.5) |
| Flatten hierarchy | Loses structure (P.2) |
| "Don't do X" framing | Less effective than "Do Y" (C.3) |
| Overengineer prompts | Opus 4.5 follows literally (C.6) |
| Overload single prompts | Divided attention, hallucinations (S.3) |
| Over-focus on wording | Structure > word choice (T.1) |
Weekly Installs
1.8K
Repository
GitHub Stars
16
First Seen
Feb 22, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykWarn
Installed on
cursor1.7K
opencode1.7K
codex1.7K
github-copilot1.7K
kimi-cli1.7K
amp1.7K
Vercel Web界面规范检查工具 - 自动检测代码是否符合Web设计指南
202,600 周安装
Coinbase Pay-for-Service:使用 USDC 自动支付 API 调用费用的完整指南
1,600 周安装
Three.js 纹理加载与配置教程 - 从基础到高级纹理处理指南
1,600 周安装
TypeScript E2E 测试指南:使用 Docker 和 GWT 模式进行端到端测试
1,600 周安装
AI代码审查分析工具 - 自动化代码质量、安全、性能审查最佳实践
1,600 周安装
Docker模式最佳实践:多阶段构建、Docker Compose配置与容器化开发指南
1,800 周安装
Claude 策略性压缩技能:智能管理上下文,提升AI编程效率与性能
1,700 周安装
| Arrows for flow notation |
| S.1 | XML tags for sections | S.2 | Imperative form |
| S.3 | Single source of truth | S.4 | Add context/motivation |
| S.5 | Blockquotes for critical | S.6 | Progressive disclosure |
| R.1 | Verify file paths | R.2 | Check URLs |
| R.3 | Linearize circular refs | P.1 | Examples near rules |
| P.2 | Hierarchy via headers (max 3-4) | P.3 | Bold for keywords (max 2-3/100 lines) |
| P.4 | Standard symbols (→ + / ✅❌⚠️) |
| S.7 | Consistent terminology | S.8 | One-level reference depth |
| P.5 | Instruction order (anchoring) | P.6 | Default over options |
| Yes |
| Yes |
| Yes |