Hypd AI automation agency logo

Hypd

AI Tools / Published June 13, 2026

3 Ways to Deploy Claude Code Agents That Run While You Sleep

Loop, scheduled tasks, and cloud deployment — three distinct approaches to running Claude Code agents on a timer or trigger without keeping a session open. When to use each one.

Last updated: June 13, 2026

claude codeagentsautomationdeploymentscheduled tasksmodaltrigger.dev
Bottom line

Loop, scheduled tasks, and cloud deployment — three distinct approaches to running Claude Code agents on a timer or trigger without keeping a session open. When to use each one.

This guide is reviewed for clarity, service accuracy, and AI-search readability. The next quarterly content review is tracked internally before unsupported metrics or client proof are added.

The deployment problem

Claude Code is powerful inside an active session. The problem is that most recurring work — monitoring comments, pulling analytics, updating spreadsheets, running pipelines — shouldn't require you to keep a terminal open.

Three deployment methods solve this. Each one trades different things: setup complexity, cost, machine dependency, and how agentic the execution loop actually is. Knowing which situation calls for which method is the whole game.

Method 1: Loop

The loop is the simplest deployment. Inside any Claude Code session, you instruct the agent to set up a recurring task using the CronCreate tool — and it runs inside your current session on an interval.

Example: "Set up a loop to check the comments on my new YouTube upload and respond to them every 10 minutes, then automatically kill the loop after 24 hours." Claude Code creates the cron, and the task fires on schedule for the duration of the session.

One important nuance: loops in the desktop app clear when you run

prompt
/clear
— that kills all crons. In the terminal,
prompt
/clear
does not kill crons. Desktop app crons expire after 3 days; terminal crons after 7.

A useful pattern: set up a second cron to run

prompt
/clear
every 5 minutes. This prevents context from accumulating across iterations and keeps each run starting clean — what's sometimes called an anti-context-rot loop.

One more thing on timing: Claude Code schedules with jitter — runs may fire up to 30 minutes after the scheduled time to avoid all sessions hitting the API simultaneously. If you need exact timing, the loop method isn't the right tool.

Pros:

  • Zero setup — just say "set up a loop" and it runs
  • Full agentic session — all your skills, files, MCPs, and sub-agents are available
  • Can run skills directly (/commands work inside loops)
  • Self-terminates after a set number of runs or time period

Cons:

  • Session must stay open — close the terminal and the loop dies
  • Machine must stay on
  • 7-day expiry in terminal, 3-day in desktop app
  • Fixed-interval timing (not exact, due to jitter)

Method 2: Scheduled tasks and cloud routines

