Claude Code Routines: Cloud Tasks on Schedule, API, or Events
Routines run Claude Code tasks in the cloud independently of your local machine—schedule daily at 9am, trigger via API, or on GitHub events. Max 15 runs/24h.
Cloud Execution Frees Claude Code from Local Sessions
Routines execute Claude Code prompts on Anthropic's web infrastructure, eliminating dependency on open terminals, active sessions, or powered-on laptops. Define tasks via natural language prompts specifying actions like API calls or file generation. Outputs commit directly to a linked GitHub repo, ensuring persistence without manual intervention. This replaces brittle session loops or costly hosted web apps, ideal for daily automations like data scraping or analysis without API fees.
Triggers include:
- Scheduled: Cron-like, e.g., run at 8:00 a.m. daily using Sonnet 4.6 (no need for Opus).
- API: On-demand calls, limited setup via web UI at claude.ai/code/routines.
- Event-based: Respond to GitHub events (e.g., repo changes), configured only via web UI with supported events listed in docs.
Requirements: Link a GitHub repo (install Claude GitHub App for webhooks), connect GitHub integration in claude.ai settings, and select a cloud environment (auto-set on Ultra plan). Use /schedule in CLI or desktop app's "Scheduled > New Remote Task" for setup.
Prompt Structure Drives Reliable Outputs
Craft prompts to include task name, target repo URL, environment (default works), trigger details, and instructions. Example prompt: "Name: GitHub Trending AI Repos. Repo: URL. Environment: default. Schedule: daily at 8am. Prompt: Call GitHub search API for top 10 AI repos last 7 days and top 5 last 30 days; filter relevance; output Markdown with editor's take."
Claude Code generates these prompts reliably if asked. Monitor runs via real-time links; reauthorize GitHub in settings if access fails. Results appear as commits, e.g., Markdown files with summaries, lists, and analysis.
Demo Delivers Actionable Daily Insights
In the example, a routine scrapes GitHub for top 10 AI repos (last week) and top 5 (last month), adds relevance checks and an "editor's take" summary. Output Markdown includes:
- Upfront trends overview.
- Ranked lists with links.
- Analysis beyond raw data.
This offloads manual API scripts (e.g., Windows-based), runs daily at 8 a.m., and enhances value with AI reasoning. Test immediately post-setup to verify. For API/event triggers, check docs for exact flows—CLI handles schedules, web UI for others.
Scale Limits Favor Personal Use Cases
Max plan caps at 15 runs/24 hours—suits individual tasks, not high-volume like N8N workflows. Avoid for hundreds of daily automations; use for "set-it-and-forget-it" needs like morning reports. Everyone has repeatable tasks (e.g., repo monitoring) now automatable without infrastructure hassle, transforming Claude Code into a persistent agent.