Loading...
    • 開發者指南
    • API 參考
    • MCP
    • 資源
    • 發行說明
    Search...
    ⌘K
    入門
    Claude 簡介快速開始
    模型與定價
    模型概覽選擇模型Claude 4.6 新功能遷移指南模型棄用定價
    使用 Claude 構建
    功能概覽使用 Messages API處理停止原因提示詞最佳實踐
    上下文管理
    上下文視窗壓縮上下文編輯
    功能
    提示詞快取延伸思考自適應思考思考力度串流訊息批次處理引用多語言支援Token 計數嵌入視覺PDF 支援Files API搜尋結果結構化輸出
    工具
    概覽如何實作工具使用細粒度工具串流Bash 工具程式碼執行工具程式化工具呼叫電腦使用工具文字編輯器工具網頁擷取工具網頁搜尋工具記憶工具工具搜尋工具
    Agent Skills
    概覽快速開始最佳實踐企業級 Skills透過 API 使用 Skills
    Agent SDK
    概覽快速開始TypeScript SDKTypeScript V2(預覽版)Python SDK遷移指南
    API 中的 MCP
    MCP 連接器遠端 MCP 伺服器
    第三方平台上的 Claude
    Amazon BedrockMicrosoft FoundryVertex AI
    提示詞工程
    概覽提示詞產生器使用提示詞範本提示詞改進器清晰直接使用範例(多範例提示)讓 Claude 思考(CoT)使用 XML 標籤賦予 Claude 角色(系統提示詞)串聯複雜提示詞長上下文技巧延伸思考技巧
    測試與評估
    定義成功標準開發測試案例使用評估工具降低延遲
    強化防護機制
    減少幻覺提高輸出一致性防範越獄攻擊串流拒絕減少提示詞洩漏讓 Claude 保持角色
    管理與監控
    Admin API 概覽資料駐留工作區用量與成本 APIClaude Code Analytics API零資料保留
    Console
    Log in
    Loading...
    Loading...
    Loading...
    Loading...
    Loading...
    Loading...
    Loading...
    Loading...
    Loading...
    Loading...
    Loading...
    Loading...
    Loading...
    Loading...
    Loading...
    Loading...

    Solutions

    • AI agents
    • Code modernization
    • Coding
    • Customer support
    • Education
    • Financial services
    • Government
    • Life sciences

    Partners

    • Amazon Bedrock
    • Google Cloud's Vertex AI

    Learn

    • Blog
    • Catalog
    • Courses
    • Use cases
    • Connectors
    • Customer stories
    • Engineering at Anthropic
    • Events
    • Powered by Claude
    • Service partners
    • Startups program

    Company

    • Anthropic
    • Careers
    • Economic Futures
    • Research
    • News
    • Responsible Scaling Policy
    • Security and compliance
    • Transparency

    Learn

    • Blog
    • Catalog
    • Courses
    • Use cases
    • Connectors
    • Customer stories
    • Engineering at Anthropic
    • Events
    • Powered by Claude
    • Service partners
    • Startups program

    Help and security

    • Availability
    • Status
    • Support
    • Discord

    Terms and policies

    • Privacy policy
    • Responsible disclosure policy
    • Terms of service: Commercial
    • Terms of service: Consumer
    • Usage policy
    使用 Claude 構建

    提示詞最佳實踐

    本指南提供適用於 Claude 最新模型的提示工程技巧,包括 Claude Opus 4.6、Claude Sonnet 4.5 和 Claude Haiku 4.5。

    本指南提供適用於 Claude 最新模型的提示工程技巧,包括 Claude Opus 4.6、Claude Sonnet 4.5 和 Claude Haiku 4.5。這些模型經過訓練,能比前幾代 Claude 模型更精確地遵循指令。

    如需模型功能概覽,請參閱模型概覽。如需了解 Claude 4.6 的新功能,請參閱 Claude 4.6 的新功能。如需遷移指南,請參閱遷移指南。

    一般原則

    明確表達您的指令

    Claude 對清晰、明確的指令反應良好。具體說明您期望的輸出可以幫助提升結果。如果您想要「超越預期」的行為,請明確要求,而不是依賴模型從模糊的提示中推斷。

    添加上下文以提升效能

    提供指令背後的上下文或動機,例如向 Claude 解釋為什麼這種行為很重要,可以幫助 Claude 更好地理解您的目標並提供更有針對性的回應。

    Claude 足夠聰明,能從解釋中進行泛化。

    謹慎對待範例和細節

    Claude 會密切關注細節和範例,這是其精確指令遵循能力的一部分。確保您的範例與您想要鼓勵的行為一致,並盡量減少您想要避免的行為。

    長期推理和狀態追蹤

    Claude 的最新模型在長期推理任務方面表現出色,具有卓越的狀態追蹤能力。Claude 透過專注於漸進式進展來保持在延長會話中的方向感——一次穩步推進幾件事,而不是試圖一次完成所有事情。這種能力特別在多個上下文視窗或任務迭代中展現,Claude 可以處理複雜任務、儲存狀態,然後在新的上下文視窗中繼續。

    上下文感知和多視窗工作流程

    Claude Opus 4.6 和 Claude 4.5 模型具有上下文感知功能,使模型能夠在對話過程中追蹤其剩餘的上下文視窗(即「token 預算」)。這使 Claude 能夠透過了解可用空間來更有效地執行任務和管理上下文。

    管理上下文限制:

    如果您在代理框架中使用 Claude,該框架會壓縮上下文或允許將上下文儲存到外部檔案(如在 Claude Code 中),我們建議將此資訊添加到您的提示中,以便 Claude 能夠相應地行動。否則,Claude 有時可能會在接近上下文限制時自然地嘗試結束工作。以下是一個範例提示:

    範例提示
    Your context window will be automatically compacted as it approaches its limit, allowing you to continue working indefinitely from where you left off. Therefore, do not stop tasks early due to token budget concerns. As you approach your token budget limit, save your current progress and state to memory before the context window refreshes. Always be as persistent and autonomous as possible and complete tasks fully, even if the end of your budget is approaching. Never artificially stop any task early regardless of the context remaining.

    記憶工具與上下文感知自然搭配,實現無縫的上下文轉換。

    多上下文視窗工作流程

    對於跨越多個上下文視窗的任務:

    1. 為第一個上下文視窗使用不同的提示:使用第一個上下文視窗來建立框架(撰寫測試、建立設定腳本),然後使用後續的上下文視窗在待辦清單上進行迭代。

    2. 讓模型以結構化格式撰寫測試:要求 Claude 在開始工作之前建立測試,並以結構化格式(例如 tests.json)追蹤它們。這有助於更好的長期迭代能力。提醒 Claude 測試的重要性:「移除或編輯測試是不可接受的,因為這可能導致功能缺失或出現錯誤。」

    3. 設定便利工具:鼓勵 Claude 建立設定腳本(例如 init.sh)來優雅地啟動伺服器、執行測試套件和程式碼檢查工具。這可以防止在從新的上下文視窗繼續時重複工作。

    4. 全新開始 vs 壓縮:當上下文視窗被清除時,考慮使用全新的上下文視窗而不是使用壓縮。Claude 的最新模型在從本地檔案系統發現狀態方面非常有效。在某些情況下,您可能想要利用這一點而不是壓縮。明確指示它應該如何開始:

      • "Call pwd; you can only read and write files in this directory."
      • "Review progress.txt, tests.json, and the git logs."
      • "Manually run through a fundamental integration test before moving on to implementing new features."
    5. 提供驗證工具:隨著自主任務長度的增長,Claude 需要在沒有持續人類回饋的情況下驗證正確性。像 Playwright MCP 伺服器或用於測試 UI 的電腦使用功能等工具很有幫助。

    6. 鼓勵完整使用上下文:提示 Claude 在繼續之前有效地完成元件:

    範例提示
    This is a very long task, so it may be beneficial to plan out your work clearly. It's encouraged to spend your entire output context working on the task - just make sure you don't run out of context with significant uncommitted work. Continue working systematically until you have completed this task.

    狀態管理最佳實踐

    • 使用結構化格式儲存狀態資料:在追蹤結構化資訊(如測試結果或任務狀態)時,使用 JSON 或其他結構化格式來幫助 Claude 理解架構需求
    • 使用非結構化文字記錄進度筆記:自由格式的進度筆記適合追蹤一般進度和上下文
    • 使用 git 進行狀態追蹤:Git 提供了已完成工作的日誌和可以恢復的檢查點。Claude 的最新模型在使用 git 跨多個會話追蹤狀態方面表現特別出色。
    • 強調漸進式進展:明確要求 Claude 追蹤其進度並專注於漸進式工作

    溝通風格

    Claude 的最新模型與先前的模型相比,具有更簡潔和自然的溝通風格:

    • 更直接和務實:提供基於事實的進度報告,而非自我慶祝式的更新
    • 更具對話性:略微更流暢和口語化,較少機械感
    • 較不冗長:除非另有提示,否則可能會為了效率而跳過詳細摘要

    這種溝通風格準確反映了已完成的工作,沒有不必要的贅述。

    特定情境的指導

    平衡冗長度

    Claude 的最新模型傾向於效率,可能會在工具呼叫後跳過口頭摘要,直接進入下一個動作。雖然這創造了精簡的工作流程,但您可能更希望看到其推理過程。

    如果您希望 Claude 在工作時提供更新:

    範例提示
    After completing a task that involves tool use, provide a quick summary of the work you've done.

    工具使用模式

    Claude 的最新模型經過精確指令遵循訓練,受益於明確指示使用特定工具。如果您說「你能建議一些修改嗎」,Claude 有時會提供建議而不是實施它們——即使進行修改可能是您的本意。

    要讓 Claude 採取行動,請更明確:

    要讓 Claude 預設更主動地採取行動,您可以將以下內容添加到您的系統提示中:

    主動行動的範例提示
    <default_to_action>
    By default, implement changes rather than only suggesting them. If the user's intent is unclear, infer the most useful likely action and proceed, using tools to discover any missing details instead of guessing. Try to infer the user's intent about whether a tool call (e.g., file edit or read) is intended or not, and act accordingly.
    </default_to_action>

    另一方面,如果您希望模型預設更謹慎,不太容易直接跳入實作,只在被要求時才採取行動,您可以使用如下提示來引導這種行為:

    保守行動的範例提示
    <do_not_act_before_instructions>
    Do not jump into implementatation or changes files unless clearly instructed to make changes. When the user's intent is ambiguous, default to providing information, doing research, and providing recommendations rather than taking action. Only proceed with edits, modifications, or implementations when the user explicitly requests them.
    </do_not_act_before_instructions>

    工具使用和觸發

    Claude Opus 4.5 和 Claude Opus 4.6 比先前的模型對系統提示更敏感。如果您的提示是為了減少工具或技能的觸發不足而設計的,這些模型現在可能會過度觸發。解決方法是減弱任何激進的語言。在您可能曾經說「關鍵:您必須在...時使用此工具」的地方,您可以使用更正常的提示,如「在...時使用此工具」。

    平衡自主性和安全性

    在沒有指導的情況下,Claude Opus 4.6 可能會採取難以逆轉或影響共享系統的行動,例如刪除檔案、強制推送或發布到外部服務。如果您希望 Claude Opus 4.6 在採取潛在風險行動之前進行確認,請在您的提示中添加指導:

    範例提示
    Consider the reversibility and potential impact of your actions. You are encouraged to take local, reversible actions like editing files or running tests, but for actions that are hard to reverse, affect shared systems, or could be destructive, ask the user before proceeding.
    
    Examples of actions that warrant confirmation:
    - Destructive operations: deleting files or branches, dropping database tables, rm -rf
    - Hard to reverse operations: git push --force, git reset --hard, amending published commits
    - Operations visible to others: pushing code, commenting on PRs/issues, sending messages, modifying shared infrastructure
    
    When encountering obstacles, do not use destructive actions as a shortcut. For example, don't bypass safety checks (e.g. --no-verify) or discard unfamiliar files that may be in-progress work.

    過度思考和過度徹底

    Claude Opus 4.6 比先前的模型進行了明顯更多的前期探索,特別是在較高的 effort 設定下。這些初始工作通常有助於優化最終結果,但模型可能會在沒有提示的情況下收集大量上下文或追蹤多個研究線索。如果您的提示之前鼓勵模型更加徹底,您應該為 Claude Opus 4.6 調整該指導:

    • 用更有針對性的指令替換籠統的預設值。 不要說「預設使用 [tool]」,而是添加指導如「當 [tool] 能增強您對問題的理解時使用它。」
    • 移除過度提示。 在先前模型中觸發不足的工具現在可能會適當觸發。像「如果有疑問,使用 [tool]」這樣的指令會導致過度觸發。
    • 使用 effort 作為後備方案。 如果 Claude 繼續過於激進,請使用較低的 effort 設定。

    在某些情況下,Claude Opus 4.6 可能會進行大量思考,這可能會增加思考 token 並減慢回應速度。如果這種行為不可取,您可以添加明確的指令來限制其推理,或者您可以降低 effort 設定以減少整體思考和 token 使用。

    範例提示
    When you're deciding how to approach a problem, choose an approach and commit to it. Avoid revisiting decisions unless you encounter new information that directly contradicts your reasoning. If you're weighing two approaches, pick one and see it through. You can always course-correct later if the chosen approach fails.

    控制回應格式

    我們發現以下幾種方式在引導輸出格式方面特別有效:

    1. 告訴 Claude 該做什麼,而不是不該做什麼

      • 不要說:「不要在回應中使用 markdown」
      • 嘗試:「您的回應應由流暢的散文段落組成。」
    2. 使用 XML 格式指示器

      • 嘗試:「將回應的散文部分寫在 <smoothly_flowing_prose_paragraphs> 標籤中。」
    3. 使您的提示風格與期望的輸出相匹配

      提示中使用的格式風格可能會影響 Claude 的回應風格。如果您在輸出格式的可控性方面仍然遇到問題,我們建議盡可能使您的提示風格與期望的輸出風格相匹配。例如,從提示中移除 markdown 可以減少輸出中 markdown 的數量。

    4. 使用詳細的提示來設定特定的格式偏好

      要更好地控制 markdown 和格式使用,請提供明確的指導:

    最小化 markdown 的範例提示
    <avoid_excessive_markdown_and_bullet_points>
    When writing reports, documents, technical explanations, analyses, or any long-form content, write in clear, flowing prose using complete paragraphs and sentences. Use standard paragraph breaks for organization and reserve markdown primarily for `inline code`, code blocks (```...```), and simple headings (###, and ###). Avoid using **bold** and *italics*.
    
    DO NOT use ordered lists (1. ...) or unordered lists (*) unless : a) you're presenting truly discrete items where a list format is the best option, or b) the user explicitly requests a list or ranking
    
    Instead of listing items with bullets or numbers, incorporate them naturally into sentences. This guidance applies especially to technical writing. Using prose instead of excessive formatting will improve user satisfaction. NEVER output a series of overly short bullet points.
    
    Your goal is readable, flowing text that guides the reader naturally through ideas rather than fragmenting information into isolated points.
    </avoid_excessive_markdown_and_bullet_points>

    研究和資訊收集

    Claude 的最新模型展示了卓越的代理搜尋能力,能夠有效地從多個來源查找和綜合資訊。為獲得最佳研究結果:

    1. 提供明確的成功標準:定義什麼構成您研究問題的成功答案

    2. 鼓勵來源驗證:要求 Claude 跨多個來源驗證資訊

    3. 對於複雜的研究任務,使用結構化方法:

    複雜研究的範例提示
    Search for this information in a structured way. As you gather data, develop several competing hypotheses. Track your confidence levels in your progress notes to improve calibration. Regularly self-critique your approach and plan. Update a hypothesis tree or research notes file to persist information and provide transparency. Break down this complex research task systematically.

    這種結構化方法使 Claude 能夠查找和綜合幾乎任何資訊,並反覆批判其發現,無論語料庫的大小如何。

    子代理編排

    Claude 的最新模型展示了顯著改進的原生子代理編排能力。這些模型能夠識別何時任務會受益於將工作委派給專門的子代理,並在不需要明確指令的情況下主動這樣做。

    要利用這種行為:

    1. 確保定義良好的子代理工具:在工具定義中提供可用且有描述的子代理工具
    2. 讓 Claude 自然編排:Claude 會在不需要明確指令的情況下適當地委派
    3. 注意過度使用:Claude Opus 4.6 對子代理有強烈的偏好,可能會在更簡單、直接的方法就足夠的情況下生成子代理。例如,模型可能會為程式碼探索生成子代理,而直接的 grep 呼叫更快且足夠。

    如果您看到過度使用子代理的情況,請添加關於何時應該和不應該使用子代理的明確指導:

    子代理使用的範例提示
    Use subagents when tasks can run in parallel, require isolated context, or involve independent workstreams that don't need to share state. For simple tasks, sequential operations, single-file edits, or tasks where you need to maintain context across steps, work directly rather than delegating.

    模型自我認知

    如果您希望 Claude 在您的應用程式中正確識別自己或使用特定的 API 字串:

    模型身份的範例提示
    The assistant is Claude, created by Anthropic. The current model is Claude Opus 4.6.

    對於需要指定模型字串的 LLM 驅動應用程式:

    模型字串的範例提示
    When an LLM is needed, please default to Claude Opus 4.6 unless the user requests otherwise. The exact model string for Claude Opus 4.6 is claude-opus-4-6.

    思考敏感度

    當延伸思考被停用時,Claude Opus 4.5 對「think」這個詞及其變體特別敏感。我們建議用傳達類似含義的替代詞替換「think」,例如「consider」、「believe」和「evaluate」。

    善用思考和交錯思考能力

    Claude 的最新模型提供思考能力,這對於涉及工具使用後反思或複雜多步驟推理的任務特別有幫助。您可以引導其初始或交錯思考以獲得更好的結果。

    Claude Opus 4.6 使用自適應思考(thinking: {type: "adaptive"}),其中 Claude 動態決定何時以及思考多少。Claude 根據兩個因素校準其思考:effort 參數和查詢複雜度。較高的 effort 會引發更多思考,更複雜的查詢也是如此。對於不需要思考的簡單查詢,模型會直接回應。在內部評估中,自適應思考可靠地比延伸思考帶來更好的效能,我們建議轉向自適應思考以獲得最智慧的回應。較舊的模型使用帶有 budget_tokens 的手動思考模式。

    您可以引導 Claude 的思考行為:

    範例提示
    After receiving tool results, carefully reflect on their quality and determine optimal next steps before proceeding. Use your thinking to plan and iterate based on this new information, and then take the best next action.

    自適應思考的觸發行為是可提示的。如果您發現模型思考的頻率超出您的預期,這在大型或複雜的系統提示中可能會發生,請添加指導來引導它:

    範例提示
    Extended thinking adds latency and should only be used when it will meaningfully improve answer quality - typically for problems that require multi-step reasoning. When in doubt, respond directly.

    如果您正在從帶有 budget_tokens 的延伸思考遷移,請替換您的思考配置並將預算控制移至 effort:

    之前(延伸思考,較舊的模型)
    client.messages.create(
        model="claude-sonnet-4-5-20250929",
        max_tokens=64000,
        thinking={"type": "enabled", "budget_tokens": 32000},
        messages=[{"role": "user", "content": "..."}],
    )
    之後(自適應思考)
    client.messages.create(
        model="claude-opus-4-6",
        max_tokens=64000,
        thinking={"type": "adaptive"},
        output_config={"effort": "high"},  # or max, medium, low
        messages=[{"role": "user", "content": "..."}],
    )

    如果您沒有使用延伸思考,則不需要任何更改。當您省略 thinking 參數時,思考預設為關閉。

    如需更多關於思考能力的資訊,請參閱延伸思考和自適應思考。

    文件建立

    Claude 的最新模型在建立簡報、動畫和視覺文件方面表現出色,具有令人印象深刻的創意天賦和強大的指令遵循能力。在大多數情況下,這些模型在第一次嘗試就能產生精緻、可用的輸出。

    為獲得文件建立的最佳結果:

    範例提示
    Create a professional presentation on [topic]. Include thoughtful design elements, visual hierarchy, and engaging animations where appropriate.

    改進的視覺能力

    Claude Opus 4.5 和 Claude Opus 4.6 與先前的 Claude 模型相比具有改進的視覺能力。它們在影像處理和資料擷取任務方面表現更好,特別是在上下文中存在多張影像時。這些改進延伸到電腦使用,模型可以更可靠地解讀螢幕截圖和 UI 元素。您也可以使用這些模型透過將影片分解為幀來分析影片。

    我們發現一種有效的技術是給 Claude 一個裁剪工具或技能來進一步提升效能。我們在影像評估中看到,當 Claude 能夠「放大」影像的相關區域時,效能持續提升。我們在這裡整理了裁剪工具的使用手冊。

    優化平行工具呼叫

    Claude 的最新模型在平行工具執行方面表現出色。這些模型會:

    • 在研究期間執行多個推測性搜尋
    • 同時讀取多個檔案以更快地建立上下文
    • 平行執行 bash 命令(這甚至可能成為系統效能的瓶頸)

    這種行為很容易引導。雖然模型在沒有提示的情況下平行工具呼叫的成功率很高,但您可以將其提升到約 100% 或調整激進程度:

    最大平行效率的範例提示
    <use_parallel_tool_calls>
    If you intend to call multiple tools and there are no dependencies between the tool calls, make all of the independent tool calls in parallel. Prioritize calling tools simultaneously whenever the actions can be done in parallel rather than sequentially. For example, when reading 3 files, run 3 tool calls in parallel to read all 3 files into context at the same time. Maximize use of parallel tool calls where possible to increase speed and efficiency. However, if some tool calls depend on previous calls to inform dependent values like the parameters, do NOT call these tools in parallel and instead call them sequentially. Never use placeholders or guess missing parameters in tool calls.
    </use_parallel_tool_calls>
    減少平行執行的範例提示
    Execute operations sequentially with brief pauses between each step to ensure stability.

    減少代理編碼中的檔案建立

    Claude 的最新模型有時可能會為測試和迭代目的建立新檔案,特別是在處理程式碼時。這種方法允許 Claude 使用檔案,特別是 python 腳本,作為「臨時草稿本」,然後再儲存最終輸出。使用臨時檔案可以改善結果,特別是對於代理編碼使用案例。

    如果您希望最小化淨新檔案建立,您可以指示 Claude 在完成後清理:

    範例提示
    If you create any temporary new files, scripts, or helper files for iteration, clean up these files by removing them at the end of the task.

    過度積極

    Claude Opus 4.5 和 Claude Opus 4.6 傾向於過度工程化,建立額外的檔案、添加不必要的抽象層,或建構未被要求的靈活性。如果您看到這種不期望的行為,請添加具體指導以保持解決方案的最小化。

    例如:

    最小化過度工程化的範例提示
    Avoid over-engineering. Only make changes that are directly requested or clearly necessary. Keep solutions simple and focused:
    
    - Scope: Don't add features, refactor code, or make "improvements" beyond what was asked. A bug fix doesn't need surrounding code cleaned up. A simple feature doesn't need extra configurability.
    
    - Documentation: Don't add docstrings, comments, or type annotations to code you didn't change. Only add comments where the logic isn't self-evident.
    
    - Defensive coding: Don't add error handling, fallbacks, or validation for scenarios that can't happen. Trust internal code and framework guarantees. Only validate at system boundaries (user input, external APIs).
    
    - Abstractions: Don't create helpers, utilities, or abstractions for one-time operations. Don't design for hypothetical future requirements. The right amount of complexity is the minimum needed for the current task.

    前端設計

    Claude Opus 4.5 和 Claude Opus 4.6 在建構複雜的、真實世界的網頁應用程式方面表現出色,具有強大的前端設計能力。然而,在沒有指導的情況下,模型可能會預設使用通用模式,產生使用者所稱的「AI 垃圾」美學。要建立獨特、有創意的前端,讓人驚喜和愉悅:

    如需改善前端設計的詳細指南,請參閱我們關於透過技能改善前端設計的部落格文章。

    以下是您可以用來鼓勵更好前端設計的系統提示片段:

    前端美學的範例提示
    <frontend_aesthetics>
    You tend to converge toward generic, "on distribution" outputs. In frontend design, this creates what users call the "AI slop" aesthetic. Avoid this: make creative, distinctive frontends that surprise and delight.
    
    Focus on:
    - Typography: Choose fonts that are beautiful, unique, and interesting. Avoid generic fonts like Arial and Inter; opt instead for distinctive choices that elevate the frontend's aesthetics.
    - Color & Theme: Commit to a cohesive aesthetic. Use CSS variables for consistency. Dominant colors with sharp accents outperform timid, evenly-distributed palettes. Draw from IDE themes and cultural aesthetics for inspiration.
    - Motion: Use animations for effects and micro-interactions. Prioritize CSS-only solutions for HTML. Use Motion library for React when available. Focus on high-impact moments: one well-orchestrated page load with staggered reveals (animation-delay) creates more delight than scattered micro-interactions.
    - Backgrounds: Create atmosphere and depth rather than defaulting to solid colors. Layer CSS gradients, use geometric patterns, or add contextual effects that match the overall aesthetic.
    
    Avoid generic AI-generated aesthetics:
    - Overused font families (Inter, Roboto, Arial, system fonts)
    - Clichéd color schemes (particularly purple gradients on white backgrounds)
    - Predictable layouts and component patterns
    - Cookie-cutter design that lacks context-specific character
    
    Interpret creatively and make unexpected choices that feel genuinely designed for the context. Vary between light and dark themes, different fonts, different aesthetics. You still tend to converge on common choices (Space Grotesk, for example) across generations. Avoid this: it is critical that you think outside the box!
    </frontend_aesthetics>

    您也可以在這裡參考完整的技能。

    避免專注於通過測試和硬編碼

    Claude 有時可能會過度專注於讓測試通過,而犧牲更通用的解決方案,或者可能使用變通方法(如輔助腳本)來進行複雜的重構,而不是直接使用標準工具。為了防止這種行為並確保穩健、可泛化的解決方案:

    範例提示
    Please write a high-quality, general-purpose solution using the standard tools available. Do not create helper scripts or workarounds to accomplish the task more efficiently. Implement a solution that works correctly for all valid inputs, not just the test cases. Do not hard-code values or create solutions that only work for specific test inputs. Instead, implement the actual logic that solves the problem generally.
    
    Focus on understanding the problem requirements and implementing the correct algorithm. Tests are there to verify correctness, not to define the solution. Provide a principled implementation that follows best practices and software design principles.
    
    If the task is unreasonable or infeasible, or if any of the tests are incorrect, please inform me rather than working around them. The solution should be robust, maintainable, and extendable.

    最小化代理編碼中的幻覺

    Claude 的最新模型較不容易產生幻覺,並基於程式碼提供更準確、有根據、智慧的答案。為了進一步鼓勵這種行為並最小化幻覺:

    範例提示
    <investigate_before_answering>
    Never speculate about code you have not opened. If the user references a specific file, you MUST read the file before answering. Make sure to investigate and read relevant files BEFORE answering questions about the codebase. Never make any claims about code before investigating unless you are certain of the correct answer - give grounded and hallucination-free answers.
    </investigate_before_answering>

    從預填回應遷移

    從 Claude Opus 4.6 開始,最後一個助手輪次的預填回應不再受支援。模型智慧和指令遵循能力已經進步到大多數預填的使用案例不再需要它。現有模型將繼續支援預填,且在對話其他位置添加助手訊息不受影響。

    以下是常見的預填場景以及如何從中遷移:

    LaTeX 輸出

    Claude Opus 4.6 預設使用 LaTeX 來處理數學表達式、方程式和技術說明。如果您偏好純文字,請在提示中添加以下指令:

    Sample prompt
    Format your response in plain text only. Do not use LaTeX, MathJax, or any markup notation such as \( \), $, or \frac{}{}. Write all math expressions using standard text characters (e.g., "/" for division, "*" for multiplication, and "^" for exponents).

    遷移注意事項

    從早期版本遷移到 Claude 4.6 模型時:

    1. 明確說明期望的行為:考慮準確描述您希望在輸出中看到的內容。

    2. 使用修飾語來構建您的指令:添加鼓勵 Claude 提高輸出品質和細節的修飾語可以幫助更好地塑造 Claude 的表現。例如,不要使用「建立一個分析儀表板」,而是使用「建立一個分析儀表板。包含盡可能多的相關功能和互動。超越基礎功能,建立一個功能完整的實作。」

    3. 明確請求特定功能:動畫和互動元素應在需要時明確請求。

    4. 更新思考配置:Claude Opus 4.6 使用自適應思考(thinking: {type: "adaptive"})而非使用 budget_tokens 的手動思考。使用努力程度參數來控制思考深度。

    5. 從預填回應遷移:從 Claude Opus 4.6 開始,最後一個助手輪次的預填回應已被棄用。請參閱從預填回應遷移以獲取替代方案的詳細指導。

    6. 調整反懶惰提示:如果您之前的提示鼓勵模型更加徹底或更積極地使用工具,請減少該指導。Claude Opus 4.6 明顯更加主動,可能會對之前模型所需的指令過度觸發。

    如需詳細的遷移步驟,請參閱遷移指南。

    Was this page helpful?

    • LaTeX 輸出