Claude Code推出routines研究預覽版,實現自動化排程、API呼叫與GitHub事件觸發
AI 語音朗讀 · Edge TTS
Claude Code推出routines研究預覽版,實現自動化排程、API呼叫與GitHub事件觸發。
Claude Code的routines功能現進入研究預覽階段,讓使用者一次設定提示詞、程式庫與連接器,即可在Anthropic雲端基礎設施上自動執行,不需保持筆電開啟。該功能適用Pro、Max、Team與Enterprise付費方案,並已整合原有CLI的/schedule命令,無需遷移。
routines核心定義
Routines為保存的Claude Code配置,包含提示詞、一或多個程式庫,以及連接器集合,封裝後自動運行於Anthropic管理的雲端基礎設施。即使筆電關閉,routines仍持續運作,每個routine擁有專屬API端點,便於警報、部署鉤子或內部工具直接指向Claude。
觸發機制多樣
單一routine可結合多種觸發器,涵蓋排程、API與GitHub事件,例如PR審核routine可夜間運行、由部署腳本觸發,並回應每個新PR。
- 排程觸發:以小時、天、平日或週期運行,使用者本地時區設定自動轉換。
- API觸發:透過HTTP POST至專屬/fire端點,使用bearer token啟動,請求主體可傳遞額外文字如警報內容,返回session URL。
- GitHub觸發:回應程式庫事件如pull_request.opened或releases,每事件獨立啟動session,未來將新增更多事件來源。
實際使用案例
文件詳列多項無人值守、可重複且目標明確的案例,強調routines處理重複性任務,讓人類專注高階決策。
- 待辦清單維護:每週夜間透過連接器掃描問題追蹤器,新開issue自動標籤、指派擁有者,並發Slack摘要,讓團隊每日以整理好的佇列開始工作。
- 警報分類:監控工具達錯誤門檻時呼叫API端點,routine拉取堆疊追蹤、關聯近期commit,並開啟含修復提案的draft PR,on-call僅審PR而非從空白終端機開始。
- 客製程式碼審核:pull_request.opened觸發,套用團隊審核清單,留下安全、效能與風格問題的內嵌註解,並加總結註解,讓人工審核者聚焦設計而非機械檢查。
- 部署驗證:生產部署後CD管道呼叫API,執行煙霧測試、掃描錯誤日誌,並在釋出版本關閉前於頻道發go/no-go訊息。
- 文件漂移偵測:每週排程掃描合併PR,標記引用變更API的文件,並對文件程式庫開啟更新PR供編輯審核。
- 函式庫移植:一SDK程式庫合併PR觸發,將變更移植至平行語言SDK並開啟對應PR,避免人工重實作。
建立routines步驟
routines可從網頁、Desktop app或CLI建立,三種方式皆寫入相同雲端帳戶,CLI建立者立即出現在claude.ai/code/routines。Desktop app的New remote task為routines,New local task則為本地排程,不屬routines。
- 網頁建立:至claude.ai/code/routines點New routine,命名並撰寫自足提示詞(強調明確步驟與成功標準),選GitHub程式庫(預設clone default branch,啟用Allow unrestricted branch pushes以允許任意分支推送)、雲端環境、觸發器與連接器,點Create即啟用。
- CLI建立:於任一session執行/schedule,或直接傳描述如/schedule daily PR review at 9am,Claude引導收集資訊後儲存。
- Desktop app建立:開啟Schedule頁,選New remote task,顯示於同一清單。
運行與權限設定
Routines作為完整Claude Code雲端session自主運行,無權限選擇器或批准提示,可執行shell命令、使用程式庫內skills,並呼叫指定連接器。存取範圍由選定程式庫的分支推送設定、環境的網路與變數、連接器決定,使用者須嚴格範圍化以限必要權限。所有動作以使用者GitHub身份或連結帳戶呈現,如commit、PR與Slack訊息。
管理與監控
於claude.ai/code/routines清單點擊routine開啟細節頁,檢視程式庫、連接器、提示詞、排程、API token、GitHub觸發與過去運行記錄。可隨時於edit form的Select a trigger區新增/移除觸發器。
使用限制與注意
Routines消耗訂閱額度如同互動session,另有每日運行上限,於claude.ai/code/routines或claude.ai/settings/usage查看剩餘額度。研究預覽階段,行為、限制與API表面可能變更;屬個人claude.ai帳戶,不共享隊友,且計入個人每日運行配額。文件連結:http://code.claude.com/docs/en/routines;更多資訊:https://claude.com/product/claude-code#updates。
此功能將Claude Code從互動工具轉為自動化骨幹,特別適合DevOps與維護任務,但預覽版提醒使用者注意潛在變動與配額管理,忠實反映Anthropic的雲端自主定位,避免本地依賴。
Now in research preview: routines in Claude Code.
— Claude (@claudeai) April 14, 2026
Configure a routine once (a prompt, a repo, and your connectors), and it can run on a schedule, from an API call, or in response to an event.
Routines run on our web infrastructure, so you don't have to keep your laptop open. pic.twitter.com/m2XJWYqkf8
Routines each come with their own API endpoint, so you can point your alerts, deploy hooks, or internal tools at Claude directly. Try sending Claude an alert payload and asking it to find the owning service and post a triage summary to #oncall.
— Claude (@claudeai) April 14, 2026
POST a message and get back a…
Webhook routines subscribe to GitHub events and let Claude respond as they come in. Try pointing one at your repo and asking Claude to flag any PR that touches /auth-provider and post a summary in #auth-changes.
— Claude (@claudeai) April 14, 2026
More event sources are coming soon.
Scheduled routines let you give Claude a cadence and walk away. Try telling Claude to pull the top bug from Linear every night at 2am, attempt a fix, and open a draft PR.
— Claude (@claudeai) April 14, 2026
If you've been using /schedule in the CLI, those are routines now, and there's nothing to migrate.
Available today across all paid plans, with Claude Code on the web enabled.
— Claude (@claudeai) April 14, 2026
Docs: https://t.co/TdOiIxRhKe
Read more: https://t.co/4M6Rl70dqK
