技能 prompt-engineering-patterns
📝

prompt-engineering-patterns

安全

应用提示工程模式

也可从以下获取: wshobson

使用经过验证的提示工程技巧改进LLM输出。本技能提供思维链推理、少样本学习和模板系统等模式,使AI交互更加可靠和可控。

支持: Claude Codex Code(CC)
📊 86 充足
1

下载技能 ZIP

2

在 Claude 中上传

前往 设置 → 功能 → 技能 → 上传技能

3

开启并开始使用

测试它

正在使用“prompt-engineering-patterns”。 Design a prompt that helps users write professional emails

预期结果:

一个结构化的邮件撰写模板,包含角色定义、语气指南和格式部分,可生成一致、专业的邮件输出。

正在使用“prompt-engineering-patterns”。 How can I improve code review quality with AI?

预期结果:

一个少样本提示,提供代码审查示例,包含常见bug模式、安全考虑和最佳实践,引导AI提供全面、建设性的反馈。

安全审计

安全
v1 • 2/24/2026

All 216 static findings are false positives. The flagged files are markdown documentation (.md) and example JSON files containing educational content about prompt engineering techniques. The scanner incorrectly interprets backticks in markdown code blocks as shell commands, text references to cryptographic terms as weak crypto implementations, and tutorial references to system commands as reconnaissance. This is a documentation skill with no executable security issues.

9
已扫描文件
2,696
分析行数
4
发现项
1
审计总数
低风险问题 (4)
False Positive: Ruby/Shell Backtick Detection in Documentation
Static scanner flagged 170 instances of 'Ruby/shell backtick execution' in markdown files. These are false positives - the backticks are markdown code block delimiters showing Python/code examples in documentation, not actual shell commands. Files affected: SKILL.md, references/*.md, assets/*.md
False Positive: Weak Cryptographic Algorithm References
Static scanner flagged 39 instances of 'Weak cryptographic algorithm' in documentation files. These are false positives - the files contain educational content explaining prompt engineering patterns, with text examples mentioning cryptographic concepts in context of AI safety, not actual crypto implementations.
False Positive: System/Network Reconnaissance in Tutorials
Static scanner flagged 'System reconnaissance' and 'Network reconnaissance' patterns in markdown documentation. These are false positives - the files contain educational tutorials that reference system commands and networking concepts as part of prompt engineering examples, not actual reconnaissance tools.
False Positive: Filesystem Path Traversal in Documentation
Static scanner flagged 'Path traversal sequence' in references/prompt-optimization.md and scripts/optimize-prompt.py. The markdown file contains text explaining path handling concepts in prompts. The Python script is a utility for prompt optimization with legitimate file operations.
审计者: claude

质量评分

82
架构
100
可维护性
87
内容
50
社区
97
安全
100
规范符合性

你能构建什么

构建可靠的AI产品

为AI驱动的应用程序设计生产就绪的提示系统,具有一致的输出格式和错误处理模式。

改进代码生成

应用结构化提示技术从Claude或Codex获取更好的代码补全和生成结果。

创建AI培训材料

开发全面的提示库和模板,用于团队范围内的AI采用和最佳实践。

试试这些提示

思维链推理
Solve this problem step by step:

Problem: {problem}

Think through each step carefully:
1. [First step]
2. [Second step]
3. [Third step]

Final answer:
少样本分类
Classify the following input into one of these categories: {categories}

Examples:
{examples}

Now classify this:
Input: {input}

Category:
系统提示模板
You are {role}. Your task is {task}.

Guidelines:
- {guideline1}
- {guideline2}
- {guideline3}

Output format:
{output_format}
迭代优化
Initial request: {request}

Current draft: {draft}

Feedback to address:
{feedback}

Please revise the draft based on this feedback:

最佳实践

  • 在系统提示中从清晰的角色定义开始,以建立AI行为边界
  • 在少样本提示中使用覆盖边缘情况的具体、多样化示例
  • 在多种查询变体上测试提示以确保输出的一致性

避免

  • 使用模糊指令如"要helpful"而没有具体的行为指南
  • 用太多示例使提示过载,超出上下文窗口限制
  • 假设提示在不同LLM模型上工作方式相同,未经测试

常见问题

什么是思维链提示?
思维链提示鼓励LLM逐步展示其推理过程,提高复杂数学、逻辑和推理任务的准确性。
少样本学习应该包含多少个示例?
大多数任务使用2-5个示例效果很好。在示例多样性与上下文窗口限制之间取得平衡。太多示例会降低响应质量。
我可以在Claude Code中使用这些模式吗?
是的,这些模式适用于Claude、Claude Code、Codex和大多数现代LLM。Claude Code可以直接执行提示模板。
如何调试产生不一致输出的提示?
添加明确的输出格式约束,包含更多多样化示例,并使用逐步推理使AI处理过程更加透明。
系统提示和用户提示有什么区别?
系统提示在对话开始时定义AI助手的角色和行为。用户提示包含每次交互的具体任务或问题。
如何处理提示注入风险?
使用清晰的指令边界,验证用户输入,避免将不受信任的内容直接拼接到提示中。使用不同部分构建提示,分别用于指令和用户数据。