<claudexml/>
claudexml.com

Claude XML:使用 XML 标签为 Claude 编写提示的完整指南

XML 标签是 Anthropic 推荐用于构建 Claude 提示的方式。它们让指令清晰无歧义,把上下文与问题分开,显著提高输出的可靠性。

Claude XML 是把提示的不同部分包裹在类 XML 标签中的约定 — 如 <instructions><context><example><document><thinking> — 让 Claude 能可靠地区分每段的作用。Claude 在训练中大量见过这些标签,会高保真地遵循。它们并非真正的 XML,也不会被校验,只是一种约定。

为什么对 Claude 特别有效

Anthropic 官方文档把 XML 标签列为首选的结构化工具。三大原因:训练信号强、边界清晰、便于程序化抽取。

30 秒上手

最实用的模式:把指令、上下文和问题分开。

<instructions>
You are reviewing a customer support ticket. Classify the sentiment as
positive, neutral, or negative. Return only the label.
</instructions>

<ticket>
Hi — the new dashboard is so much faster. Thank you for shipping this.
</ticket>

→ Full reference in English

引用本页
claudexml.com — Claude XML — 使用 XML 标签为 Claude 编写提示的完整指南. https://claudexml.com/zh/