Repeatable workflows
Automate the work
you already understand.
Choose where the task runs, what it can access, and how you will inspect its results.
New to scheduled work? Start with Routines for setup steps and beginner examples. The reference below covers additional automation approaches.
Choose the right kind of automation
| Method | Runs where? | Good for | Needs your computer on? |
|---|---|---|---|
claude -p | Where you invoke the CLI | A bounded script or one-off report | Yes, if run locally |
/loop | Current session | Temporary polling or repeated checks | Yes for local sessions |
| Desktop scheduled task | Your machine | Recurring work on local files | Yes |
| Cloud routine | Cloud or eligible organization runner | Scheduled, API, or GitHub-triggered tasks | No for Anthropic-hosted runs |
| GitHub Actions | A configured CI runner | Repository event workflows | No for GitHub-hosted runners |
| Agent SDK | Your deployed application | Custom software using agent capabilities | Depends on your host |
Start with a bounded one-off task
claude -p "Summarize README.md. Do not edit files." --tools "Read" --disallowedTools "mcp__*" --max-turns 3 --output-format jsonThis example limits built-in tools to reading, denies MCP tools, caps turns, and requests JSON. It is a useful starting point, not an operating-system sandbox. Existing trusted hooks and configuration still matter.
For API-billed print mode, --max-budget-usd 1.00 provides a per-run API budget. Also use account billing controls and host timeouts. Neither a turn cap nor a prompt is an account-wide spending cap.
Repeat a check during a session
/loop 10m check the current pull request CI status and summarize it. Do not change files or post comments.Ask Claude to list or cancel scheduled tasks when done. A local session must remain available. A repeated prompt can incur usage each time and is not an uptime guarantee. Do not assume closing a view or pressing Escape cancels every type of scheduled task.
Create a cloud routine
Routines are a research-preview feature on eligible Pro, Max, Team, and Enterprise accounts. Open Claude Code routines, create a routine, choose repositories and environment, define its instructions, and select a schedule or supported event trigger. Use Run now to inspect one execution.
/schedule every Friday at 8am America/Denver, summarize the last week of commits and open pull requests in [repository]. Report blockers and next actions in the session. Do not edit code, post comments, merge, deploy, or send messages.Confirm the resolved timezone, trigger, and saved schedule. CLI routine setup requires a sufficiently recent version and cloud account access. Preview limits may change.
Routines run autonomously. Current documentation says connected connectors may be included by default, and included tools can write without prompting. Remove unneeded connectors, restrict credentials, and inspect the first run. A read-only prompt alone does not remove write permissions.
Use Claude in GitHub Actions
For repository automation, authenticate the GitHub CLI, open Claude in the repository, then run:
/install-github-appReview the integration permissions, selected authentication method, secret storage, and proposed workflow PR. The official setup supports an API key or eligible subscription token. Once configured, a supported @claude mention can trigger work.
Begin with report-only behavior. Use a workflow timeout, limited tool access, minimal GitHub permissions, and restricted triggers. Keep secrets away from untrusted fork code. Review automated commits just as you would manual changes. GitHub runner charges and model usage are separate resources.
When to use the Agent SDK
The SDK is for building a custom application around agent behavior, tool access, and structured results. It is not required for normal Claude Code use. You must provide execution infrastructure, credentials, isolation, monitoring, and recovery. Hosting an SDK app does not self-host Claude’s model.
- Anthropic. (n.d.-b). Automate work with routines. Retrieved September 24, 2026, from https://code.claude.com/docs/en/routines
- Anthropic. (n.d.-g). Claude Code GitHub Actions. Retrieved September 24, 2026, from https://code.claude.com/docs/en/github-actions
- Anthropic. (n.d.-i). CLI reference. Retrieved September 24, 2026, from https://code.claude.com/docs/en/cli-reference
- Anthropic. (n.d.-y). Hosting the Agent SDK. Retrieved September 24, 2026, from https://code.claude.com/docs/en/agent-sdk/hosting
- Anthropic. (n.d.-ah). Run prompts on a schedule. Retrieved September 24, 2026, from https://code.claude.com/docs/en/scheduled-tasks
Was this chapter useful?
Report an errorVotes are shared only if you enable optional measurement in Privacy & Preferences.