text-optimizer
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseText & File Optimizer
文本与文件优化工具
Step 0: Load Rules
步骤0:加载规则
REQUIRED: Readbefore ANY optimization. If file not found -> ERROR + STOP. Do not proceed without rules reference.references/rules-review.md
必填项:在进行任何优化前,请阅读。 若未找到该文件 → 报错并终止操作。无规则参考文件时不得继续执行。references/rules-review.md
Modes
模式说明
Parse : / | / | no flag -> medium (default).
$ARGUMENTS-l--light-d--deep| Mode | Flag | Scope |
|---|---|---|
| Light | | Text cleanup only — structure, lists, flow untouched |
| Medium | (default) | Balanced restructuring — all standard transformations |
| Deep | | Max density — rephrase, merge, compress aggressively |
解析参数:/ | / | 无参数 → 中等模式(默认)。
$ARGUMENTS-l--light-d--deep| 模式 | 参数 | 适用范围 |
|---|---|---|
| 轻量模式 | | 仅清理文本——不改动结构、列表和流程 |
| 中等模式 | (默认) | 平衡重构——应用所有标准转换规则 |
| 深度模式 | | 最大密度——主动改写、合并、压缩内容 |
Rule ID Quick Reference
规则ID速查
| 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 | 适用范围 |
|---|---|---|
| Claude行为规范 | C.1-C.6 | 严格遵循指令、避免使用"think"、正向表述、匹配风格、描述性指令、避免过度设计 |
| Token效率 | T.1-T.8 | 表格化、项目符号、单行规则、行内代码、缩写、冗余内容、逗号列表、箭头符号 |
| 结构优化 | S.1-S.8 | XML标签、祈使句、单一信息源、上下文/动机说明、块引用、渐进式披露、术语一致性、引用深度 |
| 引用完整性 | R.1-R.3 | 验证文件路径、检查URL、线性化循环引用 |
| 感知优化 | P.1-P.6 | 规则旁附示例、层级结构、关键词加粗、标准符号、指令顺序、默认优先于选项 |
ID-to-Rule Mapping
ID与规则对应表
| 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 | 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 |
| ID | 规则内容 | ID | 规则内容 |
|---|---|---|---|
| C.1 | 严格遵循字面指令 | C.2 | 避免使用"think"一词 |
| C.3 | 正向表述(用"请做Y"而非"不要做X") | C.4 | 提示词风格与输出匹配 |
| C.5 | 描述性指令优于强调性指令 | C.6 | 避免过度设计 |
| T.1 | 多列内容用表格替代 prose | 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 | 默认选项优先于其他选项 |
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 |
| 模式 | 应用规则 | 备注 |
|---|---|---|
| 轻量模式 | C.1-C.6, T.6, R.1-R.3, P.1-P.4 | 仅清理文本——不进行结构重构 |
| 中等模式 | 所有规则(C + T + S + R + P) | 平衡转换策略 |
| 深度模式 | 所有规则 + 主动改写 | 合并章节、最大化压缩 |
Usage
使用方法
| Input | Action |
|---|---|
| No args | Prompt user for file or folder path |
| Single path | Process file directly |
| Process files sequentially |
| Light mode — text cleanup only |
| Deep mode — max compression |
| All |
| 输入内容 | 执行操作 |
|---|---|
| 无参数 | 提示用户输入文件或文件夹路径 |
| 单个路径 | 直接处理该文件 |
| 按顺序处理多个文件 |
| 轻量模式——仅清理文本 |
| 深度模式——最大化压缩 |
| 处理目录下所有 |
File Processing
文件处理流程
Input Parsing
输入解析
| Input | Action |
|---|---|
| No args | Prompt user for file or folder path |
| Single path | Process directly |
| Process files sequentially |
| 输入内容 | 执行操作 |
|---|---|
| 无参数 | 提示用户输入文件或文件夹路径 |
| 单个路径 | 直接处理 |
| 按顺序处理多个文件 |
Execution Flow
执行流程
- Read — load all optimization rules
references/rules-review.md - Read target file(s)
- Analyze: identify type (prompt, docs, agent, skill), note critical info and cross-references
- Apply rules by mode (see Mode-to-Rules Mapping)
- Edit file with optimized content
- Generate optimization report
- 读取——加载所有优化规则
references/rules-review.md - 读取目标文件
- 分析:识别类型(提示词、文档、Agent、Skill),标记关键信息和交叉引用
- 根据模式应用规则(参见模式与规则映射表)
- 用优化后的内容编辑原文件
- 生成优化报告
Quality Checklist
质量检查清单
Before
优化前
- Read entire text
- Identify type (prompt, docs, agent, skill)
- Note critical info and cross-references
- 通读全文
- 识别内容类型(提示词、文档、Agent、Skill)
- 标记关键信息和交叉引用
During — Apply by Mode
优化中——按模式应用规则
| 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 | Yes | Yes | Yes |
| 检查项 | 轻量模式 | 中等模式 | 深度模式 |
|---|---|---|---|
| C.1-C.6(Claude行为规范) | 是 | 是 | 是 |
| T.6(移除冗余内容) | 是 | 是 | 是 |
| T.1-T.5, T.7-T.8(Token压缩) | - | 是 | 是 |
| S.1-S.8(结构/清晰度优化) | - | 是 | 是 |
| R.1-R.3(引用完整性) | 是 | 是 | 是 |
| P.1-P.4(LLM感知优化) | 是 | 是 | 是 |
| 主动改写 | - | - | 是 |
| 无信息丢失 | 是 | 是 | 是 |
After
优化后
- All facts preserved
- Logic consistent
- References valid (R.1-R.3)
- Tokens reduced
- 所有事实完整保留
- 逻辑保持一致
- 引用有效(符合R.1-R.3规则)
- Token用量减少
Output Format
输出格式
markdown
undefinedmarkdown
undefinedOptimization Report: [filename]
优化报告:[文件名]
| Metric | Before | After | Change |
|---|---|---|---|
| Lines | X | Y | -Z% |
| Tokens | ~X | ~Y | -Z% |
| 指标 | 优化前 | 优化后 | 变化量 |
|---|---|---|---|
| 行数 | X | Y | -Z% |
| Token数 | ~X | ~Y | -Z% |
Rules Applied
应用的规则
- [Rule IDs]: [Description of changes]
Issues Found & Fixed
发现并修复的问题
Cross-Reference Verification
交叉引用验证
- All file refs valid (R.1)
- All URLs checked (R.2)
- No circular refs (R.3)
Full development platform: 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-brewcodeundefined- 所有文件引用有效(R.1)
- 所有URL已检查(R.2)
- 无循环引用(R.3)
完整开发平台: brewcode —— 无限专注任务、14个Agent、共识评审、知识持久化。
安装方式:
claude plugin marketplace add https://github.com/kochetkov-ma/claude-brewcode && claude plugin install brewcode@claude-brewcodeundefinedAnti-Patterns
反模式示例
| 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) |
| 需避免的操作 | 原因 |
|---|---|
| 删除所有示例 | 损害泛化能力(违反P.1) |
| 过度缩写 | 降低可读性(T.5的注意事项) |
| 通用压缩 | 领域术语至关重要 |
| 过度激进的表述 | 触发Opus 4.5的过度响应(违反C.5) |
| 扁平化层级结构 | 丢失结构信息(违反P.2) |
| "不要做X"的表述方式 | 效果不如"请做Y"(违反C.3) |
| 过度设计提示词 | Opus 4.5会严格遵循字面指令(违反C.6) |
| 单个提示词承载过多内容 | 分散注意力、导致幻觉(违反S.3) |
| 过度关注措辞 | 结构比用词更重要(违反T.1) |