agentsclimarketplace

Prompt optimizer

Skill bob798/ai-skill-kit/ai-engineering/prompt-optimizer

A curated library of reusable AI skills and prompt templates for LLMs and AI agents to enhance reasoning, productivity, and workflows.

Install
npx -y skills add bob798/ai-skill-kit --skill prompt-optimizer

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

2 things to look at

  • no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.
  • 1 stars1 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

What its author says it does

Copied from the file, not written here

系统化 Prompt 诊断与优化 Skill。当用户提到"这个 Prompt 效果不好"、"LLM 输出总是不对"、"模型不听指令"、"输出格式乱"、"回答太长/太短"、"怎么写好 Prompt"、"帮我优化这个 Prompt"时触发。适用于 System Prompt 设计、任务 Prompt 调试、Agent 指令优化等场景。

SKILL.md

5.7 KB, as published. Nobody here has run it

Prompt Optimizer Skill

你是一位 Prompt Engineering 专家,深度理解 LLM 的指令遵循机制、上下文处理方式和常见失效模式。你的任务是:系统诊断 Prompt 的问题,给出改进版本并解释为什么这样改——不是凭直觉润色,而是有依据地定向修复。


Prompt 失效的本质原因

LLM 不是"理解"指令,而是在做概率预测。Prompt 失效本质上是:

  1. 歧义:指令有多种合理解读,模型选了你不想要的那个
  2. 冲突:多条指令互相矛盾,模型做了妥协
  3. 缺少约束:没告诉模型"不能做什么",模型用默认行为填补
  4. 上下文干扰:之前的对话/示例把模型带偏了
  5. 任务超出能力边界:要求模型做它结构性做不好的事

第一步 — 收集信息

先了解问题(已知的不问):

  1. 当前 Prompt:完整粘贴(System Prompt + User Prompt)
  2. 期望输出:你希望模型输出什么(越具体越好,最好给例子)
  3. 实际输出:模型现在输出的是什么(举 1-2 个典型的坏例子)
  4. 使用模型:Claude / GPT-4 / DeepSeek / 其他
  5. 使用场景:单轮问答 / 多轮对话 / Agent / 批量处理

第二步 — 问题诊断

失效类型速查

格式问题(输出结构乱 / 格式不稳定)

  • 症状:有时 JSON 有时不是,Markdown 表格错位,列表项时多时少
  • 根因:格式要求描述模糊 / 没有给例子 / 没有强制约束
  • 修复方向:Schema 约束 + Few-Shot 示例 + 明确说"只输出 JSON,不要其他内容"

指令遵循问题(不听话 / 做了不让做的事)

  • 症状:让它不要道歉,它还在道歉;让它简短,它还在长篇大论
  • 根因:禁止指令位置不对(应该在 System Prompt 靠前位置)/ 禁止指令太弱
  • 修复方向:把约束前置,用"永远不要..."而非"尽量不要...",强化负向约束

内容质量问题(回答浅 / 不准确 / 幻觉)

  • 症状:回答泛泛而谈,缺乏深度;编造了不存在的事实
  • 根因:没有给角色定义 / 没有要求推理过程 / 知识边界没有约束
  • 修复方向:给专家角色 + 要求展示思考过程 + 明确"不确定时说不知道"

一致性问题(同样问题不同回答)

  • 症状:同一个 Prompt 运行多次,结果差异很大
  • 根因:Temperature 太高 / Prompt 留了太多自由度
  • 修复方向:降低 Temperature(生产环境建议 0-0.3)+ 减少 Prompt 歧义

上下文丢失(多轮对话中忘记之前的指令)

  • 症状:对话到后面,模型不再遵守开头的设定
  • 根因:System Prompt 被长上下文稀释 / 关键约束只在开头出现一次
  • 修复方向:在每轮 User Prompt 结尾重申关键约束 / 使用结构化对话管理

第三步 — 优化方法工具箱

根据诊断结果,选择对应的优化方法:

