在网页上安排 Claude 代码任务
Schedule tasks on the web

原始链接: https://code.claude.com/docs/en/web-scheduled-tasks

## Claude Code 定时任务:开发者自动化 Claude Code 提供定时任务来自动化重复性工作流程,即使在电脑关闭时也能运行。这些任务在 Anthropic 的基础设施上运行,所有 Claude Code 用户(Pro、Max、Team、Enterprise)均可访问。例如,拉取请求审查、CI 失败分析、文档同步和依赖性审计。 您可以通过网页界面、桌面应用程序或 CLI 使用 `/schedule` 命令来安排任务。任务需要一个明确定义的提示词、选定的仓库(可以选择无限制的分支推送),以及定义网络访问、变量和设置脚本的云环境。 提供三种调度选项:**Cloud**(可靠,无需机器)、**Desktop**(访问本地文件,需要机器)和 **/loop**(会话内快速轮询)。频率选项包括每小时、每天、工作日和每周,可通过 CLI 调整自定义计划。 每次任务运行都会创建一个新的会话进行审查,让您可以检查更改并创建拉取请求。您可以从网页、桌面应用程序或 CLI 管理任务——暂停、编辑、删除或触发立即运行。连接器可访问 Slack 和 Linear 等外部服务。

相关文章

原文
A scheduled task runs a prompt on a recurring cadence using Anthropic-managed infrastructure. Tasks keep working even when your computer is off. A few examples of recurring work you can automate:
  • Reviewing open pull requests each morning
  • Analyzing CI failures overnight and surfacing summaries
  • Syncing documentation after PRs merge
  • Running dependency audits every week
Scheduled tasks are available to all Claude Code on the web users, including Pro, Max, Team, and Enterprise.

Compare scheduling options

Claude Code offers three ways to schedule recurring work:
CloudDesktop/loop
Runs onAnthropic cloudYour machineYour machine
Requires machine onNoYesYes
Requires open sessionNoNoYes
Persistent across restartsYesYesNo (session-scoped)
Access to local filesNo (fresh clone)YesYes
MCP serversConnectors configured per taskConfig files and connectorsInherits from session
Permission promptsNo (runs autonomously)Configurable per taskInherits from session
Customizable scheduleVia /schedule in the CLIYesYes
Minimum interval1 hour1 minute1 minute

Use cloud tasks for work that should run reliably without your machine. Use Desktop tasks when you need access to local files and tools. Use /loop for quick polling during a session.

Create a scheduled task

You can create a scheduled task from three places:
  • Web: visit claude.ai/code/scheduled and click New scheduled task
  • Desktop app: open the Schedule page, click New task, and choose New remote task. See Desktop scheduled tasks for details.
  • CLI: run /schedule in any session. Claude walks you through the setup conversationally. You can also pass a description directly, like /schedule daily PR review at 9am.
The web and Desktop entry points open a form. The CLI collects the same information through a guided conversation. The steps below walk through the web interface.

Name the task and write the prompt

Give the task a descriptive name and write the prompt Claude runs each time. The prompt is the most important part: the task runs autonomously, so the prompt must be self-contained and explicit about what to do and what success looks like.The prompt input includes a model selector. Claude uses this model for each run of the task.

Select repositories

Add one or more GitHub repositories for Claude to work in. Each repository is cloned at the start of a run, starting from the default branch. Claude creates claude/-prefixed branches for its changes. To allow pushes to any branch, enable Allow unrestricted branch pushes for that repository.

Select an environment

Select a cloud environment for the task. Environments control what the cloud session has access to:
  • Network access: set the level of internet access available during each run
  • Environment variables: provide API keys, tokens, or other secrets Claude can use
  • Setup script: run install commands before each session starts, like installing dependencies or configuring tools
A Default environment is available out of the box. To use a custom environment, create one before creating the task.

Choose a schedule

Pick how often the task runs from the frequency options. The default is daily at 9:00 AM in your local time zone. Tasks may run a few minutes after their scheduled time due to stagger.If the preset options don’t fit your needs, pick the closest one and update the schedule from the CLI with /schedule update to set a specific schedule.

Review connectors

All of your connected MCP connectors are included by default. Remove any that the task doesn’t need. Connectors give Claude access to external services like Slack, Linear, or Google Drive during each run.

Create the task

Click Create. The task appears in the scheduled tasks list and runs automatically at the next scheduled time. Each run creates a new session alongside your other sessions, where you can see what Claude did, review changes, and create a pull request. To trigger a run immediately, click Run now from the task’s detail page.

Frequency options

The schedule picker offers preset frequencies that handle time zone conversion for you. Pick a time in your local zone and the task runs at that wall-clock time regardless of where the cloud infrastructure is located.

Tasks may run a few minutes after their scheduled time. The offset is consistent for each task.

FrequencyDescription
HourlyRuns every hour.
DailyRuns once per day at the time you specify. Defaults to 9:00 AM local time.
WeekdaysSame as Daily but skips Saturday and Sunday.
WeeklyRuns once per week on the day and time you specify.
For custom intervals like every 2 hours or first of each month, pick the closest preset and update the schedule from the CLI with /schedule update to set a specific schedule.

Repositories and branch permissions

Each repository you add is cloned on every run. Claude starts from the repository’s default branch unless your prompt specifies otherwise. By default, Claude can only push to branches prefixed with claude/. This prevents scheduled tasks from accidentally modifying protected or long-lived branches. To remove this restriction for a specific repository, enable Allow unrestricted branch pushes for that repository when creating or editing the task.

Connectors

Scheduled tasks can use your connected MCP connectors to read from and write to external services during each run. For example, a task that triages support requests might read from a Slack channel and create issues in Linear. When you create a task, all of your currently connected connectors are included by default. Remove any that aren’t needed to limit which tools Claude has access to during the run. You can also add connectors directly from the task form. To manage or add connectors outside of the task form, visit Settings > Connectors on claude.ai or use /schedule update in the CLI.

Environments

Each task runs in a cloud environment that controls network access, environment variables, and setup scripts. Configure environments before creating a task to give Claude access to APIs, install dependencies, or restrict network scope. See cloud environment for the full setup guide.

Manage scheduled tasks

Click a task in the Scheduled list to open its detail page. The detail page shows the task’s repositories, connectors, prompt, schedule, and a list of past runs.

View and interact with runs

Click any run to open it as a full session. From there you can see what Claude did, review changes, create a pull request, or continue the conversation. Each run session works like any other session: use the dropdown menu next to the session title to rename, archive, or delete it.

Edit and control tasks

From the task detail page you can:
  • Click Run now to start a run immediately without waiting for the next scheduled time.
  • Use the toggle in the Repeats section to pause or resume the schedule. Paused tasks keep their configuration but don’t run until you re-enable them.
  • Click the edit icon to change the name, prompt, schedule, repositories, environment, or connectors.
  • Click the delete icon to remove the task. Past sessions created by the task remain in your session list.
You can also manage tasks from the CLI with /schedule. Run /schedule list to see all tasks, /schedule update to change a task, or /schedule run to trigger one immediately.
联系我们 contact @ memedata.com