anthropic-prompt-engineer

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Anthropic Prompt Engineer

Anthropic提示词工程师

Master the art and science of prompt engineering with Anthropic's proven techniques. Generate new prompts from scratch or improve existing ones using best practices for Claude AI models (Claude 4.x, Sonnet, Opus, Haiku).
掌握Anthropic经过验证的提示词工程技术与方法。运用Claude AI模型(Claude 4.x、Sonnet、Opus、Haiku)的最佳实践,从零开始生成新提示词或优化现有提示词。

What This Skill Does

该技能的作用

Helps you create and optimize prompts for Claude AI using Anthropic's official techniques:
  • Generate new prompts - Build effective prompts from requirements
  • Improve existing prompts - Optimize prompts for better results
  • Apply best practices - Use proven techniques from Anthropic
  • Avoid common mistakes - Prevent hallucinations and unclear outputs
  • Optimize for Claude 4.x - Leverage latest model capabilities
  • Structure complex prompts - Build multi-step, production-ready prompts
帮助你运用Anthropic的官方技术为Claude AI创建和优化提示词:
  • 生成新提示词 - 根据需求构建有效的提示词
  • 优化现有提示词 - 优化提示词以获得更好的结果
  • 应用最佳实践 - 采用Anthropic经过验证的技术
  • 避免常见错误 - 防止幻觉输出和模糊结果
  • 针对Claude 4.x优化 - 利用最新模型的能力
  • 构建复杂提示词结构 - 打造多步骤、可用于生产环境的提示词

Why Prompt Engineering Matters

提示词工程的重要性

Without proper prompting:
  • Inconsistent or incorrect outputs
  • Hallucinations and made-up information
  • Unclear or verbose responses
  • Wasted tokens and API calls
  • Poor performance on complex tasks
  • Difficulty reproducing results
With engineered prompts:
  • Precise, reliable outputs
  • Factual, grounded responses
  • Clear, formatted results
  • Efficient token usage
  • Excellent complex task performance
  • Reproducible, production-ready results
缺乏恰当提示时:
  • 输出不一致或不准确
  • 出现幻觉和虚构信息
  • 回复模糊或冗长
  • 浪费令牌和API调用
  • 复杂任务表现不佳
  • 难以复现结果
使用经过工程化的提示词时:
  • 输出精准、可靠
  • 回复真实、有依据
  • 结果清晰、格式规范
  • 令牌使用高效
  • 复杂任务表现出色
  • 结果可复现、适用于生产环境

Quick Start

快速开始

Generate a New Prompt

生成新提示词

Using the anthropic-prompt-engineer skill, create a prompt that:
- Extracts structured data from customer emails
- Returns JSON format
- Handles missing information gracefully
- Includes 2 examples
Using the anthropic-prompt-engineer skill, create a prompt that:
- Extracts structured data from customer emails
- Returns JSON format
- Handles missing information gracefully
- Includes 2 examples

Improve an Existing Prompt

优化现有提示词

Using the anthropic-prompt-engineer skill, improve this prompt:

"Analyze this code and tell me if there are bugs"

Make it more effective using Anthropic's best practices.
Using the anthropic-prompt-engineer skill, improve this prompt:

"Analyze this code and tell me if there are bugs"

Make it more effective using Anthropic's best practices.

Core Techniques Summary

核心技术总结

1. Be Clear and Direct

1. 清晰直接

Provide explicit, unambiguous instructions. Claude 4.x excels with precise direction.
提供明确、无歧义的指令。Claude 4.x在精准指令下表现出色。

2. Use XML Tags for Structure

2. 使用XML标签构建结构

Organize prompts with semantic tags like
<instructions>
,
<example>
,
<context>
.
使用
<instructions>
<example>
<context>
等语义标签组织提示词。

3. Chain of Thought (CoT)

3. 思维链(CoT)

Ask Claude to think step-by-step for complex reasoning.
要求Claude逐步思考以完成复杂推理任务。

4. Prefilling

4. 预填充

Start Claude's response to guide format and style.
引导Claude的回复格式和风格。

5. Few-Shot Examples

5. 少样本示例

Provide 2-5 diverse examples showing the pattern you want.
提供2-5个多样化示例,展示你期望的模式。

6. Role Assignment

6. 角色分配

Give Claude a specific role or persona for appropriate context.
为Claude分配特定角色或身份,以适配相应场景。

Reference Materials

参考资料

All techniques, examples, and templates are available in the
references/
directory:
  • core_techniques.md - Essential techniques with examples
  • advanced_techniques.md - Advanced methods and optimization
  • common_mistakes.md - Pitfalls to avoid
  • claude_4_best_practices.md - Claude 4.x specific guidance
  • prompt_templates.md - Ready-to-use templates
所有技术、示例和模板都可在
references/
目录中找到:
  • core_techniques.md - 包含示例的核心技术文档
  • advanced_techniques.md - 高级方法与优化指南
  • common_mistakes.md - 需要避免的常见陷阱
  • claude_4_best_practices.md - 针对Claude 4.x的专属指导
  • prompt_templates.md - 可直接使用的提示词模板

Usage Examples

使用示例

Example 1: Generate a Data Extraction Prompt

示例1:生成数据提取提示词

Create a prompt that extracts names, emails, and phone numbers from business cards.
创建一个能从名片中提取姓名、邮箱和电话号码的提示词。

Example 2: Improve a Vague Prompt

示例2:优化模糊提示词

Transform "Write about machine learning" into a structured, effective prompt.
将“写一篇关于机器学习的文章”转化为结构化、高效的提示词。

Example 3: Debug a Failing Prompt

示例3:修复失效的提示词

Fix inconsistent outputs by adding structure, examples, and format specification.
通过添加结构、示例和格式规范来解决输出不一致的问题。

Best Practices Checklist

最佳实践检查清单

  • Instructions are clear and specific
  • Output format is explicitly defined
  • Examples align with desired behavior
  • XML tags separate different sections
  • Context is minimal but sufficient
  • Edge cases are addressed
  • Tested on diverse inputs
  • Token usage is optimized
  • 指令清晰具体
  • 输出格式明确定义
  • 示例与期望行为一致
  • 使用XML标签分隔不同部分
  • 上下文精简但足够
  • 考虑到边缘情况
  • 已在多样化输入上测试
  • 令牌使用已优化

Key Principles

核心原则

  1. Empirical Approach - Test, measure, iterate
  2. Context as Resource - Every token counts
  3. Clarity Over Cleverness - Explicit instructions work best
  4. Examples Teach Best - Show, don't just tell
  5. Structure Helps - Organization reduces confusion
  6. Iteration Improves - Refine based on results
  1. 实证方法 - 测试、衡量、迭代
  2. 上下文即资源 - 每个令牌都有价值
  3. 清晰优于巧妙 - 明确的指令效果最佳
  4. 示例是最好的教学方式 - 展示而非仅告知
  5. 结构有助提升效果 - 组织有序可减少混淆
  6. 迭代优化 - 根据结果不断改进

Summary

总结

Master prompt engineering to create:
  • Reliable and consistent outputs
  • Production-ready prompts
  • Token-efficient solutions
  • Easy to maintain systems
Apply Anthropic's proven techniques for best results.

Remember: Good prompts are engineered, not guessed.
掌握提示词工程,以创建:
  • 可靠且一致的输出
  • 适用于生产环境的提示词
  • 令牌高效的解决方案
  • 易于维护的系统
运用Anthropic经过验证的技术以获得最佳结果。

记住: 优秀的提示词是设计出来的,不是凭空猜测的。