# 2.1 提示词基础：Claude 特定的最佳实践

> 💡 关于提示词工程的系统性介绍（清晰性、直接性、具体性原则等基础概念），请参阅《提示词工程指南》。

本章重点介绍在与 Claude 交互时的特定技巧和最佳实践，包括 Claude 偏好的格式、XML 标签用法，以及如何利用 Claude 的特定能力。

## 2.1.1 Claude 的格式偏好

Claude 特别擅长处理结构化输入。相比其他模型，Claude 对以下格式的理解更准确：

* **XML 标签**：Claude 对 XML 标签有原生亲和力，能精确解析嵌套结构和属性语义
* **Markdown**：标题层级、列表、表格等 Markdown 元素能帮助 Claude 理解信息的层次关系
* **JSON/YAML**：结构化数据格式，适合传递配置、参数等结构化输入
* **代码块**：带语言标记的代码块能让 Claude 准确识别编程语言并提供更精准的代码分析

## 2.1.2 Claude 对 XML 标签的支持

与许多其他模型不同，Claude 对 XML 标签有特殊的亲和力。当你需要表达复杂、多层次的指令时，使用 XML 能显著提高理解准确度。

```xml
<task>
  <role>你是一位资深的 Python 后端工程师</role>
  <context>这段代码用于生产环境</context>
  <requirement>审查安全性问题</requirement>
  <constraint>重点关注 SQL 注入风险</constraint>
  <output_format>JSON</output_format>
</task>
```

Claude 特别善于：

* 解析嵌套的 XML 结构
* 根据 XML 属性和标签语义调整回复
* 在需要时按 XML 标签组织输出

## 2.1.3 Claude 的特定能力

Claude 相比其他模型的优势在以下几个方面：

**长上下文处理**：Claude Opus 4.7、Sonnet 4.6 和 Opus 4.6 支持 1M Token 上下文窗口，Haiku 4.5 支持 200K Token，使其能处理更多背景信息而不丢失精准度。

**多文件分析**：Claude 擅长同时处理多个输入文件，保持跨文件的逻辑一致性。

**思维链推理**：Claude 特别响应显式要求其“逐步思考”的提示。

**引用和溯源**：当被要求时，Claude 会精确引用源文本，很少产生“幻觉”。

## 2.1.4 Claude 特定的调整技巧

| 问题          | Claude 特定的解决方案                                              |
| ----------- | ----------------------------------------------------------- |
| Claude 过度谨慎 | 明确表示你信任其判断：`根据你的最佳判断...`                                    |
| 需要深度分析      | 使用 XML 标签清晰分离阶段：`<analysis>`, `<synthesis>`, `<conclusion>` |
| 需要特定语调      | Claude 响应具体的角色设定和语气描述                                       |
| 需要完整性       | 使用 `<require>全面覆盖所有方面</require>` 而非模糊的“详细”                  |

更多 Claude 特定的高级技巧请参阅后续章节。

➡️ [使用 XML 结构化提示词](/claude_guide/di-yi-bu-fen-ji-chu-pian/02_prompt/2.2_xml.md)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://yeasy.gitbook.io/claude_guide/di-yi-bu-fen-ji-chu-pian/02_prompt/2.1_basics.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
