Claude Routines: Serverless AI Automations That Self-Heal
Claude Routines run stateless AI agents on Anthropic servers via prompts, GitHub repos, and triggers like schedules, APIs, or GitHub events—replacing brittle scripts with reasoning that self-corrects errors.
Routines Deliver Cloud-Based, Stateless AI Execution
Claude Routines automate tasks on Anthropic's servers without needing your local hardware, terminal, or laptop running. Define a routine with a prompt, one or more GitHub repos (cloned fresh each run), environment variables for API keys (no .env files—explicitly instruct Claude to use env vars), and connectors like Slack, Linear, Gmail, Google Calendar, or ClickUp. All MCP integrations are included by default; remove unneeded ones. Each run is stateless: clones repo, executes, tears down—no persistent cookies, files, or memory. Actions run as your account (e.g., GitHub commits from your user, Slack messages from you). Access via web (claude.ai/code/routines), desktop app, or CLI (/schedule, but CLI limited to schedules). Use Sonnet for most tasks, Opus for heavy reasoning. Network access defaults to trusted Anthropic domains; switch to full or custom allowlists for others. Resources per run: 4 vCPUs, 16GB RAM, 30GB disk—avoid massive monorepos for simple tasks.
Stackable Triggers for Flexible Automation
Fire routines via three stackable triggers on the same config:
- Schedules: Hourly minimum (local timezone), presets like daily/weekly; use CLI cron for custom (e.g., every 2 hours). No sub-hourly.
- API: POST to unique HTTP endpoint with bearer token; append text payload to prompt (e.g., error alerts trigger deploys). Returns session ID/URL to watch live.
- GitHub Events: PRs, pushes, issues; filter by author/branch. Requires Claude GitHub app installed on repo (flagged if missing).
Example: Morning lead triage—daily at 7am, checks new form submissions via API key env var, drafts responses, posts to Slack. Test with 'Run Now' before scheduling; view full logs (green=success) with tool calls/decisions.
Superior to Scripts: Reasoning Enables Self-Healing
Unlike Python cron scripts that fail rigidly, Routines use full Claude Code agent—reads claude.md/skills, reasons through issues, self-heals (e.g., retries alternate approaches). Ideal for speed-to-lead, client reporting, pipeline cleanup, inbound triage, document processing: Handle repetitive morning tasks pre-team wakeup, freeing humans for high-value work. Availability: Pro (5 runs/day), Max (15), Team/Enterprise (25+ with overage). Shares token pool with interactive sessions. Don't migrate everything—use local tasks for stateful needs (browser/cookies/files), /loop for minute-interval recurring checks in one session.
5 Tips to Launch Reliable Routines
- Test First: Always 'Run Now' pre-schedule.
- Failure Fallback: Prompt: 'If step fails, Slack/text what went wrong'—avoids manual log checks.
- Lean Repos: One per routine; trim irrelevant claude.md context to save tokens.
- Setup Scripts: Pre-run env scripts install packages/CLIs (e.g., Python libs)—Claude skips figuring it out.
- Migrate Workflows: Paste N8N/make.com/Zapier JSON into Claude Code for instant routine prompt conversion—no rewrite.