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>
引用本页
claudexml.com — Claude XML — 使用 XML 标签为 Claude 编写提示的完整指南. https://claudexml.com/zh/