The handbook/Automation & agents
Reading settingsOfficial docs ↗

07 / Repeatable workflows

Automate the work
you already understand.

Choose where the task runs, what it can access, and how you will inspect its results.

STEP-BY-STEP HANDBOOK12 min introduction

Choose the right kind of automation

MethodRuns where?Good forNeeds your computer on?
claude -pWhere you invoke the CLIA bounded script or one-off reportYes, if run locally
/loopCurrent sessionTemporary polling or repeated checksYes for local sessions
Desktop scheduled taskYour machineRecurring work on local filesYes
Cloud routineCloud or eligible organization runnerScheduled, API, or GitHub-triggered tasksNo for Anthropic-hosted runs
GitHub ActionsA configured CI runnerRepository event workflowsNo for GitHub-hosted runners
Agent SDKYour deployed applicationCustom software using agent capabilitiesDepends on your host

Start with a bounded one-off task

Terminal
claude -p "Summarize README.md. Do not edit files." --tools "Read" --disallowedTools "mcp__*" --max-turns 3 --output-format json

This 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

Inside Claude Code
/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.

Inside Claude Code; replace [repository]
/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.

Review every attached connector

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:

Inside Claude Code
/install-github-app

Review 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.

Official references: CLI reference ↗ · Session scheduling ↗ · Cloud routines ↗ · GitHub Actions integration ↗ · Agent SDK hosting ↗

Was this chapter useful?

Report an error

Votes are shared only if you enable optional measurement in Privacy settings.

CONTINUE THE GUIDEHome server & self-hosting

Edit this example

Changes here affect this copy only. Nothing runs from this site. Closing this window discards your edits.

Search the field guide

Search all chapters and FAQ answers. Use Tab to reach a result and Enter to open it.