Claude Code Routines

Claude Code Routines allow developers to automate repetitive tasks using scheduled triggers, API endpoints, and GitHub events for a more efficient workflow.
Scheduled: run on a recurring cadence like hourly, nightly, or weeklyAPI: trigger on demand by sending an HTTP POST to a per-routine endpoint with a bearer tokenGitHub: run automatically in response to repository events such as pull requests, pushes, issues, or workflow runs
/schedule
. This page covers creating a routine, configuring each trigger type, managing runs, and how usage limits apply.
Example use cases
Each example pairs a trigger type with the kind of work routines are suited to: unattended, repeatable, and tied to a clear outcome.**Backlog maintenance.**A schedule trigger runs every weeknight against your issue tracker via a connector. The routine reads issues opened since the last run, applies labels, assigns owners based on the area of code referenced, and posts a summary to Slack so the team starts the day with a groomed queue.
**Alert triage.**Your monitoring tool calls the routine’s API endpoint when an error threshold is crossed, passing the alert body as
text
. The routine pulls the stack trace, correlates it with recent commits in the repository, and opens a draft pull request with a proposed fix and a link back to the alert. On-call reviews the PR instead of starting from a blank terminal. **Bespoke code review.**A GitHub trigger runs on
pull_request.opened
. The routine applies your team’s own review checklist, leaves inline comments for security, performance, and style issues, and adds a summary comment so human reviewers can focus on design instead of mechanical checks. **Deploy verification.**Your CD pipeline calls the routine’s API endpoint after each production deploy. The routine runs smoke checks against the new build, scans error logs for regressions, and posts a go or no-go to the release channel before the deploy window closes.
**Docs drift.**A schedule trigger runs weekly. The routine scans merged PRs since the last run, flags documentation that references changed APIs, and opens update PRs against the docs repository for an editor to review.
**Library port.**A GitHub trigger runs on
pull_request.closed
filtered to merged PRs in one SDK repository. The routine ports the change to a parallel SDK in another language and opens a matching PR, keeping the two libraries in step without a human re-implementing each change. The sections below walk through creating a routine and configuring each of these trigger types.
Create a routine
Create a routine from the web, the Desktop app, or the CLI. All three surfaces write to the same cloud account, so a routine you create in the CLI shows up at claude.ai/code/routines immediately. In the Desktop app, clickNew taskand choose
New remote task; choosing
New local taskinstead creates a local Desktop scheduled task, which runs on your machine and is not a routine. The creation form sets up the routine’s prompt, repositories, environment, connectors, and triggers. Routines run autonomously as full Claude Code cloud sessions: there is no permission-mode picker and no approval prompts during a run. The session can run shell commands, use skills committed to the cloned repository, and call any connectors you include. What a routine can reach is determined by the repositories you select and their branch-push setting, the environment’s network access and variables, and the connectors you include. Scope each of those to what the routine actually needs. Routines belong to your individual claude.ai account. They are not shared with teammates, and they count against your account’s daily run allowance. Anything a routine does through your connected GitHub identity or connectors appears as you: commits and pull requests carry your GitHub user, and Slack messages, Linear tickets, or other connector actions use your linked accounts for those services.
Create from the web
Name the routine and write the prompt
Select repositories
claude/
-prefixed branches for its changes. To allow pushes to any branch, enable Allow unrestricted branch pushesfor that repository.
Select an environment
Network access: set the level of internet access available during each runEnvironment variables: provide API keys, tokens, or other secrets Claude can useSetup script: run install commands before each session starts, like installing dependencies or configuring tools
Defaultenvironment is provided. To use a custom environment, create one before creating the routine.
Select a trigger
Select a trigger, choose how the routine starts. You can pick one trigger type or combine several.
Review connectors
Create the routine
Create. The routine appears in the list and runs the next time one of its triggers matches. To start a run immediately, click
Run nowon the routine’s detail page.Each run creates a new session alongside your other sessions, where you can see what Claude did, review changes, and create a pull request.
Create from the CLI
Run/schedule
in any session to create a scheduled routine conversationally. You can also pass a description directly, as in /schedule daily PR review at 9am
. Claude walks through the same information the web form collects, then saves the routine to your account.
/schedule
in the CLI creates scheduled routines only. To add an API or GitHub trigger, edit the routine on the web at claude.ai/code/routines.
The CLI also supports managing existing routines. Run /schedule list
to see all routines, /schedule update
to change one, or /schedule run
to trigger it immediately.
Create from the Desktop app
Open theSchedulepage in the Desktop app, click
New task, and choose
New remote task. The Desktop app shows both local scheduled tasks and routines in the same grid. See Desktop scheduled tasks for details on the local option.
Configure triggers
A routine starts when one of its triggers matches. You can attach any combination of schedule, API, and GitHub triggers to the same routine, and add or remove them at any time from theSelect a triggersection of the routine’s edit form.
Add a schedule trigger
A schedule trigger runs the routine on a recurring cadence. Pick a preset frequency in theSelect a triggersection: hourly, daily, weekdays, or weekly. Times are entered in your local zone and converted automatically, so the routine runs at that wall-clock time regardless of where the cloud infrastructure is located. Runs may start a few minutes after the scheduled time due to stagger. The offset is consistent for each routine. For a custom interval such as every two hours or the first of each month, pick the closest preset in the form, then run
/schedule update
in the CLI to set a specific cron expression. The minimum interval is one hour; expressions that run more frequently are rejected.
Add an API trigger
An API trigger gives a routine a dedicated HTTP endpoint. POSTing to the endpoint with the routine’s bearer token starts a new session and returns a session URL. Use this to wire Claude Code into alerting systems, deploy pipelines, internal tools, or anywhere you can make an authenticated HTTP request. API triggers are added to an existing routine from the web. The CLI cannot currently create or revoke tokens.Add an API trigger
Select a triggersection below the prompt, click
Add another trigger, and choose
API.
Copy the URL and generate a token
Generate tokenand copy the token immediately. The token is shown once and cannot be retrieved later, so store it somewhere secure such as your alerting tool’s secret store.
Regenerateor
Revoke.
Trigger a routine
Send a POST request to the/fire
endpoint with the bearer token in the Authorization
header. The request body accepts an optional text
field that’s appended to the routine’s configured prompt as a one-shot user turn. Use text
to pass context like an alert body or a failing log. The example below triggers a routine from a shell:
API
Source: Hacker News
















