optimize-md

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Document Optimizer

文档优化器

Read, optimize, and rewrite markdown documents for token efficiency, structural clarity, and LLM parseability. The target file is provided as a file path argument.
读取、优化并重写Markdown文档,提升Token效率、结构清晰度与LLM可解析性。目标文件通过文件路径参数指定。

Workflow

工作流

  1. Read the file at the provided path. If no path is provided, ask for one
  2. Analyze the document for optimization opportunities using the principles below
  3. Rewrite the file in place with all optimizations applied
  4. Report a brief summary: original line count, new line count, and key changes made
  1. 读取文件:读取指定路径下的文件。若未提供路径,则询问用户获取
  2. 分析:依据以下原则分析文档的优化空间
  3. 重写:在原文件中应用所有优化措施
  4. 报告:生成简要总结,包括原行数、新行数以及主要修改内容

Optimization Principles

优化原则

Token Economics

Token经济性

Challenge every sentence: "Does this earn its tokens?" Remove content that restates common knowledge, repeats itself, or adds no actionable value.
Remove decorative language. No "please note", "it's worth mentioning", "remember that", "importantly".
Eliminate filler transitions. "Additionally", "furthermore", "in other words", "as mentioned above".
Remove hedging. "Consider", "try to", "when possible", "generally speaking", "it depends".
质疑每一句话:"这段内容是否值得占用Token?" 删除重复常识、自我重复或无实际价值的内容。
删除装饰性表述,如“请注意”“值得一提的是”“请记住”“重要的是”等。
删除填充性过渡词,如“此外”“再者”“换句话说”“如上所述”等。
删除模糊性表述,如“考虑”“尽量”“可能的话”“一般而言”“视情况而定”等。

Structural Optimization

结构优化

TechniqueApply When
Convert prose to tablesComparing options, listing attributes, or mapping inputs to outputs
Convert prose to listsContent contains discrete, parallel, independent items
Keep proseExplaining relationships, conditional logic, or rationale
Merge sectionsMultiple sections cover the same concept
Remove sectionsContent restates framework docs or common knowledge
Flatten unnecessary nesting. Collapse single-item subsections into their parent.
Place critical information first within each section. Most important content at the top.
End sections decisively. No trailing "etc.", "and so on", or "and more".
技巧适用场景
prose转表格对比选项、列出属性或映射输入输出时
prose转列表内容包含独立、平行的离散项时
保留 prose解释关系、条件逻辑或原理时
合并章节多个章节覆盖同一概念时
删除章节内容重复框架文档或常识时
扁平化不必要的嵌套结构,将仅含单个子项的子章节合并至父章节。
每个章节内将关键信息前置,最重要的内容放在顶部。
章节结尾要干脆,避免使用“等等”“诸如此类”等表述。

Sentence Compression

句子压缩

Remove filler words and passive voice:
  • Before: "It is recommended that you should make sure to always validate user input"
  • After: "Validate user input at API boundaries"
Combine related statements:
  • Before: "Use TypeScript for all new files. Make sure to add type annotations. Enable strict mode in tsconfig."
  • After: "Use TypeScript strict mode with explicit type annotations for all new files"
Remove redundant qualifiers:
  • Before: "This is a very important and critical step that must always be done"
  • After: "Required step"
删除冗余词汇与被动语态:
  • 优化前:"It is recommended that you should make sure to always validate user input"
  • 优化后:"在API边界验证用户输入"
合并相关表述:
  • 优化前:"Use TypeScript for all new files. Make sure to add type annotations. Enable strict mode in tsconfig."
  • 优化后:"所有新文件使用TypeScript严格模式并添加显式类型注解"
删除冗余限定词:
  • 优化前:"This is a very important and critical step that must always be done"
  • 优化后:"必填步骤"

Content Filtering

内容过滤

Remove entirely:
  • Welcome messages, introductions, background history
  • Motivational statements ("This will help you write better code!")
  • Content the model already knows (framework basics, language syntax)
  • Hypothetical future scenarios ("If we ever migrate to...")
  • Time-sensitive references without dates
  • Redundant examples that demonstrate the same concept
Preserve:
  • Domain-specific knowledge the model lacks
  • Concrete examples demonstrating non-obvious patterns
  • Decision criteria and trade-off analysis
  • Exact commands, configs, and code snippets
  • Constraints and prohibited actions
完全删除:
  • 欢迎语、引言、背景历史
  • 励志性语句(如“这将帮助你写出更好的代码!”)
  • 模型已掌握的内容(框架基础、语言语法)
  • 假设性未来场景(如“如果我们迁移到……”)
  • 无日期的时效性参考内容
  • 重复演示同一概念的示例
保留:
  • 模型不具备的领域特定知识
  • 演示非明显模式的具体示例
  • 决策标准与权衡分析
  • 精确的命令、配置与代码片段
  • 约束条件与禁止操作

Formatting Cleanup

格式清理

Use language-labeled code blocks. Never use unlabeled fences.
Use consistent heading hierarchy. No skipped levels (h2 -> h4).
Remove excessive emphasis. Bold only for hard constraints where violation causes failure. Limit to 10% of content.
Use one blank line between sections. Remove consecutive blank lines.
Standardize list markers within each list (all
-
or all
*
, not mixed).
使用带语言标签的代码块,禁止使用无标签的代码围栏。
保持一致的标题层级,禁止跳过层级(如从h2直接跳到h4)。
减少过度强调,仅对违反会导致失败的硬性约束使用加粗,占比不超过内容的10%。
章节间使用一个空行分隔,删除连续空行。
统一每个列表的标记符(全部使用
-
或全部使用
*
,禁止混合使用)。

Terminology Consistency

术语一致性

Identify synonyms used for the same concept. Choose the most precise term and use it throughout.
  • Before: alternating "endpoint", "route", "URL", "path" for the same concept
  • After: consistently "endpoint" throughout
识别同一概念的同义词,选择最精准的术语并统一使用。
  • 优化前:交替使用“endpoint”“route”“URL”“path”指代同一概念
  • 优化后:全程统一使用“endpoint”

Constraints

约束条件

  • Preserve all factual content and meaning. Compression must not alter semantics
  • Preserve code blocks verbatim unless they contain obvious errors
  • Preserve document title (h1 heading). Rephrase for concision only if verbose
  • Do not add new content. Optimization removes and restructures; it does not invent
  • Do not add commentary or annotations to the output file
  • Write the optimized document directly to the source file
  • 保留所有事实内容与含义:压缩不得改变语义
  • 完整保留代码块:除非存在明显错误
  • 保留文档标题(h1标题):仅在过于冗长时可精简表述
  • 不得添加新内容:优化仅进行删除与重构,不得创造新内容
  • 不得在输出文件中添加注释或说明
  • 直接将优化后的文档写入源文件