Claude Code Routines: How to Run Scheduled AI Agents Without a Server
Claude Code's new Routines feature lets you schedule cloud-based AI tasks without keeping your laptop open. Here's how to set them up.
What Claude Code Routines Actually Are
Most AI coding tools work the same way: you open a session, give it a task, and wait. When your session ends, the work stops. That’s fine for one-off tasks. It breaks down the moment you want something to happen on a schedule — every morning, every hour, every time a condition is met.
Claude Code Routines are Anthropic’s answer to that problem. They let you define scheduled AI agent tasks that run in the cloud, completely independent of whether your laptop is on, your terminal is open, or you’re even awake. You set the schedule once. The agent runs on Anthropic’s infrastructure. You get results.
This article explains how Routines work, how to set them up step by step, what you can actually do with them, and where they fit (and don’t fit) in a broader automation stack.
The Problem Routines Solve
Before Routines, running a recurring Claude Code task meant keeping a machine running. Some people used GitHub Actions cron jobs to trigger Claude Code in headless mode. Others ran a Mac Mini in a closet. Others used tools like Trigger.dev to orchestrate the scheduling layer themselves.
All of these work, but they come with overhead. You’re managing infrastructure. You’re paying for compute you might not need. You’re debugging deployment environments that have nothing to do with the actual AI task.
Running a Claude Code agent 24/7 without dedicated hardware was genuinely annoying to set up before Routines existed. The solutions were either expensive (dedicated server), fragile (cron job on your laptop), or required significant DevOps work (containerized deployments).
Routines remove that entire layer. You define a task, set a schedule, and Anthropic’s cloud handles execution. No server to maintain. No cron jobs to babysit.
How Claude Code Routines Work
The Core Concept
A Routine is a named, scheduled invocation of Claude Code. It runs in Anthropic’s managed cloud environment, with access to your configured tools, credentials, and permissions. The key components are:
- A task definition — what you want the agent to do, written as a natural language prompt or structured instruction set
- A schedule — when to run it (cron-style or interval-based)
- A permission set — what tools and resources the agent has access to
- An output destination — where results go (a file, a webhook, an email, etc.)
When the scheduled time hits, Anthropic spins up an execution environment, runs your Claude Code agent against the task definition, and delivers the output to wherever you pointed it.
Cloud Execution Model
This is the important part: the agent doesn’t run on your machine. It runs on Anthropic’s infrastructure. That means:
- Your laptop can be off
- Your internet connection doesn’t matter at execution time
- You’re not paying for idle compute between runs
- Anthropic handles scaling, retries, and environment consistency
The model is similar to how serverless functions work — you define the logic, the platform handles when and where it runs. The difference is that instead of writing a function, you’re writing an agent task in natural language.
This is also what distinguishes Routines from Claude Code’s /loop command, which repeats tasks within an active session but stops the moment you close the terminal.
Tool Access in Routines
Routines can use any tools you’ve configured in Claude Code: file system access, web search, shell commands, API calls. The tool permissions are defined per-routine, so you can scope each scheduled task to exactly what it needs.
For security-sensitive tasks — anything touching production systems, financial data, or external APIs with write access — you’ll want to be deliberate about what permissions you grant. Narrower is better.
How to Set Up a Claude Code Routine
Prerequisites
Before you create a Routine, you need:
- Claude Code installed and configured (Max plan or above — Routines are not available on the free tier)
- Any credentials or API keys your task will need, stored in Claude Code’s credential vault
- A clear task definition: what should the agent do, and what does “done” look like?
Step 1: Define the Task
Start with a clear, specific task prompt. Vague prompts produce vague results — this matters even more for scheduled tasks because there’s no one watching to course-correct.
A good Routine task definition includes:
- What to do (the action)
- What to look at (the inputs or data sources)
- What to produce (the output format)
- What to do with the output (where to send it)
Example of a weak task definition:
“Check my GitHub repos and tell me what’s happening.”
Example of a strong task definition:
“Check all open pull requests in the repos listed in repos.txt. For any PR that has been open more than 3 days with no activity, post a comment asking the author for a status update. Output a summary of PRs reviewed and comments posted to /logs/pr-summary-{date}.md.”
The more specific you are, the more reliably the agent will do what you actually want.
Step 2: Create the Routine
In Claude Code, open the Routines panel. Select “New Routine” and configure:
- Name — something descriptive (e.g., “Daily PR staleness check”)
- Task prompt — paste your task definition
- Schedule — choose from presets (daily, weekly, hourly) or enter a cron expression for precise control
- Tools — select which tools this routine can use
- Credentials — attach any stored credentials needed for API access
- Output — configure where results go
Step 3: Test Before Scheduling
Run the Routine manually before activating the schedule. This catches prompt issues, permission problems, and output format mismatches before they become recurring failures.
Use the “Run Now” option to trigger a single execution. Review the output carefully. If it’s not what you expected, refine the task definition and test again.
Step 4: Activate the Schedule
Once you’re satisfied with the output, toggle the Routine to active. The scheduler takes over from there.
You can monitor execution history, view logs for each run, and pause or modify the Routine at any time from the Routines panel.
Practical Use Cases
Daily Monitoring and Reporting
This is the most common entry point. You set up a Routine that runs every morning and produces a report: open issues, flagged errors, pending tasks, status summaries.
Examples:
- Scan error logs and produce a digest of new error types
- Check competitor pricing pages and note changes
- Pull metrics from an API and summarize trends
For something like a daily AI news briefing, a Routine is a clean fit — define the sources, the format, the output location, and let it run every morning while you’re still asleep.
Code Quality and Maintenance
Routines work well for recurring code health checks that don’t need to block the main development workflow:
- Run static analysis on new commits and post results to a Slack channel
- Check for outdated dependencies and open a PR with proposed updates
- Scan for TODO/FIXME comments added in the last week and add them to a task tracker
These are exactly the kinds of tasks that always feel important but never feel urgent enough to do manually. Automating them with a Routine means they actually happen.
Data Collection and Processing
If your work involves regularly pulling data from external sources, Routines can handle the collection layer:
- Scrape structured data from a set of URLs on a schedule
- Pull records from an API and append them to a local dataset
- Monitor a feed and extract items matching specific criteria
You can pair this with scheduled browser automation for tasks that require actual browser interaction — form fills, authenticated scraping, UI-driven workflows.
Multi-Agent Coordination
Routines can also be used to trigger sub-agents or coordinate across multiple Claude Code instances. One Routine might run a research task and write its output to a shared location. Another Routine, scheduled slightly later, might pick up that output and process it further.
This is a simple form of multi-agent workflow that doesn’t require a dedicated orchestration layer. It’s not sophisticated — you’re essentially using the file system or a shared API as a message bus — but it works for a lot of practical cases.
Scheduling Options and Cron Syntax
Preset Schedules
Claude Code Routines offer a set of preset schedules for common intervals:
| Preset | Runs |
|---|---|
| Every hour | At the top of each hour |
| Daily | Once per day (you set the time) |
| Weekly | Once per week (you set the day and time) |
| Weekdays only | Monday–Friday at a set time |
| Monthly | Once per month on a set date |
Custom Cron Expressions
For precise control, you can enter a standard cron expression. The format is:
minute hour day-of-month month day-of-week
Examples:
0 9 * * 1-5— 9:00 AM every weekday*/30 * * * *— every 30 minutes0 8,17 * * *— 8:00 AM and 5:00 PM daily0 0 1 * *— midnight on the first day of each month
If you’re not familiar with cron syntax, tools like crontab.guru (an authoritative cron expression editor) can help you build and test expressions before using them.
Timezone Handling
Routines run in UTC by default. If your schedule needs to align with a specific timezone — say, “run at 9 AM Eastern” — you’ll need to convert to UTC when setting the cron expression. This is easy to forget and easy to get wrong, so double-check your timing when you first activate a Routine.
What Routines Can and Can’t Do
What They’re Good At
- Tasks that repeat on a fixed schedule
- Tasks that take minutes, not seconds (the overhead of spinning up an agent environment isn’t worth it for sub-second tasks)
- Tasks with clear, deterministic outputs
- Tasks that don’t need real-time interaction with a human
Where They Fall Short
Routines aren’t designed for event-driven workflows — things that should trigger when something happens rather than when the clock hits a certain time. For that, you need a proper event-driven architecture, which might involve webhooks, tools like Trigger.dev, or Anthropic’s broader managed agents infrastructure.
They’re also not the right fit for very high-frequency tasks. If you need something running every minute or continuously polling a resource, you’re looking at a different architecture — closer to what the Agentic OS heartbeat pattern addresses.
And Routines don’t handle complex multi-step workflows with branching logic particularly well on their own. You can write a task prompt that includes conditional logic, but once the complexity grows beyond a certain point, you’re better off with a proper orchestration layer.
If you’re deciding between Routines and a more full-featured platform, the Claude Code Routines vs n8n comparison breaks down the tradeoffs in detail.
Routines vs. Other Scheduling Approaches
vs. GitHub Actions
GitHub Actions with a cron schedule is a legitimate way to run recurring AI tasks. You define a workflow YAML file, set a cron trigger, and GitHub handles execution. The advantage is that it’s free for public repos and cheap for private ones, and it integrates naturally with your codebase.
The disadvantage is that it requires more setup. You’re writing workflow YAML, managing secrets in GitHub, and dealing with Actions-specific quirks. For a developer who already lives in GitHub, that overhead is minimal. For someone who just wants a scheduled AI task without touching infrastructure, it’s more than necessary.
Routines are simpler to set up if you’re already using Claude Code. GitHub Actions give you more control and lower cost if you’re comfortable with the tooling.
vs. Trigger.dev
Trigger.dev is purpose-built for scheduled and event-driven background jobs. It handles retries, fan-out, long-running tasks, and complex orchestration that Routines don’t support. If you’re building an AI news digest agent or anything that needs reliable job queuing and error handling, Trigger.dev is worth looking at.
The tradeoff: Trigger.dev requires you to write code. You define your jobs in TypeScript. That’s powerful but it’s a higher bar than defining a task prompt in plain language.
vs. n8n or Zapier
These platforms excel at connecting services together through a visual workflow builder. If your scheduled task is primarily about moving data between services — “every morning, pull from this API and write to that spreadsheet” — n8n or Zapier might be the cleaner choice.
They’re less suited for tasks that require reasoning, analysis, or generating structured content. That’s where Claude Code Routines have an edge.
Monitoring and Debugging Routines
Execution Logs
Every Routine run produces a log that includes:
- Start and end time
- Tools called and their outputs
- The final response from the agent
- Any errors encountered
Review logs regularly, especially in the first week after activating a new Routine. Edge cases you didn’t anticipate in your task definition will show up quickly.
Handling Failures
Routines can fail. The agent might encounter an API that’s temporarily down, a file that doesn’t exist yet, or a permission error it can’t resolve. Claude Code will log the failure and move on to the next scheduled run.
You can configure failure notifications to get alerted when a Routine errors out. For critical tasks, this is worth setting up so you’re not discovering a failure three days later.
Iterating on Task Definitions
Your first task definition probably won’t be perfect. Expect to refine it based on what you see in the logs. Common issues:
- Output format doesn’t match what you expected (add format instructions to the prompt)
- Agent takes an action you didn’t intend (add explicit constraints)
- Agent skips steps because they seemed unnecessary (add explicit instructions for each step)
- Agent can’t find a resource (check file paths and API endpoints)
This iteration loop is normal. Most Routines stabilize after two or three refinement passes.
How Remy Fits This Picture
Routines solve the scheduling problem for Claude Code users. But there’s a higher-level question underneath: what happens when the task you’re scheduling is complex enough to need its own application?
Fetching data and writing a markdown file is a task. Building a system that fetches data, processes it, stores it in a database, surfaces it through a dashboard, and triggers different actions based on what it finds — that’s an application.
That’s where Remy comes in.
Remy compiles annotated markdown specs into full-stack applications: real backends, SQL databases, auth, deployment. Instead of stringing together a Claude Code Routine, a file system, a manual processing step, and a spreadsheet, you describe the whole system in a spec and Remy builds it.
The practical difference: Routines are good for “do this task on a schedule.” Remy is good for “build the system that handles this class of problem permanently.” If you find yourself stacking Routines together to approximate an application, that’s a signal you might want a proper spec-driven build instead.
You can try Remy at mindstudio.ai/remy.
FAQ
What plan do I need to use Claude Code Routines?
Routines are available on the Claude Max plan and above. They’re not included in the free tier or standard Claude.ai subscription. Anthropic has positioned Routines as a power-user feature, and the pricing reflects that.
Can a Routine trigger another Routine?
Not directly through the Routines interface. You can set up indirect chaining by having one Routine write output to a location that a subsequent Routine reads from, but there’s no built-in sequencing or dependency management. For complex multi-step orchestration, you’d want a proper agent orchestration layer rather than trying to chain Routines manually.
How do Routines handle credentials and secrets?
Credentials are stored in Claude Code’s credential vault and attached to Routines by reference. The actual credential values aren’t embedded in the task definition — the agent retrieves them at execution time from the vault. This is important for security: you’re not storing API keys in plain text in a prompt.
What happens if a Routine runs while I’m also using Claude Code?
Routines run independently of your active Claude Code session. They don’t interfere with each other. The Routine executes in a separate cloud environment, while your local session continues unaffected. You won’t see the Routine’s activity in your terminal unless you explicitly check the Routines panel.
How is this different from Claude Code’s background agent (Chyros)?
Claude Code Chyros is an always-on background daemon that monitors your development environment and proactively suggests or takes actions based on what it observes. Routines are explicitly scheduled tasks that run at defined times. Chyros is reactive and continuous; Routines are scheduled and discrete. They serve different purposes and can complement each other.
Can I run Routines on private or sensitive data?
Yes, with appropriate care. The key considerations are: what tools you grant access to, what credentials you attach, and what the output destination is. Anthropic processes the execution in their cloud environment, so you should review their data handling policies for any task involving sensitive information before setting it up as a Routine. For highly sensitive workflows, you may want to evaluate whether a self-hosted alternative better fits your requirements.
Key Takeaways
- Claude Code Routines let you schedule AI agent tasks that run in Anthropic’s cloud — no local machine required.
- Setup involves three core pieces: a task definition, a schedule, and output destination. Getting the task definition right is where most of the work is.
- Routines work best for recurring, clearly-scoped tasks with predictable outputs. They’re not designed for event-driven workflows or complex multi-step orchestration.
- Monitor logs closely in the first week. Most task definitions need one or two refinements before they stabilize.
- When your needs grow beyond a scheduled task into a full system, a spec-driven build with Remy is likely the cleaner path.