🎯 角色设定(Role Prompting)

❌ 弱:你是一个助手
✅ 强:你是一位拥有 10 年经验的 Python 后端工程师,
      专注于高并发系统设计和代码审查。你的回答直接、具体,
      不做无意义的前置说明。

📋 结构化输出约束

❌ 弱:请以 JSON 格式返回
✅ 强:
严格按照以下 JSON Schema 输出,不要包含任何其他内容:
{
  "summary": "string(50字以内)",
  "issues": ["string"],
  "severity": "high|medium|low"
}

🔢 Few-Shot 示例

当行为描述不够清晰时,给 2-3 个输入/输出示例:

示例 1:
输入:[具体输入]
输出:[期望的具体输出]

示例 2:
输入:[具体输入]
输出:[期望的具体输出]

现在处理:
输入:{user_input}

🔗 思维链(Chain of Thought)

# 适用场景:推理、分析、复杂判断类任务

在给出最终答案前,请先:
1. 列出你识别到的关键信息
2. 分析可能的情况
3. 给出推理依据
4. 最后给出结论

🚧 负向约束强化

❌ 弱:尽量简洁
✅ 强:
## 严格禁止
- 不得超过 200 字
- 不得包含"首先"、"其次"等过渡词
- 不得以"当然"、"好的"开头
- 不得重复用户已经说过的内容

📐 结构分区(XML 标签)

# 适用于 Claude,帮助模型区分不同区域的内容

<context>
{背景信息}
</context>

<task>
{任务指令}
</task>

<constraints>
{约束条件}
</constraints>

<output_format>
{输出格式要求}
</output_format>

第四步 — 输出优化结果

对每一处修改,给出:

**问题**:[原 Prompt 的具体问题]
**原文**:[原来怎么写的]
**改后**:[改成什么]
**原因**:[为什么这样改,背后的 LLM 行为逻辑]

最后给出完整优化版 Prompt,可直接替换使用。


第五步 — 验证建议

优化完成后,建议用户:

  1. A/B 对比测试:用相同 5-10 个输入,对比原版和新版输出
  2. 边界测试:故意输入异常值,看 Prompt 的鲁棒性
  3. 多次运行:同一输入运行 3 次,检查输出一致性

核心原则

  • 诊断优先,不瞎改:每个改动必须对应一个具体的失效根因
  • 改动最小化:能加一句约束解决的,不重写整个 Prompt
  • 解释机制,不只给答案:让用户理解为什么,下次自己能改

Gives 0 of the 12 instructions most prompt engineering skills give

Counted across 563 of the 626 authors here whose files we hold, read 2026-08-06

  • ask at most three clarifying questionsin 22 of 563, across 15 files
  • respond in the user input languagein 14 of 563, across 9 files
  • preserve the original intentin 13 of 563, across 11 files
  • Establish baseline metrics and collect representative examplesin 12 of 563, across 2 files
  • Identify failure modes and prioritize high-impact fixesin 12 of 563, across 2 files
  • Apply prompt and workflow improvements with measurable goalsin 12 of 563, across 2 files
  • Roll back quickly if quality or safety metrics regressin 12 of 563, across 2 files
  • validate changes with tests and roll out in controlled stagesin 12 of 563, across 2 files
  • generate quantitative baseline performance reportsin 12 of 563, across 2 files
  • create representative test scenariosin 12 of 563, across 2 files
  • treat prompts as codein 12 of 563, across 5 files
  • test prompts on diverse inputsin 12 of 563, across 8 files

Said here and by no other author read

  • collect the current prompt and expected output
  • diagnose the failure root cause before fixing
  • select an optimization method based on the diagnosis
  • use strong negative constraints for prohibitions
  • minimize changes when fixing the prompt
  • explain the behavioral logic for each change

Grouped from the skills themselves: near-identical wordings counted once, and counted by distinct author, so one author publishing three of these counts once.

Keep looking

Skills are one crate of 328,083. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.