prompt-optimizer
Transform vague prompts into precise, well-structured specifications using EARS (Easy Approach to Requirements Syntax) methodology. This skill should be used when users provide loose requirements, ambiguous feature descriptions, or need to enhance prompts for AI-generated code, products, or documents. Triggers include requests to "optimize my prompt", "improve this requirement", "make this more specific", or when raw requirements lack detail and structure.
1How It Works & Mechanism
Pure prompt orchestration: The entire mechanism relies on a "four-tier enhancement workflow"—transforming vague requirements using EARS syntax, grounding them in domain theories, extracting realistic examples, and packaging them into an enhanced prompt with a fixed structural skeleton.
**Four-layer enhancement process:** 1. **EARS syntax transformation** - Convert descriptive language to normative specifications 2. **Domain theory grounding** - Apply relevant industry frameworks (GTD, BJ Fogg, Gestalt, etc.) 3. **Example extraction** - Surface concrete use cases with real data 4. **Structured prompt generation** - Format using Role/Skills/Workflows/Examples/Formats framework
Implementation of the five EARS patterns: Ubiquitous, Event-driven, State-driven, Conditional, and Unwanted behavior each have fixed sentence patterns, paired with before/after comparisons and a transformation checklist (making conditions explicit, adding triggers, quantifying metrics, splitting atomic statements, removing ambiguous words).
**Five core patterns:** 1. **Ubiquitous**: `The system shall <action>` 2. **Event-driven**: `When <trigger>, the system shall <action>` 3. **State-driven**: `While <state>, the system shall <action>` 4. **Conditional**: `If <condition>, the system shall <action>` 5. **Unwanted behavior**: `If <condition>, the system shall prevent <unwanted action>`
Domain theory grounding mechanism: It first identifies the domain based on requirement keywords, selects 2–4 complementary theories from a 10-domain catalog, maps theoretical principles to specific features, and explicitly cites theory names within the prompt.
**Selection process:** 1. Identify primary domain from requirement keywords 2. Match to 2-4 complementary theories 3. Apply theory principles to specific features 4. Cite theories in enhanced prompt for credibility
The theory catalog itself is a major asset: 10 domains (productivity, behavior change, UX, gamification, learning, data visualization, e-commerce, information architecture, security, accessibility) containing 38 numbered theoretical entries, supported by a selection workflow ("pick 2–4 theories → map to features and workflows → cite for credibility") and a complete selection walkthrough.
## How to Select Theories 1. **Identify the domain** from user requirements 2. **Match to primary objective** (engagement, learning, conversion, etc.) 3. **Select 2-4 relevant theories** that complement each other 4. **Apply principles** to specific features and workflows 5. **Cite theories** in enhanced prompts to add credibility
Fixed five-section output skeleton: Role / Skills / Workflows / Examples / Formats, where examples strictly mandate realistic data ("Real data, not 'Example 1', 'Example 2'"), delivering a ready-to-copy Markdown specification.
- **Concrete examples**: Real data, not "Example 1", "Example 2"
Sequential, diagnostic six-step workflow: It begins by diagnosing weaknesses in the original requirement (overly broad, missing triggers, vague actions, lack of constraints), then progressively converts them to EARS, selects theories, extracts examples, generates the prompt, and presents the output in a fixed six-part structure.
### Step 1: Analyze Original Requirement Identify weaknesses: - **Overly broad** - "Add user authentication" → Missing password requirements, session management - **Missing triggers** - "Send notifications" → Missing when/why notifications trigger - **Ambiguous actions** - "Make it user-friendly" → No measurable usability criteria - **No constraints** - "Process payments" → Missing security, compliance requirements
Advanced handbook for complex requirements: Multi-stakeholder requirements (per-role EARS statements, explicit role constraints, and nested permissions), non-functional requirements (quantified thresholds across performance, security, scalability, and reliability), and complex conditional logic (nested AND/OR, precedence handling, and fallback branches).
1. Quantify constraints explicitly (no vague terms like "fast" or "secure") 2. Specify measurement methods (how to verify the requirement) 3. Include threshold values (acceptable ranges) 4. Define degradation behavior (what happens when thresholds are exceeded)
On-demand reference loading with a lean main skeleton: SKILL.md uses a Resources section explaining when to load each reference, sparing the model from reading everything at once (195-line main file + 1,014 lines of references).
- **`references/domain_theories.md`** - 40+ theories mapped to 10 domains (productivity, UX, gamification, learning, e-commerce, security, etc.)
2Core Capabilities
3External Dependencies
| Kind | Dependency / Endpoint |
|---|---|
| network | 出处引用链接(方法论来源展示,运行时脚本并不访问) |
4Recommended Governance & Evidence
- SKILL.md: Pure prompt directives and rule text, devoid of script execution and external side effects.
5Second-Pass Verification
- [ok] 资产面:是否存在脚本、hooks 或隐藏文件 — find prompt-optimizer -type f(含隐藏)只有 5 个文件:SKILL.md、references/{advanced_techniques,domain_theories,ears_syntax,examples}.md。无 scripts/、无 tests/、无 frontmatter 里的 allowed-tools 之外的配置键(frontmatter 仅 name/description 两键)。第一遍『纯 prompt』结论成立。
- [ok] 外部依赖反例:是否有漏掉的网络/凭证/执行面 — 全目录 token 扫描:无 curl/wget/urllib/requests/子进程调用/环境变量读取/写文件指令;https?:// 仅 3 处且都是出处引用(mp.weixin.qq.com 在 SKILL.md 与 examples.md),其余命中(token、api、secret 等)均出现在 EARS 示例文本里(如 password_reset_tokens 表、POST /api/auth/reset-password),是指被改写的示例需求而非 skill 的依赖。external_deps 因此只列出处引用一条,并注明运行时并不访问。
- [discrepancy] 宣传口径核对:domain_theories.md 是否真有 40+ 理论与 10 个域 — SKILL.md 的 Resources 段写 `40+ theories mapped to 10 domains`。第二遍用脚本统计:域数 10 属实(Productivity 5、Behavior Change 4、UX 6、Gamification 4、Learning 5、DataViz 3、E-commerce 3、IA 3、Security 3、Accessibility 2),但编号理论条目合计 38 条,未达 40+;若把跨域重复的 Self-Determination Theory、Gestalt Principles 去重,唯一理论数更少。属宣传性口径略偏大,不影响目录可用性,但『40+』不应被当作已核实的数字引用。
- [ok] EARS 五范式与 checklist 是否在两处一致 — SKILL.md 的 Step 2 列出五范式与 6 项 checklist;ears_syntax.md 对同一五范式给出 Format/English/Use when/Example 完整四段(含中文句式 `当 <trigger> 时,系统应 <action>`)与同一份扩展 checklist(多出『Define the actor』『Specify measurable outcomes』两项)、再加多条件事件与分支动作两种复杂形态。两处无冲突,reference 是超集。
- [ok] 输出格式声明 vs 实际骨架(夸大检查) — SKILL.md Step 5 的骨架(Role/Skills/Workflows/Examples/Formats)、Step 6 的六段式结果格式、examples.md 的 Transformation Pattern Template 三处骨架一致;description 宣称的『precise, well-structured specifications』由 Formats 段的『File types, structure requirements / Technical constraints / Deliverable checklist』承载。无未兑现承诺,也没有声称会验证产出。
- [ok] 非功能需求与复杂条件的具体落地方式是否真实存在 — advanced_techniques.md 实读:非功能四类各给 3-8 条量化范式(200ms/95%、1.5s FCP/90%、TLS 1.3、tokenize 卡号、retry 3×2s、1,000/s 排队、fraud score>70);复杂条件给出嵌套层级、显式布尔、优先级、括号与兜底五步与多段示例。第一遍『量化阈值』结论逐条可定位。
- [ok] 案例数量与出处标注 — examples.md 标题清单:Example 1 拖延症消除器、Example 2 电商商品页、Example 3 学习仪表盘、Example 4 密码重置安全,加一个 Transformation Pattern Template;SKILL.md Resources 段自述『Four complete transformation examples (procrastination app, e-commerce product page, learning dashboard, password reset security)』与实读标题逐一对应。出处标注在 SKILL.md 与 examples.md 出现两次且互为一致。
- [ok] 对『改写是否会被当作事实核验』的找反例 — 通读 5 个文件,未发现任何『验证需求真实性/可达性』的步骤或声明,也没有针对输出自检的机制(checklist 只约束句式与粒度)。故 verdict.risks 中『只保证写法规范不保证内容正确』成立,且不构成夸大——SKILL.md 也未做此承诺。
6Verdict & Scenarios
a62c59842d84fe47…