Skip to content
tinAI
Go back

Tự động hóa công việc với Routines trên Claude Code

Bài gốc: Automate work with routines - Claude Code Docs

Tác giả: Anthropic

Ngày đăng: Dịch ngày:

TL;DR

Claude Code ra mắt Routines — tính năng cho phép chạy tự động các tác vụ Claude Code trên hạ tầng cloud của Anthropic, trigger theo lịch, API call, hoặc sự kiện GitHub. Chạy được ngay cả khi máy tính đóng, không cần ngồi chờ.

Giới thiệu

Claude Code Routines là tính năng mới cho phép định nghĩa và chạy tự động các tác vụ trên hạ tầng cloud của Anthropic. Khác với local scripts, mỗi routine chạy trong một Claude Code session đầy đủ — có thể dùng tools, MCP connectors (Slack, Linear, Google Drive), và tương tác với GitHub repositories, kể cả khi laptop đã tắt.

Routines hiện đang ở research preview. API surface và limits có thể thay đổi.

Cấu trúc của một Routine

Mỗi routine gồm:

Các loại Trigger

Schedule

Chạy theo lịch cố định: hourly, daily, weekdays, weekly. Hỗ trợ custom cron expression qua CLI với /schedule update. Minimum interval là 1 giờ.

API

Gọi routine qua HTTP POST đến một endpoint riêng của từng routine. Request body có thể truyền context qua field text — ví dụ alert body, failing log. Response trả về session_id và URL để theo dõi run. Dùng để tích hợp vào alerting systems, deploy pipelines, hay internal tools.

GitHub Event

Trigger tự động khi có sự kiện trên repository. Hỗ trợ nhiều loại event:

EventKích hoạt khi
Pull requestPR mở, đóng, update, gán label
PushCommit được push lên branch
IssuesIssue mở, đóng, comment
Workflow runGitHub Actions workflow hoàn thành
ReleaseRelease được publish

Hỗ trợ filter theo author, base/head branch, labels, draft status.

Use Cases thực tế

Backlog maintenance — Schedule trigger chạy mỗi tối: đọc issues mới, gán labels và assignees, post summary lên Slack cho team.

Alert triage — Monitoring tool gọi API trigger khi lỗi vượt ngưỡng. Claude pull stack trace, tìm commit liên quan, tạo draft PR fix.

Code review tự động — GitHub trigger khi PR mở: Claude apply checklist review của team, để lại inline comments, post summary.

Deploy verification — CD pipeline gọi routine sau mỗi deploy: Claude chạy smoke checks, scan error logs, post go/no-go lên release channel.

Docs drift — Schedule trigger hàng tuần: scan merged PRs, flag docs tham chiếu APIs đã thay đổi, mở update PRs.

Tạo và Quản lý

Từ web: https://claude.ai/code/routines → New routine

Từ CLI: chạy /schedule hoặc /schedule daily PR review at 9am

Từ Desktop app: Schedule page → New task → New remote task

Mỗi run tạo ra một session riêng biệt — có thể xem lại toàn bộ actions của Claude, review changes, tạo PR.

Lưu ý quan trọng


Read Original (EN) Quay lại Newsletter