本文由 AI 分析生成
建立時間: 2025-09-29
Summary
EN: Anthropic’s official reference guide for prompt engineering with Claude, covering all major techniques: explicit formatting instructions, XML tags for structured context, role assignment, parallel tool calls, adaptive/extended thinking, and agentic system design. The guide also includes anti-patterns to avoid, such as over-engineering prompts when simpler instructions suffice.
ZH: Anthropic 官方的 Claude 提示工程參考手冊,涵蓋明確格式指示、XML 標籤結構化上下文、角色設定、平行工具呼叫、自適應/延伸思考以及代理系統設計等核心技巧,並列出應避免的反模式(如不必要的過度工程化)。
Key Points
- XML tags as structural delimiters (e.g.,
<document>,<instructions>) improve Claude’s ability to parse complex prompts - Role assignment: give Claude a specific persona/expertise context for domain-specific tasks
- Parallel tool calls: Claude can invoke multiple tools simultaneously when they don’t depend on each other — significantly reducing latency
- Extended thinking: budget tokens for longer internal reasoning chains before responding
- Agentic systems: chain prompts across steps; design for error recovery and graceful degradation
- Anti-pattern: using complex multi-step prompts when a single direct instruction is sufficient
Insights
- The XML tag guidance aligns with how models are trained — the structured delimiters make context unambiguous, reducing hallucination from ambiguous boundaries
- Parallel tool calls are often underused; most developers default to sequential calls even when parallelism is safe
- Extended thinking is not always better — the cost (latency, tokens) must be weighed against the task complexity
Connections
- Directly applicable to building the analyze-vault pipeline in this repo: XML-structured prompts + parallel reads
- Connects to SkillsBench findings: well-structured skill documentation (SKILL.md) dramatically outperforms no guidance
- The “anti-over-engineering” section echoes the DRY critique in Repeat Yourself — sometimes simplicity wins
Raw Excerpt
“Use XML tags to structure complex prompts. When your prompt contains multiple distinct components — instructions, context, examples, questions — XML tags help Claude parse the structure unambiguously and reduce the chance of conflating different parts of the input.”