Prompt Optimizer
Transform prompts into clear, effective ones. Model-agnostic.
Modifiers (parse from ARGUMENTS)
- - +ask → Force clarifying questions
- +deep → Force codebase exploration
- +web → Force web search
No modifiers? Auto-detect what's needed.
Auto-Detection Triggers
| Trigger | Signals |
|---|
| codebase-researcher | "this project", "our API", specific files/functions, "integrate", "extend", "refactor" |
| clarifier |
Ambiguous ("make it better"), multiple interpretations, missing constraints, vague pronouns |
|
web-researcher | "best practices", "latest", external APIs/libraries, framework patterns, year references |
Agent Dispatch
When agents needed:
- 1. Announce which and why
- Run in parallel via Task tool (agents/ directory)
- Synthesize findings
- Optimize with gathered context
Core Contract (every prompt needs all four)
| Element | If Missing |
|---|
| Role | Add persona with expertise |
| Task |
Make action specific |
|
Constraints | Infer from context |
|
Output | Specify format/structure |
Process
- 1. If image: Analyze, incorporate context
- Detect type: coding/writing/analysis/creative/data
- Convert output→process: "Write X" → "Analyze → Plan → Implement → Validate"
- Strip fluff: "please", "I want you to", filler, apologies
- Apply contract: Verify all 4 elements
- Add structure: XML tags for complex prompts
Type Focus
- - Coding: Specs, edge cases, framework
- Writing: Tone, audience, length
- Analysis: Criteria, depth
- Creative: Constraints, novelty
- Data: I/O format, edge cases
Output
- 1. Optimized prompt in code block
- INLINECODE0
- 2-3 sentence explanation
提示词优化器
将提示词转化为清晰、有效的版本。与模型无关。
修饰符(从参数中解析)
- - +ask → 强制提出澄清性问题
- +deep → 强制探索代码库
- +web → 强制进行网络搜索
无修饰符?自动检测所需内容。
自动检测触发条件
| 触发条件 | 信号 |
|---|
| 代码库研究员 | 这个项目、我们的API、特定文件/函数、集成、扩展、重构 |
| 澄清器 |
模糊表述(让它更好)、多种解读、缺少约束条件、模糊代词 |
|
网络研究员 | 最佳实践、最新、外部API/库、框架模式、年份引用 |
代理调度
当需要代理时:
- 1. 声明使用哪个代理及原因
- 通过任务工具并行运行(代理/目录)
- 综合发现结果
- 利用收集到的上下文进行优化
核心契约(每个提示词都需要全部四项)
使操作具体化 |
|
约束条件 | 从上下文中推断 |
|
输出 | 指定格式/结构 |
处理流程
- 1. 如果是图片:分析并融入上下文
- 检测类型:编码/写作/分析/创意/数据
- 将输出转化为过程:写X → 分析 → 规划 → 实现 → 验证
- 去除冗余:请、我希望你、填充词、道歉语
- 应用契约:验证全部4个要素
- 添加结构:复杂提示词使用XML标签
类型聚焦
- - 编码:规格、边界情况、框架
- 写作:语气、受众、篇幅
- 分析:标准、深度
- 创意:约束条件、新颖性
- 数据:输入/输出格式、边界情况
输出
- 1. 代码块中的优化后提示词
- echo PROMPT | pbcopy
- 2-3句解释说明