文章摘要
Claude Code文档介绍了如何通过"routines"功能自动化工作流程。该功能属于Claude开发者平台的一部分,可帮助用户构建和部署自动化任务,与子代理、第三方集成等协同工作。文档提供了入门指南、配置说明和SDK参考等资源,方便开发者快速实现工作自动化。
文章总结
使用Claude Code自动化工作流程指南
概述
Claude Code的"Routines"功能允许用户通过预设的触发条件自动执行任务,实现工作流程自动化。该功能目前处于研究预览阶段,行为和API可能会发生变化。
核心功能
- 自动化执行:保存Claude配置(包括提示、代码库和连接器),按预设条件自动运行
- 三种触发方式:
- 定时触发:按小时/天/周等周期运行
- API触发:通过HTTP POST请求手动触发
- GitHub事件触发:响应代码库事件(如PR、推送等)
创建Routine的三种方式
网页创建:
- 访问claude.ai/code/routines
- 设置名称、提示、代码库、环境和触发器
- 可选择模型并配置连接器
CLI创建:
- 使用
/schedule命令创建定时任务 - 支持查看(
list)、更新(update)和立即运行(run)
- 使用
桌面应用创建:
- 在Schedule页面选择"New remote task"
触发配置详解
定时触发
- 支持预设频率(每小时/每天/每周等)
- 可自定义cron表达式(最小间隔1小时)
- 按用户本地时区运行
API触发
- 提供专属HTTP端点
- 需使用Bearer Token认证
- 可传递
text参数附加上下文 - 请求示例:
bash curl -X POST [端点URL] \ -H "Authorization: Bearer [token]" \ -d '{"text": "附加信息"}'
GitHub触发
- 需安装Claude GitHub应用
- 支持多种事件类型(PR、推送、问题等)
- 可设置过滤条件(作者、分支、标签等)
- 受每小时调用限制
管理功能
- 查看运行记录:可查看每次执行详情
- 编辑配置:随时修改提示、代码库等设置
- 控制状态:暂停/恢复定时任务
- 权限管理:
- 默认只能推送至
claude/前缀分支 - 可设置为无限制推送
- 默认只能推送至
使用限制
- 计入订阅用量
- 有每日执行次数限制
- 组织账户可设置超额使用
典型应用场景
- 待办事项维护:定时整理问题跟踪系统
- 警报处理:监控系统触发自动修复
- 代码审查:PR创建时自动检查
- 部署验证:CD流程后自动测试
相关资源
- 本地定时任务(
/loop) - 桌面应用定时任务
- 云环境配置
- MCP连接器
- GitHub Actions集成
该功能适用于Pro、Max、Team和Enterprise订阅用户,帮助实现重复性工作的自动化处理。
评论总结
以下是评论内容的总结:
1. 对Claude Code使用限制的担忧
- 用户质疑在Claude Code使用限制大幅减少后,这些自动化工具如何运作,是否仅适用于20x Max计划。
- "Given the alleged recent extreme reduction in Claude Code usage limits... Are they effectively only usable with a 20x Max plan?" (评论1)
- "You'd think that if they were compute-limited ... Trying to get people to use it less ..." (评论5)
2. 功能发布速度与竞争
- 用户认为Anthropic功能发布速度极快,可能试图取代OpenClaw。
- "Feature delivery rate by Anthropic is basically a fast takeoff in miniature." (评论3)
- "I wonder if Anthropic wants to just make claude a full stand-in replacement for openclaw..." (评论6)
3. 替代方案与比较
- 用户提到GitHub的Agentic Workflows作为替代方案,具有更多安全控制。
- "also take a look at Agentic Workflows... They support much of the same triggers and come with many additional security controls out of the box" (评论4)
4. 技术实现与局限性
- 用户指出这只是另一种数据注入方式,且缺乏组织级控制。
- "this is yet another way of injecting data into a prompt..." (评论7)
- "The obvious functionality that seems to be missing here is any way to organize and control these at an organization rather than individual level." (评论14)
5. 使用体验与信任问题
- 用户分享实际使用体验,但也表达对Anthropic长期信任的担忧。
- "Very useful, (when it works)." (评论20)
- "I have 0 trust in them... No trust that they won't nerf the tool/model behind the feature" (评论21)
6. 功能不完善与需求
- 用户指出功能不完善,如仅支持x8664、缺乏ARM64支持等。
- "Seems like it only supports x86
- "One gripe I have with Claude Code is that the CLI, Desktop app, and apparently the Webapp have a Venn Diagram of features." (评论22)
7. 自动化潜力与未来展望
- 用户认为这是迈向OpenClaw式AI的重要一步,但也质疑自身是否仍被需要。
- "This is massive. Arguably will be the start of the move to openclaw-style AI." (评论23)
- "Am I needed anymore?" (评论25)
8. 其他关注点
- 用户提到反垄断问题、使用条款模糊性及调试困难等。
- "did not anthropic block openclaw?" (评论9)
- "do I get my Anthropic account nuked or not?" (评论11)
- "I imagine debugging any of this would be maddening." (评论21)