原典: Best practices for prompt engineering

一行要約

大半はモデルを問わない一般論。Claude 4.x を名指しする箇所(例の細部への注意深さ、技法選択表の extended thinking、長い文脈の context awareness)と、Claude 5 世代・CLAUDE.md・skills に触れる箇所がある。最も価値があるのは「問題 → 対処」のトラブルシューティング表と、「もう古い技法」の名指し(重い XML タグ、role prompting)。

The best prompt isn’t the longest or most complex. It’s the one that achieves your goals reliably with the minimum necessary structure.

最良のプロンプトは、最も長いものでも最も複雑なものでもない。必要最小限の構造で、目的を確実に達成するものである。

要点

Prompt engineering is the craft of structuring instructions to get better outputs from AI models.

prompt engineering とは、AI モデルからより良い出力を得るために指示を構造化する技芸である。

However, prompting is converging with context engineering for Claude 5 generation models — less scaffolding, more curation.

ただし、Claude 5 世代のモデルでは、prompting は context engineering に収束しつつある。足場を組むことは減り、選び抜くことが増える。

それでも prompt engineering の重要性は下がらない、と結びで釘を刺している:

However, the shift toward context engineering doesn’t diminish prompt engineering’s importance. In fact, prompt engineering is a fundamental building block within context engineering.

とはいえ、context engineering への移行は prompt engineering の重要性を損なわない。実際、prompt engineering は context engineering の中の基本的な構成要素である。

中核の4技法

  1. 明示的かつ明確に — 直接的な動作動詞で曖昧さを消す
  2. 文脈と動機を与える — 「なぜ」を説明すると、モデルが目的を理解できる
  3. 具体的に — 制約、文脈、構造、要件を含める
  4. 例を使う — one-shot / few-shot で形式の期待を明確にする

発展的な技法

  • prefill による形式制御(Claude 4.6 以降では非対応。increase-consistency 参照)

  • chain of thought

    When available, extended thinking is generally preferable to manual chain of thought prompting.

    使えるなら、extended thinking のほうが手で書く chain of thought prompting より概ね望ましい。

    使いどころは4つ: extended thinking が無いとき、読み返せる推論が欲しいとき、複数の分析段階が要るとき、特定の観点を必ず考慮させたいとき。そのうえで:

    Even when extended thinking is available, explicit CoT prompting can still be beneficial for complex tasks. The two approaches are complementary, not mutually exclusive.

    extended thinking が使えるときでも、複雑なタスクでは明示的な CoT prompting が依然として有益でありうる。両者は補い合うもので、排他ではない。

  • prompt chaining —— レイテンシと引き換えに精度を上げる(各タスクを易しくする)

  • 出力形式の制御 —— 3つの手:

    1. しないことではなく、することを言う(“Do not use markdown” ではなく “Your response should be composed of smoothly flowing prose paragraphs”)
    2. prompt の書式を欲しい出力に合わせる(markdown を減らしたいなら prompt の markdown を減らす)
    3. 書式の好みを明示する

長い内容を扱うとき

  • 最も重要な情報は先頭か末尾に置く(別の規則として、claude-prompting-best-practices は 20k トークン超の資料で「資料を先頭、クエリを末尾」を勧める)
  • タスクを小さく分けるのは、文脈の限界のためではなく、範囲をはっきりさせてモデルに最善を尽くさせるため。境界のはっきりした焦点のあるタスクは、1つの prompt で複数の目的を果たそうとするより一貫して質が高い

トラブルシューティング表(この記事で最も実用的)

問題対処
出力が一般的すぎる具体性を足す、例を足す、網羅的な出力を要求する
話が逸れる実際の目的を明示する、文脈を与える
形式が一貫しないfew-shot 例を足す、または prefill
タスクが複雑すぎる複数のプロンプトに分割する(chaining)
不要な前置きが付くprefill、または直接答えるよう明示的に要求する
hallucination「わからない」と言う許可を明示的に与える
頼んでいない提案が来る行動について明示する(“Suggest changes” ではなく “Change this”)

避けるべき間違い

  • 不要な複雑さによる過剰設計
  • 発展的な技法を追って基本を無視する
  • AI が心を読むと仮定する(具体的に書く)
  • すべての技法を同時に使う
  • 反復と洗練を飛ばす
  • 古くなった技法に頼る(重い XML タグ、role prompting)

Prompt engineering is ultimately about communication: speaking the language that helps AI most clearly understand your intent.

prompt engineering は突き詰めれば伝達の問題である。自分の意図を AI が最も明確に理解できる言葉で語ることだ。

For instructions you want applied to every session rather than every prompt, move them into CLAUDE.md files, skills, or other steering methods.

prompt ごとではなくセッションごとに効かせたい指示は、CLAUDE.md、skills、その他の誘導手段に移せ。

そのまま使える具体例

明示的に書く:

❌ Create an analytics dashboard
✅ Create an analytics dashboard. Include as many relevant features and interactions as possible. Go beyond the basics to create a fully-featured implementation.

文脈と動機を与える(理由を書くと一般化できる):

❌ NEVER use bullet points
✅ I prefer responses in natural paragraph form rather than bullet points because I find flowing prose easier to read and more conversational.

具体的に書く:

❌ Create a meal plan for a Mediterranean diet
✅ Design a Mediterranean diet meal plan for pre-diabetic management. 1,800 calories daily, emphasis on low glycemic foods. List breakfast, lunch, dinner, and one snack with complete nutritional breakdowns.

不確実性を認める許可(hallucination 対策):

Analyze this financial data and identify trends. If the data is insufficient to draw conclusions, say so rather than speculating.

chain of thought:

Think step-by-step before you write the email.

形式の制御:

Your response should be composed of smoothly flowing prose paragraphs... Reserve markdown primarily for inline code, code blocks, and simple headings. DO NOT use ordered lists or unordered lists unless...

原典で言及されている関連文書