Claude Routines: 24/7 Cloud Agents from GitHub Repos
Claude Code Routines run scheduled prompts autonomously on Anthropic's cloud using your GitHub repo and cloud env vars for API keys—no laptop needed. Min 1hr interval, Pro:5 runs/day, Max:15, with agentic self-correction intact.
Configure Routines for One-Shot Autonomous Execution
Routines execute a single prompt on Anthropic's cloud infrastructure, triggered by schedules (min 1-hour intervals: hourly, daily, weekdays), API calls, or GitHub events like PRs/pushes. Link to a GitHub repo containing claude.md instructions, scripts, and skills—Claude clones it fresh per run, executes, then deletes. Store API keys in cloud environment variables (e.g., YouTube API key as process.env.YOUTUBE_API_KEY), not .env (gitignored), and explicitly prompt Claude to use env vars: "My YouTube API key is available as an environment variable. Use it directly from the environment. Don't look for a .env." Select model, connectors (OAuth for Slack/Gmail), and permissions (full for unvetted domains like ClickUp; trusted limits to Anthropic-approved services to block malicious outbound requests). Test via "Run Now" to watch real-time, interrupt, or continue—ensures one-shot success without human input.
Each run uses 4 vCPUs, 16GB RAM, 30GB disk; optimize by using minimal repos to avoid context bloat draining session limits (same as interactive Claude Code). Setup scripts run pre-launch for package installs.
Overcome Key Gotchas for Migration
Local scheduled tasks fail remotely without fixes: no local files/cookies (stateless, no browser persistence like Playwright sessions), so adapt to API endpoints with keys/headers. Browser automations need public APIs or cookie-based auth per run. Migrate by copying prompts, adding env instructions, and switching access to "full" for blocked services—e.g., ClickUp messaging succeeded only on full, failed on trusted. Failed YouTube comment analysis (fetch 50 recent, bullet summary) until prompt specified env usage. Stateless runs destroy env post-execution unless code changes create GitHub branches; history persists for debugging failures.
Trade-offs vs Local Tasks and Agentic Advantages
Routines excel over desktop tasks (/loop) by running machine-off, surviving restarts, but lack local file access, need 1hr min interval (vs 1min local), and cap runs (Pro:5/day, Max:15, Team/Enterprise:25; metered overage possible). Fully autonomous (no permission prompts), but GitHub-only context limits massive projects—use dedicated repos per routine. Security: Runs as you, so test thoroughly; full access risks prompt injection exfiltrating data (low for private repos). Preserves full agentic WAT framework (Workflows, Agents, Tools): Claude self-corrects errors, reads claude.md for context, leaves memory trails across stateless runs via outputs/Slack notifications on failure. Beats script-only cloud deploys by retaining reasoning/self-healing, enabling true 24/7 agents without hardware.