定义可重复执行的例行任务,用于处理积压工作、审查拉取请求以及响应云端事件。
- 分类产品公告
- 产品Claude Code
- 日期2026年4月14日
- 阅读时间5分钟
- https://claude.com/blog/introducing-routines-in-claude-code
今天,我们在研究预览版中推出 Claude Code 的例行任务功能。例行任务是一种 Claude Code 自动化机制,您只需配置一次(包括提示词、代码仓库和连接器),即可按计划、通过 API 调用或响应事件来运行。例行任务在 Claude Code 的网页基础设施上运行,因此无需依赖您的笔记本电脑保持开机状态。
开发者已经在使用 Claude Code 来自动化软件开发周期,但在此之前,他们需要自行管理 cron 任务、基础设施以及 MCP 服务器等额外工具。例行任务自带对您的代码仓库和连接器的访问权限,因此您可以打包自动化流程,并设置它们按计划运行或通过触发器启动。
工作原理
计划例行任务
为 Claude Code 提供一个提示词和一个执行频率(每小时、每晚或每周),它就会按该计划运行:
Every night at 2am: pull the top bug from Linear, attempt a fix, and open a draft PR. 如果您在 CLI 中使用 `/schedule`,这些任务现在就是计划例行任务。
API 例行任务
您也可以配置通过 API 调用触发的例行任务。每个例行任务都有自己专属的端点和身份验证 token。发送一条 POST 消息,即可获取一个会话 URL。将 Claude Code 接入您的告警系统、部署钩子、内部工具——任何可以发起 HTTP 请求的地方:
Read the alert payload, find the owning service, and post a triage summary to #oncall with a proposed first step. 如果您是在 Claude 平台上构建云托管智能体,而非自动化 Claude Code,那么 Claude Managed Agents 中的计划部署功能也能让您自己的智能体实现同样的按计划运行行为。
Webhook 例行任务,从 GitHub 开始
Please flag PRs that touch the /auth-provider module. Any changes to this module need to be summarized and posted to #auth-changes. Claude 会为每个拉取请求打开一个会话,并持续将来自该拉取请求的更新馈送给会话,以便处理评论和 CI 失败等后续事项。
我们计划在未来将基于 webhook 的例行任务扩展到更多事件源进行触发。
团队正在构建的内容
早期使用例行任务的用户已经涌现出几种常见模式:
计划例行任务
- 积压工作管理:每晚对新增 issue 进行分类、打标签、分配负责人,并将摘要发布到 Slack
- 文档漂移检测:每周扫描已合并的拉取请求,标记那些引用了已变更 API 的文档,并创建更新拉取请求
API 例行任务
- 部署验证:每次部署后,你的 CI/CD 管道会自动发布通知,Claude 会对新构建版本执行冒烟测试,扫描错误日志以检查是否存在回归问题,并在发布频道中给出“通过/不通过”的结论。
- 告警分类:将 Datadog 指向该自动化流程的端点,Claude 会拉取追踪信息,将其与最近的部署进行关联,并在值班人员打开页面之前,就准备好一份修复草案。
- 反馈处理:文档反馈组件或内部仪表盘提交报告后,Claude 会在上下文中带着该问题打开仓库会话,并起草修改方案。
GitHub 自动化流程
- 库移植:每当有 PR 合并到 Python SDK 时,会触发一个自动化流程,将该变更移植到对应的 Go SDK,并创建一个匹配的 PR。
- 定制化代码审查:当 PR 被创建时,在人工审查员查看之前,先运行你团队自己的安全与性能检查清单,并在代码中留下内联评论。
快速入门
自动化流程功能现已面向 Pro、Max、Team 和 Enterprise 套餐的 Claude Code 用户开放,需在网页端启用 Claude Code。请访问 claude.ai/code 创建你的第一个自动化流程,或在 CLI 中输入 /schedule。
自动化流程会像交互式会话一样消耗订阅使用额度。此外,自动化流程还有每日限制:Pro 用户每天最多可运行 5 个流程,Max 用户每天最多可运行 15 个流程,Team 和 Enterprise 用户每天最多可运行 25 个流程。超出这些限制后,你可以通过额外使用额度来运行更多流程。详情请参阅文档。
用 Claude 改变你组织的运作方式
Define repeatable routines that work your backlog, review your PRs, and respond to events in the cloud.
- Category
- ProductClaude Code
- DateApril 14, 2026
- Reading time5min
- https://claude.com/blog/introducing-routines-in-claude-code
Today, we're introducing routines in Claude Code in research preview. A routine is a Claude Code automation you configure once — including a prompt, repo, and connectors — and then run on a schedule, from an API call, or in response to an event. Routines run on Claude Code’s web infrastructure, so nothing depends on your laptop being open.
Developers already use Claude Code to automate the software development cycle, but until now, they've managed cron jobs, infrastructure, and additional tooling like MCP servers themselves. Routines ship with access to your repos and your connectors, so you can package up automations and set them to run on a schedule or trigger.
How it works
Scheduled routines
Give Claude Code a prompt and a cadence (hourly, nightly, or weekly) and it runs on that schedule:
Every night at 2am: pull the top bug from Linear, attempt a fix, and open a draft PR. If you're using /schedule in the CLI, those tasks are now scheduled routines.
API routines
You can also configure routines to be triggered by API calls. Every routine gets its own endpoint and auth token. POST a message, get back a session URL. Wire Claude Code into your alerting, your deploy hooks, your internal tools—anywhere you can make an HTTP request:
Read the alert payload, find the owning service, and post a triage summary to #oncall with a proposed first step. If you're building cloud-hosted agents on the Claude Platform rather than automating Claude Code, scheduled deployments in Claude Managed Agents give your own agents the same run-on-a-schedule behavior.
Webhook routines, starting with GitHub
Please flag PRs that touch the /auth-provider module. Any changes to this module need to be summarized and posted to #auth-changes. Claude opens one session per PR and will continue to feed updates from that PR to the session, so it can address follow-ups like comments and CI failures.
We plan to expand webhook-based routines to trigger from more event sources in the future.
What teams are building
A few common patterns have emerged for early users creating routines:
Scheduled routines
- Backlog management: triage new issues nightly, label, assign, and post a summary to Slack
- Docs drift: scan merged PRs weekly, flag docs that reference changed APIs, and open update PRs
API routines
- Deploy verification: your CD pipeline posts after each deploy, Claude runs smoke checks against the new build, scans error logs for regressions, and posts a go/no-go to the release channel
- Alert triage: point Datadog at the routine's endpoint, Claude pulls the trace, correlates it with recent deployments, and has a draft fix waiting before on-call opens the page
- Feedback resolution: a docs feedback widget or internal dashboard posts the report, Claude opens a session against the repo with the issue in context, and drafts the change
GitHub routines
- Library port: every PR merged to a Python SDK triggers a routine that ports the change to the parallel Go SDK, and opens a matching PR
- Bespoke code review: on PR opened, run your team's own checklist across security and performance, leaving inline comments before a human reviewer looks
Getting started
Routines are available today for Claude Code users on Pro, Max, Team, and Enterprise plans with Claude Code on the web enabled. Head to claude.ai/code to create your first routine, or type /schedule in the CLI.
Routines draw down subscription usage limits in the same way as interactive sessions. In addition, routines have daily limits: Pro users can run up to 5 routines per day, Max users can run up to 15 routines per day, and Team and Enterprise users can run up to 25 routines per day. You can run extra routines beyond these limits with extra usage. See the docs for more information.