prompt-engineer

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Prompt Engineering Skill

Prompt Engineering 技能

This skill provides comprehensive guidance for creating effective prompts for language models using proven best practices. Use this skill whenever working on prompt design, optimization, or troubleshooting.
本技能为使用经过验证的最佳实践为大语言模型创建有效的提示词提供全面指导。当你需要进行提示词设计、优化或问题排查时均可使用本技能。

Overview

概述

Apply proven prompt engineering techniques to create high-quality, reliable prompts that produce consistent, accurate outputs while minimizing hallucinations and implementing appropriate security measures.
应用经过验证的Prompt Engineering技术,创建高质量、可靠的提示词,在实现一致、准确输出的同时,最大限度减少幻觉问题,并落实合适的安全措施。

When to Use This Skill

何时使用本技能

Trigger this skill when users request:
  • Help writing a prompt for a specific task
  • Improving an existing prompt that isn't performing well
  • Making outputs more consistent, accurate, or secure
  • Creating system prompts for specialized roles
  • Implementing specific techniques (chain-of-thought, multishot, XML tags)
  • Reducing hallucinations or errors in outputs
  • Debugging prompt performance issues
当用户提出以下需求时触发本技能:
  • 为特定任务编写提示词的相关帮助
  • 优化效果不佳的现有提示词
  • 提升输出的一致性、准确性或安全性
  • 为特殊角色创建系统提示词
  • 落地特定技术(chain-of-thought、multishot、XML tags)

Workflow

工作流程

Step 1: Understand Requirements

步骤1:理解需求

Ask clarifying questions to understand:
  • Task goal: What should the prompt accomplish?
  • Use case: One-time use, API integration, or production system?
  • Constraints: Output format, length, style, tone requirements
  • Quality needs: Consistency, accuracy, security priorities
  • Complexity: Simple task or multi-step workflow?
通过询问澄清类问题了解以下信息:
  • 任务目标:该提示词需要实现什么效果?
  • 使用场景:一次性使用、API集成还是生产系统使用?
  • 约束条件:输出格式、长度、风格、语气要求
  • 质量需求:一致性、准确性、安全优先级
  • 复杂度:简单任务还是多步骤工作流?

Step 2: Identify Applicable Techniques

步骤2:确定适用的技术

Based on requirements, determine which techniques to apply:
Core techniques (for all prompts):
  • Be clear and direct
  • Use XML tags for structure
Specialized techniques:
  • Role-specific expertise → System prompts
  • Complex reasoning → Chain of thought
  • Format consistency → Multishot prompting
  • Multi-step tasks → Prompt chaining
  • Long documents → Long context tips
  • Deep analysis → Extended thinking
  • Factual accuracy → Hallucination reduction
  • Output consistency → Consistency techniques
  • Security concerns → Jailbreak mitigation
基于需求,确定要应用的技术:
核心技术(适用于所有提示词):
  • 清晰直接
  • 使用XML标签做结构划分
专项技术:
  • 特定角色专业能力 → 系统提示词
  • 复杂推理 → Chain of thought
  • 格式一致性 → Multishot prompting
  • 多步骤任务 → Prompt chaining
  • 长文档 → 长上下文处理技巧
  • 深度分析 → 扩展思考
  • 事实准确性 → 幻觉减少
  • 输出一致性 → 一致性技术
  • 安全顾虑 → 越狱缓解

Step 3: Load Relevant References

步骤3:加载相关参考资料

Read the appropriate reference file(s) based on techniques needed:
For basic prompt improvement:
Read references/core_prompting.md
Covers: clarity, system prompts, XML tags
For complex tasks:
Read references/advanced_patterns.md
Covers: chain of thought, multishot, chaining, long context, extended thinking
For specific quality issues:
Read references/quality_improvement.md
Covers: hallucinations, consistency, security
根据所需技术阅读对应的参考文件:
基础提示词优化:
Read references/core_prompting.md
涵盖内容:清晰度、系统提示词、XML标签
复杂任务:
Read references/advanced_patterns.md
涵盖内容:chain of thought、multishot、chaining、长上下文、扩展思考
特定质量问题:
Read references/quality_improvement.md
涵盖内容:幻觉、一致性、安全

Step 4: Design the Prompt

步骤4:设计提示词

Apply techniques from references to create the prompt structure:
Basic Template:
[System prompt - optional, for role assignment]

<context>
Relevant background information
</context>

