Loading...
    • 开发者指南
    • API 参考
    • MCP
    • 资源
    • 更新日志
    Search...
    ⌘K
    入门
    Claude 简介快速开始
    模型与定价
    模型概览选择模型Claude 4.6 新特性迁移指南模型弃用定价
    使用 Claude 构建
    功能概览使用 Messages API处理停止原因提示词最佳实践
    上下文管理
    上下文窗口压缩上下文编辑
    能力
    提示缓存扩展思考自适应思考推理力度流式消息批量处理引用多语言支持Token 计数嵌入视觉PDF 支持Files API搜索结果结构化输出
    工具
    概览如何实现工具使用细粒度工具流式传输Bash 工具代码执行工具程序化工具调用计算机使用工具文本编辑器工具网页抓取工具网页搜索工具记忆工具工具搜索工具
    Agent Skills
    概览快速开始最佳实践企业级 Skills通过 API 使用 Skills
    Agent SDK
    概览快速开始TypeScript SDKTypeScript V2(预览版)Python SDK迁移指南
    API 中的 MCP
    MCP 连接器远程 MCP 服务器
    第三方平台上的 Claude
    Amazon BedrockMicrosoft FoundryVertex AI
    提示工程
    概览提示词生成器使用提示词模板提示词优化器清晰直接使用示例(多样本提示)让 Claude 思考(思维链)使用 XML 标签赋予 Claude 角色(系统提示词)链式复杂提示长上下文技巧扩展思考技巧
    测试与评估
    定义成功标准开发测试用例使用评估工具降低延迟
    加强安全护栏
    减少幻觉提高输出一致性防范越狱攻击流式拒绝减少提示词泄露保持 Claude 角色设定
    管理与监控
    Admin API 概览数据驻留工作空间用量与成本 APIClaude Code Analytics API零数据留存
    Console
    Log in
    Loading...
    Loading...
    Loading...
    Loading...
    Loading...
    Loading...
    Loading...
    Loading...
    Loading...
    Loading...
    Loading...
    Loading...
    Loading...
    Loading...
    Loading...
    Loading...

    Solutions

    • AI agents
    • Code modernization
    • Coding
    • Customer support
    • Education
    • Financial services
    • Government
    • Life sciences

    Partners

    • Amazon Bedrock
    • Google Cloud's Vertex AI

    Learn

    • Blog
    • Catalog
    • Courses
    • Use cases
    • Connectors
    • Customer stories
    • Engineering at Anthropic
    • Events
    • Powered by Claude
    • Service partners
    • Startups program

    Company

    • Anthropic
    • Careers
    • Economic Futures
    • Research
    • News
    • Responsible Scaling Policy
    • Security and compliance
    • Transparency

    Learn

    • Blog
    • Catalog
    • Courses
    • Use cases
    • Connectors
    • Customer stories
    • Engineering at Anthropic
    • Events
    • Powered by Claude
    • Service partners
    • Startups program

    Help and security

    • Availability
    • Status
    • Support
    • Discord

    Terms and policies

    • Privacy policy
    • Responsible disclosure policy
    • Terms of service: Commercial
    • Terms of service: Consumer
    • Usage policy
    提示工程

    使用示例(多轮提示)引导 Claude 的行为

    通过在提示中提供精心设计的示例,可以显著提高 Claude 输出的准确性、一致性和质量。

    While these tips apply broadly to all Claude models, you can find prompting tips specific to extended thinking models here.

    示例是让 Claude 生成您需要的内容的秘密武器。通过在提示中提供几个精心设计的示例,您可以显著提高 Claude 输出的准确性、一致性和质量。 这种技术被称为少样本或多轮提示,对于需要结构化输出或遵守特定格式的任务特别有效。

    增强您的提示:包含 3-5 个多样化、相关的示例,以向 Claude 准确展示您想要的内容。示例越多 = 性能越好,特别是对于复杂任务。

    为什么使用示例?

    • 准确性:示例减少对指令的误解。
    • 一致性:示例强制执行统一的结构和风格。
    • 性能:精心选择的示例提高了 Claude 处理复杂任务的能力。

    制作有效的示例

    为了获得最大效果,请确保您的示例具有以下特点:

    • 相关性:您的示例反映您的实际用例。
    • 多样性:您的示例涵盖边界情况和潜在挑战,并且变化足够大,使 Claude 不会无意中拾取意外的模式。
    • 清晰性:您的示例用 <example> 标签包装(如果有多个,嵌套在 <examples> 标签中)以获得结构。
    要求 Claude 评估您的示例的相关性、多样性或清晰性。或者让 Claude 根据您的初始集合生成更多示例。


    提示库

    获得精选提示的灵感,这些提示适用于各种任务和用例。

    GitHub 提示教程

    一个充满示例的教程,涵盖了我们文档中的提示工程概念。

    Google Sheets 提示教程

    通过交互式电子表格提供的我们提示工程教程的轻量级版本。

    Was this page helpful?