How to Use Claude Routines to Run Autonomous Tasks Automatically

Claude Routines remove the biggest limitation session-based AI has always had: nothing happens unless you're there to ask for it.

Here's a problem I know you've run into. You build a great AI workflow, it works perfectly, and then you close your laptop and everything stops.

That's the hard limit of session-based AI. Claude responds when you type. The moment your session ends, the automation ends with it. If you want a daily report at 7 AM, you have to remember to ask for it at 7 AM. Every single day.

Claude Routines change that completely. Launched in April 2026, Claude Routines is a feature inside Claude Code that lets you define a task once and let it run on Anthropic's cloud on its own. You set a schedule, attach the right tools, and walk away. No laptop required. No terminal open. No babysitting.

This guide walks you through everything: what Routines are, the three trigger types, how to set one up step by step, the 7 gotchas that trip people up, and a Gmail triage workflow you can deploy today.


What Is Claude Routines?

A Claude Routine is a saved task that runs on Anthropic's cloud infrastructure. It is made up of three things:

  • A prompt — what you want Claude to do
  • Connected repositories — the code or content Claude works with
  • Connectors — integrations like Gmail, Slack, Google Drive, or GitHub

Once you configure a Routine, it runs independently of your device. Your laptop can be off. Your internet can be down at execution time. The agent still fires, does the work, and logs the results.

Think of it like hiring someone to check your inbox every morning, triage the messages, and send you a summary. Except you write the instructions once and never manage them again.

Routines are available to Claude Code users on Pro, Max, Team, and Enterprise plans. Create them at claude.ai/code/routines or directly from the command line using the /schedule command.

For a deeper look at how Claude connects to external tools and apps, How to Use Claude MCP to Connect Claude to Your Business Apps explains the connector layer that Routines rely on.


The 3 Trigger Types

Every Routine supports one or more trigger types. You can combine them on the same Routine, so the same task can fire on a schedule, respond to an API call, and react to a GitHub event simultaneously.

1. Scheduled Trigger

Set a time cadence and walk away. Options include hourly, daily, on weekdays, or weekly. You enter the time in your local timezone. The system handles the conversion automatically.

You can also use custom cron expressions for precise intervals:

  • 0 9 * * 1-5 — 9:00 AM every weekday
  • 0 8,17 * * * — 8 AM and 5 PM daily
  • 0 0 1 * * — midnight on the first of each month

Not familiar with cron syntax? Crontab Guru is the best tool for building and testing cron expressions before you use them.

From the CLI, you can create a scheduled routine conversationally:

/schedule daily PR review at 9am

Claude walks through the same fields the web form collects and saves the routine to your account. It shows up at claude.ai/code/routines immediately.

Best for: morning digests, weekly reports, nightly cleanup jobs, recurring content tasks.

2. API Trigger

Each Routine can expose its own HTTP endpoint with a dedicated bearer token. Send a POST request to that endpoint and Claude spins up a session, runs your prompt, and returns a session URL.

The powerful detail: you can pass context with every trigger using the text field. Point your monitoring tool, deploy pipeline, or internal system at the endpoint and it gets a response tailored to the data you send.

curl -X POST https://api.anthropic.com/v1/claude_code/routines/trig_01ABC.../fire \
  -H "Authorization: Bearer sk-ant-oat01-xxxxx" \
  -H "Content-Type: application/json" \
  -d '{"text": "Sentry alert SEN-4521 fired in prod. Stack trace attached."}'

Best for: alert triage, deploy verification, triggering AI tasks from external systems.

3. GitHub Webhook Trigger

Subscribe a Routine to GitHub repository events and Claude reacts automatically. Every matching event starts its own session. Supported events include:

  • Pull request opened, closed, labeled, synchronized, or updated
  • Commits pushed to a branch
  • Issues opened, edited, closed, or labeled
  • Release created, published, or deleted
  • GitHub Actions workflow started or completed

You can filter pull request events by author, title, base branch, labels, and draft state. So a routine can fire only when a PR is opened by a specific team member on a specific branch.

Best for: automated code review, PR summaries, issue triage, syncing changes across repositories.