These live inside the Claude desktop app under Routines. Two variants: local (runs on your machine) and remote (runs on Anthropic's infrastructure).

Both work by injecting a prompt into a fresh Claude Code session on a schedule. You write the instructions once — what to do, in what order, with what context — and the system fires them on your chosen cadence.

Local scheduled tasks run on your machine when the desktop app is open. If your machine was off for days and missed scheduled runs, Claude Code will catch up and run the missed tasks when you open the app. Pause tasks first if you don't want that behaviour.

Cloud routines run on Anthropic's servers regardless of whether your machine or app is open. On the Max plan, you get 15 remote runs per day. Pro gets 5. Teams and Enterprise get 25. Cloud routines also support GitHub event triggers and API webhooks — so they can fire on external events like a new git push, not just time.

One important constraint: cloud routines have a 1-hour minimum interval. For anything that needs to run more frequently, use a loop instead.

Pros:

  • Built into Claude Code desktop — no extra infrastructure
  • Full Claude Code session capabilities (skills, MCPs, sub-agents, shell access)
  • Cloud variant runs truly autonomously — machine can be off
  • Cloud routines can be triggered by API or GitHub events, not just time

Cons:

  • Local tasks require desktop app open and machine on
  • Cloud routines have a 1-hour minimum interval
  • Cloud routines capped at 5–25 runs/day depending on plan
  • Prompt scoping matters — an imprecise prompt on an autonomous agent produces imprecise (sometimes unwanted) actions

Method 3: Modal or Trigger.dev

The third method deploys a script to a third-party cloud platform — not your machine, not Anthropic's infrastructure — and runs it on a cron or webhook.

Modal is Python-based serverless: write a Python function, deploy it to Modal, and it runs in the cloud on a schedule. This feels like a script on a timer. Trigger.dev uses TypeScript and feels more agentic — tasks can be broken into multiple steps that call each other, and it supports durable workflows.

The key difference from methods 1 and 2: this is not Claude Code running your prompt. This is a script making API calls. That means the agent loop (tools, file access, bash execution, sub-agents) requires using the Claude Agent SDK, not a standard API call. A raw API call gives you the model's text response. The Agent SDK gives you the full agent loop — the same capabilities you have in a Claude Code session.

Also critical: Method 3 uses API credits, not your Claude subscription. Every token costs money at the API rate, which makes it more expensive for AI-heavy automations. Where it wins: processes that don't need AI at all, or that need to run more than 15 times per day, or that need to run independently of any Claude account or machine.

Pros:

  • Runs in the cloud with no machine, app, or session required
  • No daily run cap — scales as needed
  • Can be called as a webhook from external systems (GitHub Actions, Zapier, n8n)
  • Modal (Python) and Trigger.dev (TypeScript) both work well with Claude Code for scripting

Cons:

  • Requires API credits — not covered by Claude subscription, billed per token
  • Getting the full agent loop requires the Claude Agent SDK, not just the API
  • More setup than methods 1 and 2

The WAT framework: which method gives you what

A useful mental model — Workflow (W), Agent (A), and Tools (T):

  • Method 1 (Loop) — W + A + T. Full Claude Code session. All tools, the full agentic reasoning loop, and your custom workflow (skills). Best for tasks that need to act on dynamic context and make non-deterministic decisions.
  • Method 2 (Scheduled tasks / cloud routines) — W + A + T. Same capabilities as Method 1, but on a timer you don't have to manage. The cloud variant adds genuine autonomy (machine-off operation).
  • Method 3 (Modal / Trigger.dev, standard API) — W + T only. No agent loop unless you use the Agent SDK. Best for deterministic scripts that need to run frequently or call external webhooks.
  • Method 3 (with Agent SDK) — W + A + T. Full agent loop, but billed at API rates. Appropriate when you need the agent loop at scale beyond what Claude scheduled tasks support.

When to use each

  • Use a loop when: you need a task to run repeatedly inside an active session, you want to set it up in natural language without any config, and you're comfortable keeping the session open.
  • Use scheduled tasks (local) when: you have a regular automated workflow that needs to run on your machine while you work on other things.
  • Use cloud routines when: you need true 24/7 autonomy — the task should run even if your computer is off — and you can work within the 1-hour minimum interval and daily run cap.
  • Use Modal or Trigger.dev when: the process is deterministic enough to be a script, you need to run more than the cloud routine cap allows, or you need webhook/event-driven triggering from external systems.

Frequently asked questions

Can I run a Claude Code skill inside a scheduled task or cloud routine? Yes. Both local and remote scheduled tasks inject your prompt into a regular Claude Code session, so all your skills, custom instructions, and slash commands are available. You can reference a skill explicitly in the prompt — "run the /wins-engagement skill" — and the session will execute it the same way it would if you typed that command yourself.

What's the difference between the Claude Agent SDK and the regular Claude API? The regular API gives you the model's text response to a single message — like talking to Claude in the browser, but programmatically. The Agent SDK gives you the full Claude Code experience: tool use (bash, file edits, web search), the iterative reasoning loop, sub-agents, MCPs, skills, memory, and compaction. If your automation needs to do things (edit files, run commands, call APIs), you want the Agent SDK. If it just needs to generate text, the regular API is cheaper and simpler.

Is there a method that doesn't require paying for Claude Max? Loops and local scheduled tasks work on any Claude plan that includes Claude Code — they run inside your existing session allocation. Cloud routines and the Agent SDK have separate billing. Modal and Trigger.dev without the Agent SDK use the Anthropic API directly, which is billed per token regardless of your subscription tier. If cost is the constraint, loops and local scheduled tasks are the highest-capability, lowest-cost option.