<instructions>
Clear, specific task instructions
Use numbered steps for multi-step tasks
</instructions>

<examples>
  <example>
    <input>Sample input</input>
    <output>Expected output</output>
  </example>
  [2-4 more examples if using multishot]
</examples>

<output_format>
Specify exact format (JSON, XML, markdown, etc.)
</output_format>

[Actual task/question]
Key Design Principles:
  1. Clarity: Be explicit and specific
  2. Structure: Use XML tags to organize
  3. Examples: Provide 3-5 concrete examples for complex formats
  4. Context: Give relevant background
  5. Constraints: Specify output requirements clearly
应用参考资料中的技术创建提示词结构:
基础模板:
[系统提示词 - 可选,用于角色分配]

<context>
相关背景信息
</context>

<instructions>
清晰、具体的任务指令
多步骤任务使用编号步骤说明
</instructions>

<examples>
  <example>
    <input>示例输入</input>
    <output>预期输出</output>
  </example>
  [如果使用multishot可再补充2-4个示例]
</examples>

<output_format>
指定确切的输出格式(JSON、XML、markdown等)
</output_format>

[实际任务/问题]
核心设计原则:
  1. 清晰度:表述明确具体
  2. 结构性:使用XML标签组织内容
  3. 示例:复杂格式提供3-5个具体示例
  4. 上下文:提供相关背景信息
  5. 约束:明确说明输出要求

Step 5: Add Quality Controls

步骤5:添加质量控制机制

Based on quality needs, add appropriate safeguards:
For factual accuracy:
  • Grant permission to say "I don't know"
  • Request quote extraction before analysis
  • Require citations for claims
  • Limit to provided information sources
For consistency:
  • Provide explicit format specifications
  • Use response prefilling
  • Include diverse examples
  • Consider prompt chaining
For security:
  • Add harmlessness screening
  • Establish clear ethical boundaries
  • Implement input validation
  • Use layered protection
根据质量需求,添加合适的保障措施:
事实准确性保障:
  • 允许模型回复“我不知道”
  • 要求分析前先提取引用内容
  • 要求声明附带引用来源
  • 限定仅使用提供的信息源
一致性保障:
  • 提供明确的格式规范
  • 使用响应预填充
  • 包含多样化示例
  • 考虑使用prompt chaining
安全性保障:
  • 添加无害性筛查
  • 设立明确的伦理边界
  • 实现输入校验
  • 使用分层防护

Step 6: Optimize and Test

步骤6:优化与测试

Optimization checklist:
  • Could someone with minimal context follow the instructions?
  • Are all terms and requirements clearly defined?
  • Is the desired output format explicitly specified?
  • Are examples diverse and relevant?
  • Are XML tags used consistently?
  • Is the prompt as concise as possible while remaining clear?
Testing approach:
  • Run prompt multiple times with varied inputs
  • Check consistency across runs
  • Verify outputs match expected format
  • Test edge cases
  • Validate quality controls work
优化检查清单:
  • 仅具备最少上下文的人员能否理解指令?
  • 所有术语和要求是否都有明确定义?
  • 是否明确指定了预期的输出格式?
  • 示例是否多样且相关?
  • XML标签使用是否一致?
  • 提示词是否在保持清晰的前提下尽可能简洁?
测试方法:
  • 使用不同输入多次运行提示词
  • 检查多次运行的输出一致性
  • 验证输出是否符合预期格式
  • 测试边界案例
  • 确认质量控制机制生效

Step 7: Iterate Based on Results

步骤7:根据结果迭代

Debugging process:
  1. Identify failure points
  2. Review relevant reference material
  3. Apply appropriate techniques
  4. Test and measure improvement
  5. Repeat until satisfactory
Common Issues and Solutions:
IssueSolutionReference
Inconsistent formatAdd examples, use prefillingquality_improvement.md
HallucinationsAdd uncertainty permission, quote groundingquality_improvement.md
Missing stepsBreak into subtasks, use chainingadvanced_patterns.md
Wrong toneAdd role to system promptcore_prompting.md
Misunderstands taskAdd clarity, provide contextcore_prompting.md
Complex reasoning failsAdd chain of thoughtadvanced_patterns.md
调试流程:
  1. 定位失败点
  2. 查阅相关参考资料
  3. 应用合适的技术
  4. 测试并评估改进效果
  5. 重复直到效果满意