How to Set Up Your First Routine

The easiest starting point is the web interface. Here's the full setup process.

Step 1: Go to claude.ai/code/routines

Log in to Claude Code and click the Routines tab. You'll see a dashboard of any existing routines and a calendar view of upcoming scheduled runs.

Step 2: Click "New Routine"

Fill out the form with these fields:

  1. Name — make it descriptive (e.g., "Morning Email Triage")
  2. Task prompt — what you want Claude to do (see Step 3)
  3. Trigger type — schedule, API, or GitHub
  4. Repositories — the repos Claude should clone for this task
  5. Connectors — integrations like Gmail, Slack, or Linear
  6. Setup script — optional script that runs before the session starts (useful for installing dependencies)

Step 3: Write a specific task prompt

This is where most people go wrong. Vague prompts produce inconsistent automation, and there's no one to course-correct when a routine misfires. Compare these two examples:

Weak:

"Check my GitHub repos and tell me what's happening."

Strong:

"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. Write a summary of all PRs reviewed and comments posted to /logs/pr-summary-{date}.md."

The strong version specifies what to look at, what to do, what to produce, and where to save the output. Write every routine prompt with that level of detail.

Step 4: Choose your trigger

For a scheduled routine, pick Daily, Weekly, Weekdays, or enter a custom cron expression. The minimum interval for scheduled routines is once per hour. For API or GitHub triggers, the form walks you through generating your endpoint and token.

Step 5: Test with "Run Now" before activating

Before you switch on the schedule, click Run now to trigger a single execution. Review the output. Does it match what you expected? If not, refine the prompt and test again. Most routines need one or two adjustments before they stabilize.

Step 6: Activate

Once the output looks right, toggle the Routine to active. From the CLI, use /schedule run to test a routine and /schedule list to see all active routines.


The 7 Gotchas That Trip People Up

These are the seven mistakes that cause the most confusion for people setting up Routines for the first time. Knowing them in advance will save you hours.

Gotcha 1: The .env secrets trap

Never put API keys or credentials in a .env file inside your repository. Routines clone your repo fresh on every run, so secrets in repo files are a security risk. They also cause silent failures when the credentials aren't in the expected location. Store all credentials in Claude Code's connector credential vault. The routine retrieves them at execution time, not from your repo.

Gotcha 2: Timezone confusion

The web UI accepts times in your local timezone. Still, it's worth verifying the first few runs, especially for time-sensitive tasks. If you need a task to fire at 9 AM for a morning standup, check that the scheduled time looks correct after saving. One misconfigured timezone setting turns your "morning digest" into a 2 PM interruption.

Gotcha 3: Vague prompts break automation

A prompt that works great in an interactive session doesn't always produce reliable results when it runs unattended. You won't be there to clarify or redirect. Add specifics: what to look at, what to produce, where to save the output, and what to do if something is missing or ambiguous.

Gotcha 4: Branch push restrictions

By default, Routines can only push to branches prefixed with claude/. This protects your main and release branches from accidental changes. If your routine needs to push to a different branch, you must explicitly enable "Allow unrestricted branch pushes" in the routine settings. Forgetting this means code changes get silently blocked with no obvious error.

Gotcha 5: The API bearer token appears only once

When you create an API-triggered routine, Claude generates a bearer token and shows it exactly once. You cannot retrieve it again from the dashboard. Copy it immediately into your alerting tool's secret store, a password manager, or wherever your calling system needs it. If you lose it, you'll need to rotate and generate a new token.

Gotcha 6: Skipping the test run

It's tempting to flip the schedule on and trust that the prompt works. Almost every time, the first few automated runs surface issues you didn't catch. Always click "Run now" to verify the full execution before setting the routine live. It takes two minutes and prevents a week of silent misfires.

Gotcha 7: GitHub App vs. web-setup confusion

Running /web-setup in the Claude Code CLI grants Claude clone access to your repository. It does not install the GitHub App. Webhook-triggered routines require a separate GitHub App installation on the target repository. The trigger setup form prompts you through this, but many people miss the step and spend an hour wondering why their pull request events aren't triggering anything.


