---
title: 為 Claude Sonnet 5 撰寫提示
url: https://platform.claude.com/docs/zh-TW/build-with-claude/prompt-engineering/prompting-claude-sonnet-5
description: Claude Sonnet 5 的行為差異與提示模式，涵蓋 effort、自適應思考預設值以及工具使用。
---

本指南涵蓋 Claude Sonnet 5 特有的提示模式。如需了解該模型的規格，請參閱 [Claude Sonnet 5](https://platform.claude.com/docs/zh-TW/models/sonnet-5/overview)。如需適用於所有目前 Claude 模型的技巧，請參閱[提示最佳實踐](https://platform.claude.com/docs/zh-TW/build-with-claude/prompt-engineering/claude-prompting-best-practices)。

Claude Sonnet 5 在程式設計與代理式任務方面具有特別的優勢。它在現有的 Claude Sonnet 4.6 提示上開箱即用即可表現良好。本指南中的模式涵蓋最常需要調整的行為。

## 回應長度與冗長程度

Claude Sonnet 5 會根據任務的複雜度來調整回應長度，而不是預設採用固定的「verbosity」（冗長程度）。這通常意味著在簡單查詢上給出較短的答案，而在開放式分析上給出較長的答案。

如果您的產品依賴特定的輸出風格或冗長程度，您可能需要調整提示。舉例來說，若要降低冗長程度，您可以加入：

```text wrap
Provide concise, focused responses. Skip non-essential context, and keep examples minimal.
```

如果您看到特定類型的冗長（例如過度解釋），您可以在提示中加入額外的指示來避免。展示 Claude 如何以適當簡潔程度進行溝通的正面範例，往往比負面範例或告訴模型不要做什麼的指示更有效。

## 校準 effort 與思考深度

[effort 參數](https://platform.claude.com/docs/zh-TW/build-with-claude/effort)可讓您在 Claude 的智慧程度與 token 花費之間進行調整，以能力換取更快的速度與更低的成本。在 Claude Sonnet 5 上，effort 預設為 `high`，與 Claude Sonnet 4.6 相同。對於最困難的程式設計與代理式任務，請將 effort 提高到 `xhigh`。您可以嘗試其他 effort 等級，以進一步調整 token 使用量與智慧程度：

* **`max`：** 絕對最高的能力，對 token 花費沒有任何限制。
* **`xhigh`：** 超高 effort 是最困難的程式設計與代理式使用情境的建議設定。
* **`high`：** 預設值。此設定在大多數使用情境中平衡 token 使用量與智慧程度。
* **`medium`：** 適合對成本敏感、需要在犧牲部分智慧程度的情況下減少 token 使用量的使用情境。
* **`low`：** 保留給簡短、範圍明確的任務，以及對「latency」（延遲）敏感但對智慧程度不敏感的工作負載。

遷移時的粗略跨模型對應如下：Claude Sonnet 5 在 medium 時的智慧程度與 Claude Sonnet 4.6 在 high 時相當，而 Claude Sonnet 5 在 high 時則與 Claude Sonnet 4.6 在 max 時相當。進行基準測試時，請依據觀察到的思考長度來對應，而不是依據 effort 名稱。

Claude Sonnet 5 會嚴格遵守 effort 等級，尤其是在低端。在 `low` 與 `medium` 時，模型會將工作範圍限縮在所要求的內容，而不會超出請求範圍。這對延遲與成本有利，但在以 `low` effort 執行中等複雜度的任務時，存在一定程度思考不足的風險。

如果您在複雜問題上觀察到推理過於淺薄，請將 effort 提高到 `high` 或 `xhigh`，而不是透過提示來繞過問題。如果您因延遲考量需要將 effort 維持在 `low`，請加入有針對性的指引：

```text wrap
This task involves multistep reasoning. Think carefully through the problem before responding.
```

在 Claude Sonnet 5 上，[「adaptive thinking」（自適應思考）](https://platform.claude.com/docs/zh-TW/build-with-claude/thinking)預設為開啟。沒有 `thinking` 欄位的請求會以自適應思考執行。這與 Claude Sonnet 4.6 不同，在 Claude Sonnet 4.6 上，相同的請求會在沒有思考的情況下執行。若要完全關閉思考，請傳入 `thinking: {type: "disabled"}`。由於 `max_tokens` 是總輸出（思考加上回應文字）的硬性上限，請針對在 Claude Sonnet 4.6 上未使用思考執行的工作負載重新檢視此設定。如果您先前在 Claude Sonnet 4.6 上關閉思考，請嘗試在 Claude Sonnet 5 上開啟思考並搭配較低的 effort 等級。

自適應思考的觸發行為是可引導的。如果您發現模型輸出思考區塊的頻率高於您的期望（這可能發生在大型或複雜的系統提示中），請加入指引來引導它。一如往常，請衡量任何提示變更對效能的影響。範例：

```text wrap
Thinking adds latency and should only be used when it will meaningfully improve answer quality, typically for problems that require multistep reasoning. When in doubt, respond directly.
```

相反地，如果您以 `medium` 執行困難的工作負載並看到思考不足的情況，首要的調整手段是提高 effort。如果您需要更精細的控制，請直接透過提示來要求。

手動「extended thinking」（擴展思考）（`thinking: {type: "enabled", budget_tokens: N}`）在 Claude Sonnet 5 上不受支援，並會傳回 400 錯誤。它在 Claude Sonnet 4.6 上已被棄用，現在已被移除。請改用自適應思考搭配 effort 參數。

<Note>
  如果您以 `high`、`xhigh` 或 `max` effort 執行 Claude Sonnet 5，請在 `max_tokens` 中保留餘裕，讓模型有空間進行思考與工具呼叫。在長時間任務中，自適應思考可能會使用大部分的預算；如果預算吃緊，您可能會看到回應幾乎全部是思考內容，接著是被截斷的答案以及 `stop_reason: "max_tokens"`。提高 `max_tokens` 或降至 `medium` effort 即可解決此問題。由於 Claude Sonnet 5 使用新的「tokenizer」（分詞器），對於相同文字會產生約多 30% 的 token，因此為 Claude Sonnet 4.6 調整的 `max_tokens` 上限可能會截斷同等的輸出。確切的增幅取決於內容與工作負載的型態。
</Note>

## 工具使用的觸發

Claude Sonnet 5 預設比 Claude Sonnet 4.6 更具代理性，更容易主動使用工具並執行自我驗證迴圈。在停用思考的情況下，模型較不會主動使用工具或考慮搜尋；如果您在關閉思考時仰賴工具呼叫，請在系統提示中加入明確的提示。effort 也是影響工具使用的手段：`high` 或 `xhigh` effort 設定在代理式搜尋與程式設計中會顯示出明顯更多的工具使用。對於您希望有更多工具使用的情境，您也可以調整提示，明確指示模型何時以及如何正確使用其工具。例如，如果您發現模型沒有使用您的網頁搜尋工具，請清楚說明為何以及如何使用。

## 面向使用者的進度更新

Claude Sonnet 5 會在長時間的代理式執行過程中，定期向使用者提供品質更高的更新。如果您曾加入鷹架來強制產生中間狀態訊息（「每 3 次工具呼叫後，總結進度」），請嘗試將其移除。如果您發現 Claude Sonnet 5 面向使用者的更新在長度或內容上與您的使用情境不太契合，請在提示中明確描述這些更新應有的樣貌並提供範例。

## 更字面化的指示遵循

Claude Sonnet 5 會以字面且明確的方式解讀提示，尤其是在較低的 effort 等級時。它不會默默地將一項指示從一個項目推廣到另一個項目，也不會推斷您未提出的要求。這種字面化的優點是精確，而且它通常在具有精心調整提示的 API 使用情境、結構化擷取，以及您希望行為可預測的管線中表現更好。如果您需要 Claude 廣泛套用某項指示，請明確說明範圍（例如：「將此格式套用到每個章節，而不只是第一個章節」）。

## 語氣與寫作風格

如同任何新模型，長篇寫作的文風可能會有所改變。如果您的產品仰賴特定語氣，請針對新的基準重新評估風格提示。

例如，如果您的產品語調較為溫暖或更具對話性，請加入：

```text wrap
Use a warm, collaborative tone. Acknowledge the user's framing before answering.
```

如果您先前依賴 `temperature` 來獲得風格上的多樣性，請注意，設定 `temperature`、`top_p` 或 `top_k` 在 Claude Sonnet 5 上會傳回 400 錯誤。此限制對 Sonnet 等級的模型而言是新的。遷移時請移除這些參數，並改用系統提示指示來引導語氣與多樣性。

## 設計與前端預設值

在開放式的前端與設計需求上，Claude Sonnet 5 可能會固定採用一致的預設視覺風格。預設的內部風格對某些需求來說效果不錯，但可能不適合儀表板、開發者工具、金融科技、醫療保健或企業應用程式。

籠統的指示（「不要使用那個顏色」、「讓它簡潔極簡」）往往會讓模型轉向另一個固定的配色，而不是產生多樣性。有兩種方法能可靠地奏效：

**1. 指定具體的替代方案。** 模型會精確遵循明確的規格：

```text wrap
Design a desktop landing page for a supplement brand called AEFRM.

The visual direction should come from a cold monochrome atmosphere using pale silver-gray tones that gradually deepen into blue-gray and near-black, similar to a misted metallic surface.

The page should feel sharp and controlled, with a strong sense of structure and restraint.

Use this tonal system across the full page instead of introducing bright accent colors.

Use the uploaded image on the hero design in black and white.

The layout should be built with clear horizontal sections and a centered max-width container. Use 4px corner radius consistently across cards, buttons, inputs, and media frames. Margins should feel generous, with enough empty space around each section so the page breathes.

Typography should use a square, angular sans-serif with wider letter spacing than usual, especially in headings and navigation, so the text feels more engineered and less compressed. Headline text can be large and uppercase, while supporting copy remains short and sparse. The sub texts should be written with Alumni Sans SC in 4-6px like tiny little texts on corners bottom centre like that.

For the structure, start with a hero section containing a strong product statement, one short supporting paragraph, and a clean product placeholder or packshot frame. Below that, add a benefit grid with three or four blocks, then a formulation or ingredients section, and finally a cta.

Buttons should be flat and precise, with subtle hover changes using transition: all 160ms ease out where brightness and border contrast shift slightly rather than using dramatic motion.

Color palette should stay within this range:
#E9ECEC, #C9D2D4, #8C9A9E, #44545B, #11171B.
```

**2. 讓模型在建構之前先提出選項。** 這能打破預設並讓使用者掌握控制權。由於 Claude Sonnet 5 不接受 `temperature`，此方法是在多次執行中產生具有實質差異的設計方向的建議方式。範例提示：

```text wrap
Before building, propose 4 distinct visual directions tailored to this brief (each as: bg hex / accent hex / typeface, plus a one-line rationale). Ask the user to pick one, then implement only that direction.
```

若要避開使用者所稱的「AI slop」美學這類通用模式，您可以在系統提示中加入一段簡短的指令。[frontend-design 技能](https://github.com/anthropics/claude-code/blob/main/plugins/frontend-design/skills/frontend-design/SKILL.md)提供了更完整的處理方式，但以下片段與前述的多樣性方法搭配使用效果良好：

```text wrap
<frontend_aesthetics>
NEVER use generic AI-generated aesthetics like overused font families (Inter, Roboto, Arial, system fonts), cliched color schemes (particularly purple gradients on white or dark backgrounds), predictable layouts and component patterns, and cookie-cutter design that lacks context-specific character. Use unique fonts, cohesive colors and themes, and animations for effects and micro-interactions.
</frontend_aesthetics>
```

## 互動式程式設計產品

在僅有單一使用者回合的自主、非同步程式設計代理，與有多個使用者回合的互動式、同步程式設計代理之間，token 用量與行為可能會有所不同。若要在程式設計產品中同時最大化效能與 token 效率，請使用 `xhigh` 或 `high` effort、加入自動模式等自主功能，並減少使用者所需的人工互動次數。

在限制所需的使用者互動次數時，重要的是在第一個人類回合中預先說明任務、意圖與相關限制。預先提供明確、清楚且準確的任務描述，有助於最大化自主性與智慧程度，同時將使用者回合後的額外 token 使用量降到最低。相反地，在多個使用者回合中逐步傳達的模糊或說明不足的提示，往往會相對降低 token 效率，有時也會降低效能。

## 程式碼審查框架

如果您的程式碼審查框架是為較早的模型調整的，您一開始可能會在 Claude Sonnet 5 上看到較低的召回率。這很可能是框架造成的影響，而非能力退步。當審查提示中寫著「只回報高嚴重性的問題」、「保守一點」或「不要吹毛求疵」之類的內容時，Claude Sonnet 5 可能會比早期模型更忠實地遵循該指示：它可能同樣徹底地調查程式碼、找出錯誤，然後不回報它判定低於您所述標準的發現。這可能表現為模型進行相同深度的調查，但轉化為回報發現的調查較少，尤其是較低嚴重性的錯誤。精確率通常會上升，但即使模型底層的找錯能力已經提升，測得的召回率仍可能下降。

一些建議的提示用語：

```text wrap
Report every issue you find, including ones you are uncertain about or consider low-severity. Do not filter for importance or confidence at this stage - a separate verification step will do that. Your goal here is coverage: it is better to surface a finding that later gets filtered out than to silently drop a real bug. For each finding, include your confidence level and an estimated severity so a downstream filter can rank them.
```

此提示可以在沒有實際第二步驟的情況下使用，但將信心篩選從發現步驟中移出通常會有幫助。如果您的框架有獨立的驗證、去重或排序階段，請明確告訴模型，它在發現階段的工作是涵蓋範圍，而不是篩選。

如果您確實希望模型在單次處理中自行篩選，請具體說明回報門檻，而不是使用「重要」之類的定性用語：例如，「回報任何可能導致錯誤行為、測試失敗或誤導性結果的錯誤；只省略純粹的風格或命名偏好等細節問題。」

請針對您的評估或測試案例的子集反覆調整提示，以驗證召回率或「F1 score」（F1 分數）的提升。

## 電腦使用

Claude Sonnet 5 透過 `computer_toolset_20260801` 工具集以及 `computer_20251124` 工具版本支援電腦使用。它也支援[瀏覽器使用工具](https://platform.claude.com/docs/zh-TW/agents-and-tools/tool-use/browser-use-tool)（`browser_toolset_20260801`），用於在網頁內執行任務。[Computer use](https://platform.claude.com/docs/zh-TW/agents-and-tools/tool-use/computer-use-tool)（電腦使用）功能可在各種解析度下運作，最高解析度為 2576px / 3.75MP。內部電腦使用測試顯示，以 1080p 傳送圖片能在效能與成本之間取得良好的平衡。

對於特別注重成本的工作負載，720p 或 1366×768 是成本較低且效能強勁的選項。請自行進行測試，以找出最適合您使用情境的設定；嘗試不同的 effort 設定也有助於調整模型的行為。
