prompt-engineering-patterns
掌握高级提示工程技术,以最大化生产环境中LLM的性能、可靠性和可控性。在优化提示、改进LLM输出或设计生产提示模板时使用。
npx skills add majiayu000/claude-skill-registry --skill prompt-engineering-patterns-evanfang0054-cc-system-creator-sc --agent claude-code
Same command for any agent — swap --agent for codex, cursor, copilot.
Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.
# 提示工程模式 掌握高级提示工程技术,以最大化LLM的性能、可靠性和可控性。 ## 何时使用此技能 - 为生产级LLM应用程序设计复杂提示 - 优化提示性能和一致性 - 实现结构化推理模式(思维链、思维树) - 构建具有动态示例选择的小样本学习系统 - 创建具有变量插值功能可重用的提示模板 - 调试和优化产生不一致输出的提示 - 为专用AI助手实现系统提示 ## 核心能力 ### 1. 小样本学习 - 示例选择策略(语义相似性、多样性采样) - 在上下文窗口约束下平衡示例数量 - 构建有效的输入输出对示范 - 从知识库动态检索示例 - 通过策略性示例选择处理边界情况 ### 2. 思维链提示 - 逐步推理引导 - 零样本CoT:"让我们一步步思考" - 少样本CoT与推理轨迹 - 自一致性技术(采样多个推理路径) - 验证和确认步骤 ### 3. 提示优化 - 迭代优化工作流 - 提示变体的A/B测试 - 测量提示性能指标(准确性、一致性、延迟) - 在保持质量的同时减少token使用 - 处理边界情况和失败模式 ### 4. 模板系统 - 变量插值和格式化 - 条件提示部分 - 多轮对话模板 - 基于角色的提示组合 - 模块化提示组件 ### 5. 系统提示设计 - 设置模型行为和约束 - 定义输出格式和结构 - 建立角色和专业能力 - 安全准则和内容策略 - 上下文设置和背景信息 ## 快速开始 ```python from prompt_optimizer import PromptTemplate, FewShotSelector # 定义结构化提示模板 template = PromptTemplate( system="你是一位专家级SQL开发者。生成高效、安全的SQL查询。", instruction="将以下自然语言查询转换为SQL:\n{query}", few_shot_examples=True, output_format="带有解释性注释的SQL代码块" ) # 配置小样本学习 selector = FewShotSelector( examples_db="sql_examples.jsonl", selection_strategy="semantic_similarity", max_examples=3 ) # 生成优化提示 prompt = template.render( query="查找过去30天内注册的所有用户", examples=selector.select(query="用户注册日期筛选") ) ``` ## 关键模式 ### 渐进式披露 从简单提示开始,仅在需要时增加复杂性: 1. **级别1**:直接指令 - "总结这篇文章" 2. **级别2**:添加约束 - "用3个要点总结这篇文章,重点关注关键
- 何时使用此技能
- 核心能力
- 1. 小样本学习
- 2. 思维链提示
- 3. 提示优化
- 4. 模板系统
- 5. 系统提示设计
- 快速开始
- 关键模式
- 渐进式披露
- 指令层次结构
- 错误恢复
- 最佳实践
- 常见陷阱
What does the prompt-engineering-patterns skill do?
掌握高级提示工程技术,以最大化生产环境中LLM的性能、可靠性和可控性。在优化提示、改进LLM输出或设计生产提示模板时使用。
How do I install it?
Run `npx skills add majiayu000/claude-skill-registry --skill prompt-engineering-patterns-evanfang0054-cc-system-creator-sc --agent claude-code` — it drops the skill into your project so the agent can pick it up. Swap the --agent value for codex, cursor or copilot if you use one of those.
Where does this skill come from?
From majiayu000/claude-skill-registry, a repository with 534 stars. We read it straight from the repository tree rather than a submitted listing, so what you see here is what is actually published.
Is a popular skill a good skill?
Not necessarily. Stars measure attention, not adoption — a repository can trend for a week and be abandoned. That is why we show the weekly change from our own snapshots next to the total, instead of a single flattering number.