常见问题与解决方案:
问题解决方案参考文件
格式不一致添加示例,使用预填充quality_improvement.md
幻觉问题允许回复不确定内容,基于引用输出quality_improvement.md
步骤缺失拆分为子任务,使用chainingadvanced_patterns.md
语气错误在系统提示词中添加角色说明core_prompting.md
任务理解错误提升清晰度,提供上下文core_prompting.md
复杂推理失败添加chain of thoughtadvanced_patterns.md

Important Principles

重要原则

Progressive Disclosure Start with core techniques and add advanced patterns only when needed. Don't over-engineer simple prompts.
Documentation When delivering prompts, explain which techniques were used and why. This helps users understand and maintain them.
Validation Always validate critical outputs, especially for high-stakes applications. No prompting technique eliminates all errors.
Experimentation Prompt engineering is iterative. Small changes can have significant impacts. Test variations and measure results.
渐进式披露 从核心技术开始,仅在必要时添加高级模式。不要过度设计简单提示词。
文档说明 交付提示词时,说明使用了哪些技术以及原因,帮助用户理解和维护。
校验机制 始终校验关键输出,尤其是高风险应用场景。没有任何提示词技术可以完全消除错误。
实验思维 Prompt Engineering是迭代过程,微小的改动可能产生显著影响。测试不同变体并衡量结果。

Quick Reference Guide

快速参考指南

Technique Selection Matrix

技术选择矩阵

User NeedPrimary TechniqueReference File
Better clarityBe clear and directcore_prompting.md
Domain expertiseSystem promptscore_prompting.md
Organized structureXML tagscore_prompting.md
Complex reasoningChain of thoughtadvanced_patterns.md
Format consistencyMultishot promptingadvanced_patterns.md
Multi-step processPrompt chainingadvanced_patterns.md
Long documents (100K+ tokens)Long context tipsadvanced_patterns.md
Deep analysisExtended thinkingadvanced_patterns.md
Reduce false informationHallucination reductionquality_improvement.md
Consistent outputsConsistency techniquesquality_improvement.md
Security/safetyJailbreak mitigationquality_improvement.md
用户需求核心技术参考文件
提升清晰度表述清晰直接core_prompting.md
领域专业能力系统提示词core_prompting.md
结构化内容XML tagscore_prompting.md
复杂推理Chain of thoughtadvanced_patterns.md
格式一致性Multishot promptingadvanced_patterns.md
多步骤流程Prompt chainingadvanced_patterns.md
长文档(100K+ tokens)长上下文处理技巧advanced_patterns.md
深度分析扩展思考advanced_patterns.md
减少错误信息幻觉减少quality_improvement.md
输出一致性一致性技术quality_improvement.md
安全/防护越狱缓解quality_improvement.md

When to Combine Techniques

何时组合使用技术

  • Structured analysis: XML tags + Chain of thought
  • Consistent formatting: Multishot + Response prefilling
  • Complex workflows: Prompt chaining + XML tags
  • Factual reports: Quote grounding + Citation verification
  • Production systems: System prompts + Input validation + Consistency techniques
  • 结构化分析:XML tags + Chain of thought
  • 一致格式输出:Multishot + 响应预填充
  • 复杂工作流:Prompt chaining + XML tags
  • 事实报告:引用锚定 + 引用验证
  • 生产系统:系统提示词 + 输入校验 + 一致性技术

Resources

资源

This skill includes three comprehensive reference files:
本技能包含三份全面的参考文件:

references/core_prompting.md

references/core_prompting.md

Essential techniques for all prompts:
  • Being clear and direct
  • System prompts and role assignment
  • Using XML tags effectively
适用于所有提示词的基础技术:
  • 表述清晰直接
  • 系统提示词与角色分配
  • 高效使用XML标签

references/advanced_patterns.md

references/advanced_patterns.md

Sophisticated techniques for complex tasks:
  • Chain of thought prompting
  • Multishot prompting
  • Prompt chaining
  • Long context handling
  • Extended thinking
适用于复杂任务的高级技术:
  • Chain of thought prompting
  • Multishot prompting
  • Prompt chaining
  • 长上下文处理
  • 扩展思考

references/quality_improvement.md

references/quality_improvement.md

Techniques for specific quality issues:
  • Reducing hallucinations
  • Increasing consistency
  • Mitigating jailbreaks and prompt injections
Load these files as needed based on the workflow steps above.
解决特定质量问题的技术:
  • 减少幻觉
  • 提升一致性
  • 缓解越狱与提示词注入
根据上述工作流步骤按需加载这些文件。