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 賦予角色

    While these tips apply broadly to all Claude models, you can find prompting tips specific to extended thinking models here.

    使用 Claude 時,您可以透過 system 參數為其賦予角色,從而大幅提升其表現。這種技術稱為角色提示,是使用系統提示與 Claude 互動最強大的方式。

    適當的角色可以將 Claude 從通用助手轉變為您的虛擬領域專家!

    系統提示技巧:使用 system 參數來設定 Claude 的角色。將其他所有內容(如任務特定指令)放在 user 回合中。

    為什麼要使用角色提示?

    • 提高準確性: 在法律分析或財務建模等複雜場景中,角色提示可以顯著提升 Claude 的表現。
    • 量身定制語調: 無論您需要財務長的簡潔風格還是文案撰寫者的創意風格,角色提示都能調整 Claude 的溝通方式。
    • 改善專注度: 透過設定角色背景,Claude 能更好地保持在您任務的特定需求範圍內。

    如何為 Claude 賦予角色

    在 Messages API 中使用 system 參數來設定 Claude 的角色:

    import anthropic
    
    client = anthropic.Anthropic()
    
    response = client.messages.create(
        model="claude-opus-4-6",
        max_tokens=2048,
        system="You are a seasoned data scientist at a Fortune 500 company.", # <-- role prompt
        messages=[
            {"role": "user", "content": "Analyze this dataset for anomalies: <dataset>{{DATASET}}</dataset>"}
        ]
    )
    
    print(response.content)
    角色提示技巧:嘗試不同的角色!對於相同的資料,資料科學家可能會看到與行銷策略師不同的洞察。而專精於財富 500 強企業客戶洞察分析的資料科學家可能會產生更不一樣的結果!

    範例

    範例 1:法律合約分析

    沒有角色時,Claude 可能會遺漏關鍵問題:

    有了角色後,Claude 能捕捉到可能造成數百萬損失的關鍵問題:

    範例 2:財務分析

    沒有角色時,Claude 的分析缺乏深度:

    有了角色後,Claude 能提供可執行的洞察:


    提示詞庫

    從精選的各種任務和使用案例提示詞中獲取靈感。

    GitHub 提示工程教學

    一個包含豐富範例的教學,涵蓋我們文件中的提示工程概念。

    Google Sheets 提示工程教學

    透過互動式試算表提供的輕量版提示工程教學。

    Was this page helpful?

    • 如何為 Claude 賦予角色
    • 範例 1:法律合約分析
    • 範例 2:財務分析