The Gmail Triage Workflow (Deploy This Today)

This is the Routine that convinced most people I know to actually start using this feature. Here's how to build it.

What it does: Every morning, Claude checks your inbox, reviews unread messages from the past 24 hours, categorizes each one, and produces a prioritized action list in a markdown file. You start your day knowing exactly what's urgent and what can wait.

Connector setup:

  1. Go to claude.ai/code/routines and click "New Routine"
  2. Under Connectors, add Gmail (you authorize once via OAuth)
  3. Set the trigger to Daily at your preferred morning time

The task prompt:

"Check my Gmail inbox for unread messages received in the last 24 hours. Categorize each message as: URGENT (needs response today), ACTION (needs follow-up within 3 days), INFO (no action needed), or SPAM (can be archived). For every URGENT and ACTION message, draft a 2-sentence reply starter. Output a numbered list sorted by category to /logs/email-triage-{YYYY-MM-DD}.md. If the inbox has no unread messages, write 'Inbox clear' to the log file and exit."

What you get:

Every morning, before you open Gmail, there's a markdown file with every message categorized and reply starters ready for anything urgent. You open Gmail already knowing what needs attention and what doesn't.

What I love about this pattern is how it flips the dynamic. Instead of email controlling your morning, your morning starts with a clear picture of what actually matters. This one routine saves 30 to 45 minutes every day once it's running.

The same structure works for Slack digest summaries, GitHub notification reviews, and task tracker updates. The pattern is always: check the source, filter for what matters, produce an action list.

You can download a full Gmail Triage Workflow guide with variations and prompt customizations in the resource pack at the bottom of this article.


Plan Limits: How Many Routines Can You Run Per Day?

PlanRoutine Runs Per Day
Pro5
Max15
Team25
Enterprise25+ with extra usage

Usage counts the same way as standard Claude Code sessions. Additional runs beyond the daily limit are available through paid overage on plans with extra usage enabled. Check your consumption at claude.ai/settings/usage.

For most people starting out, 5 runs per day on Pro is enough to test three or four workflows. Once you're running production routines, upgrading to Max or Team gives you the headroom to scale.


When Routines Don't Make Sense

Routines are the right tool for tasks that need reasoning, run unattended, and happen on a predictable cadence. They're not the right tool for everything.

Skip Routines when:

  • The task is pure data movement with no reasoning required. Moving records from one API to another with a fixed format is faster and cheaper on n8n or Zapier. Routines shine when the task needs judgment, not just routing.
  • You need more than 25 runs per day. High-frequency triggers (per-message webhooks, real-time pipelines) will burn through daily limits fast.
  • The task depends on your local filesystem. Routines clone your repos but cannot access your local machine. For tasks that need local files, use Desktop scheduled tasks in the Claude Code desktop app instead.

The question to ask yourself: does this workflow need to think, or does it just need to move data? If it just moves data, keep it in your existing automation platform. If it needs to think, reason, analyze, or draft, Routines are built for it.


Get Started Today

Claude Routines remove the biggest limitation that session-based AI has always had: nothing happens unless you're there to ask for it.

Pick one task you do manually every single day. Write a specific prompt for it. Set it as a daily Routine. Test it with "Run now." Watch it run on its own the next morning.

That one routine will show you more about what autonomous AI can do for your workflow than any amount of reading about it. Start there, then expand.

The full official documentation is at Claude Code Routines documentation. For API reference and advanced trigger configuration, the same documentation covers every parameter in detail.

If you want to go deeper on connecting Claude to your business tools and external APIs, check out How to Connect Claude AI to Your Apps Using the Claude API as the natural next step after you've got Routines running.

And if you're interested in a no-code approach to scheduled AI automation that doesn't require Claude Code at all, How to Set Up Automations on Zo Computer is worth reading alongside this guide.

Download the free Claude Routines Starter Pack below. It includes 7 ready-to-deploy routine templates, the full Gmail triage workflow guide with variations, and a step-by-step setup reference you can follow alongside this article.

Free resource

7 ready-to-deploy Routine templates + Gmail triage workflow guide + step-by-step setup reference

Download the free Routines starter pack
Link copied!