prompt-refiner
A prompt is not just wording polish — it is task clarification, boundary setting, and verification shaping.
Refine vague user prompts into clear, actionable, verifiable versions. Show the refined result and let the user confirm before execution. Works as a closed loop with session-learner, which captures user choice preferences over time.
Quick Reference
| Situation | Action |
|---|
| Vague request | Refine first |
| Complete prompt |
Execute directly, no popup |
| Substantial improvement | Show refined + popup choose |
| No substantial improvement | Skip popup, execute original |
| User says "just do it" | Auto-apply |
| User says "only optimize" | Return refined, don't execute |
Continue Modes
- 1. Popup-confirm (default) — Show refined prompt, popup to choose refined vs original, execute after choice
- Auto-apply — When user says "just do it / skip confirmation", show refined then execute immediately
- Optimize-only — When user only asks to refine without executing, return refined result only
When NOT to Use
- - User input is already well-structured with clear goals, constraints, and acceptance criteria
- Single-step operations (delete a line, rename a variable, change a single string)
- Simple factual questions or explanations
- User explicitly says "don't optimize" or "just do it"
Workflow
- 1. Extract original prompt and current session context (goals, constraints, tech stack, errors, expected output).
- Generate refined prompt, ensuring:
- Core intent unchanged
- Goals and boundaries explicit
- Output format verifiable
- Language concise, no fluff
- 3. Produce result based on Continue Mode.
- After user makes a choice, generate a learning signal for
session-learner — capture preference pattern, never record full prompt text.
Refined Prompt Structure
Include the following blocks as needed (trim, don't mechanically stack):
- - Goal
- Context
- Constraints / Non-goals
- Execution Requirements
- Output Format
- Acceptance Criteria
For detailed patterns and examples, see references/prompt-patterns.md.
Output Templates
A) Popup-confirm (default)
First, judge whether refinement adds real value. If the refined prompt only tweaks wording without adding explicit goals/constraints/output format/acceptance criteria, and doesn't significantly reduce ambiguity, it has no substantial optimization value.
- - No substantial value: Don't popup, don't interrupt. Execute with the original prompt directly.
- Has substantial value: Execute the two steps below. Do not skip or merge them.
Step 1 (required): Output the refined prompt as plain text in the chat area first.
Optimized Prompt
Step 2 (required, after step 1): Call AskUserQuestion popup for user to choose.
Options:
- - A: Use refined prompt to continue (recommended)
- B: Use original prompt to continue
Forbidden:
- - Do not popup without showing the refined prompt content first
- Do not put the refined prompt inside AskUserQuestion description as a substitute for step 1
- Steps 1 and 2 must be in the same response
Execute after user chooses.
B) Auto-apply
Optimized Prompt
Then execute immediately.
C) Optimize-only
Optimized Prompt
Do not execute the task.
Heuristics
- - Rewrite vague phrases ("optimize it / make it better / fix it up") into actionable steps with clear criteria.
- Fill in missing inputs, boundary conditions, and completion definitions.
- For code tasks: specify scope, verification method, expected deliverables.
- For content tasks: specify audience, tone, length, structure constraints.
- If critical context is missing, ask the minimum necessary clarification; otherwise proceed.
Integration with session-learner
- - When user chooses refined or rejects it, this is a preference signal for
session-learner. - INLINECODE4 should only summarize rules (e.g., "user prefers seeing refined version before confirming"), never record full prompt text.
- Over time,
session-learner builds a preference profile that makes prompt-refiner increasingly aligned with user habits.
Priority Rules
- - When user explicitly specifies a flow, follow user instructions.
- When no explicit instruction, use Popup-confirm.
prompt-refiner
提示词优化不仅仅是措辞润色——它涉及任务澄清、边界设定和验证塑造。
将模糊的用户提示词优化为清晰、可执行、可验证的版本。先展示优化结果,让用户确认后再执行。与session-learner形成闭环,后者会随时间记录用户的选择偏好。
快速参考
直接执行,不弹窗 |
| 实质性改进 | 展示优化版 + 弹窗选择 |
| 无实质性改进 | 跳过弹窗,执行原版 |
| 用户说直接执行 | 自动应用 |
| 用户说仅优化 | 返回优化版,不执行 |
继续模式
- 1. 弹窗确认(默认) — 展示优化后的提示词,弹窗让用户选择优化版或原版,选择后执行
- 自动应用 — 当用户说直接执行/跳过确认时,展示优化版后立即执行
- 仅优化 — 当用户只要求优化而不执行时,仅返回优化结果
何时不使用
- - 用户输入已结构良好,包含明确目标、约束和验收标准
- 单步操作(删除一行、重命名变量、修改单个字符串)
- 简单的事实性问题或解释
- 用户明确说不要优化或直接执行
工作流程
- 1. 提取原始提示词和当前会话上下文(目标、约束、技术栈、错误、预期输出)。
- 生成优化后的提示词,确保:
- 核心意图不变
- 目标和边界明确
- 输出格式可验证
- 语言简洁,无冗余
- 3. 根据继续模式生成结果。
- 用户做出选择后,为session-learner生成学习信号——记录偏好模式,绝不记录完整提示词文本。
优化提示词结构
根据需要包含以下模块(精简处理,不要机械堆砌):
- - 目标
- 上下文
- 约束/非目标
- 执行要求
- 输出格式
- 验收标准
详细模式和示例请参见references/prompt-patterns.md。
输出模板
A) 弹窗确认(默认)
首先,判断优化是否带来实际价值。 如果优化后的提示词仅调整措辞,未增加明确的目标/约束/输出格式/验收标准,且未显著减少歧义,则无实质性优化价值。
- - 无实质性价值:不弹窗,不中断。直接使用原始提示词执行。
- 有实质性价值:执行以下两个步骤。不可跳过或合并。
步骤1(必需):先在聊天区域以纯文本形式输出优化后的提示词。
优化提示词
<完整优化提示词内容>
步骤2(必需,在步骤1之后):调用AskUserQuestion弹窗供用户选择。
选项:
- - A:使用优化提示词继续(推荐)
- B:使用原始提示词继续
禁止:
- - 未先展示优化提示词内容时不得弹窗
- 不得将优化提示词放在AskUserQuestion描述中作为步骤1的替代
- 步骤1和步骤2必须在同一响应中
用户选择后执行。
B) 自动应用
优化提示词
<优化提示词>
然后立即执行。
C) 仅优化
优化提示词
<优化提示词>
不执行任务。
启发式规则
- - 将模糊表述(优化它/让它更好/修复一下)改写为具有明确标准的可执行步骤。
- 补充缺失的输入、边界条件和完成定义。
- 对于代码任务:明确范围、验证方法、预期交付物。
- 对于内容任务:明确受众、语气、长度、结构约束。
- 如果缺少关键上下文,询问最少必要的澄清信息;否则继续执行。
与session-learner的集成
- - 当用户选择优化版或拒绝时,这将成为session-learner的偏好信号。
- session-learner应仅总结规则(例如用户偏好先查看优化版再确认),绝不记录完整提示词文本。
- 随着时间的推移,session-learner会构建偏好画像,使prompt-refiner越来越符合用户习惯。
优先级规则
- - 当用户明确指定流程时,遵循用户指示。
- 当无明确指示时,使用弹窗确认模式。