# 本章小结：掌握 AI 的语言艺术

提示工程（Prompt Engineering）并非魔法咒语，它是现代 AI 开发的基础语法。当你通过本章的学习，从“随便问问”进化到“结构化指令”时，你实际上已经完成了从用户到开发者视角的转变。

## 核心知识点回顾

### 三大基石：Clear, Direct, Specific

所有高级技巧都建立在清晰的表达之上。

* **消除歧义**：不要让 AI 猜。
* **肯定指令**：告诉它做什么，而不是不做什么。
* **具体语境**：像给新员工派活一样交代背景。

### 结构化思维

* **物理隔离**：用 `<tag>` 把指令和数据分开。
* **语义锚点**：XML 标签是 Claude 最熟悉的语言路标。
* **鲁棒性**：当 Context 变长时，结构化是防止模型“发疯”的唯一解药。

### 系统提示词

* 它是 AI 的“出厂设置”。
* 包含 **角色 (Role)**、**知识边界 (Scope)** 和 **风格惯例 (Tone)**。
* 具有最高的指令优先级，用于抵抗遗忘和注入攻击。

### 引导与控制技术

* **Few-Shot (举栗子)**：让 AI 模仿格式和风格，无需长篇大论。
* **Chain of Thought (列算式)**：用 `<thinking>` 强迫 AI 慢下来思考，解决复杂逻辑。
* **Structured Outputs**：新模型优先用 API 级结构约束输出格式；Prefill 只适用于仍支持该能力的旧模型。

### 工程化迭代

* Prompt 不是写出来的，是 **测出来的**。
* 建立由真实用例组成的 **Golden Dataset**。
* 利用 **Metaprompting** 让 AI 帮你写 AI。

## 开发者自检清单

在将 Prompt 部署到生产环境前，请问自己：

* [ ] **结构清晰吗？** 是否使用了 XML 区分不同部分？
* [ ] **有示例吗？** 是否提供了至少一个 Few-Shot 示例？
* [ ] **能防注入吗？** 用户输入是否被 `<user_input>` 包裹？
* [ ] **会思考吗？** 对于复杂推理，是否启用了 CoT？
* [ ] **格式对吗？** 是否使用了 Structured Outputs、严格工具输入或可解析的输出约束？

## 下一站：赋予 AI 双手

现在你已经能让 Claude 输出完美的文本了。但如果它只能说话，它依然是被困在盒子里的智者。 是时候打破第四面墙，让它连接 API、数据库和外部世界了。

➡️ [第三章：Tool Use 工具调用](/claude_guide/di-er-bu-fen-gong-ju-pian/03_tools.md)

***

> 📝 **发现错误或有改进建议？** 欢迎提交 [Issue](https://github.com/yeasy/claude_guide/issues) 或 [PR](https://github.com/yeasy/claude_guide/pulls)。


---

# 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/summary.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.
