Roman Peschke @roman.peschke
Free Guide

How to Automate Your Business with Claude Code Routines

Take any workflow you run locally and turn it into a hands-off cloud routine. No laptop, no servers, no glue code.

Scale your ads with AI
Tools you'll use

Anthropic just turned autonomous work into a setup form. Before Routines, running a workflow on a schedule meant keeping your laptop open, paying for a server, or duct-taping cron jobs together. Now you write a prompt, pick a trigger, and it runs on Anthropic's cloud.

This is The Autonomous Loop: Prompt → Trigger → Run. Do it once, it runs forever.

What this guide assumes

  • You have a Claude Pro, Max, Team, or Enterprise subscription. Routines are only on paid plans.
  • You have a GitHub account. Free is fine. Sign up here if you don't.
  • You have a working local workflow. A project folder on your Mac that already runs (a cron job, a launchd task, or a script you run manually).
  • You have Claude Code installed. Claude will do the terminal work for you.
  • Your API keys live in a local .env file (or somewhere you can copy them from).
Prep
1

Turn on Claude Code on the web

Go to claude.ai. Click your avatar in the top right, then Settings.

  • Under Billing, confirm your plan is Pro, Max, Team, or Enterprise.
  • Under Feature previews, toggle on Claude Code on the web.

Open a new tab and go to claude.ai/code. If you see the session list, you're in.

2

Push your project to a private GitHub repo

Routines need your code in a GitHub repo so they can clone it at the start of every run. Open Claude Code in your project folder (cd in, then claude), and paste:

Create a private GitHub repo for this project called [your-project-name] and push the code up. First, write a .gitignore that excludes .env and anything with secrets. Don't commit any keys. Tell me when the repo is live.

Claude handles the git init, the push, and GitHub auth if needed.

3

Scrub local paths so it runs in the cloud

Anything hardcoded to your Mac (/Users/..., ~/) won't exist in the cloud. Still in Claude Code, paste:

Find every hardcoded local path in this project (anything starting with /Users/, ~/, or referencing my home directory). Replace with repo-relative paths. Confirm .env is gitignored and no secrets are in the git history. Push the cleanups.
Configure
4

List your secrets

Ask Claude Code:

List every variable in my .env file. Names only, not values. I need the list to set up a cloud environment.

Keep the list handy. You'll paste the actual values into the web UI yourself.

5

Create a cloud environment

In your browser, go to claude.ai/code. In the left sidebar, click Environments, then New environment. Give it a name.

  • Environment variables: click Add variable for each name from Step 4. Open your local .env in a text editor, copy each value, paste it into the web form.
  • Setup script: back in Claude Code, paste:
    Look at this project and write the exact setup script I need to paste into Claude Code's cloud environment so a fresh clone is runnable. Install all my dependencies, nothing else.
    Paste Claude's output into the Setup script field in the browser.
  • Network access: set to Full. Your routine will hit external APIs.

Click Save.

6

Connect your MCP tools

If your routine sends emails, posts to Slack, writes to a CRM, or hits anything outside your repo — connect it as an MCP connector.

On claude.ai, go to Settings → Connectors. Click Connect on each service you need (Gmail, Slack, Linear, Google Drive, Notion, and more). Authenticate through each one's OAuth flow.

Ship
7

Turn your workflow into a routine prompt

A routine prompt is instructions to an autonomous agent, not code. Back in Claude Code, paste:

Look at the main script in this project (the one my cron or launchd runs). Rewrite it as a routine prompt for Claude Code — instructions to an autonomous agent, not code. Include numbered steps, explicit success criteria at the bottom, and any file paths it should read or write.

Copy the prompt Claude gives you.

8

Create the routine and attach a trigger

Go to claude.ai/code/routines and click New routine.

  • Name: something clear, like "Morning Ad Report."
  • Prompt: paste the prompt from Step 7.
  • Repositories: click Add repository, pick the repo from Step 2.
  • Environment: pick the one from Step 5.
  • Connectors: uncheck any this routine doesn't need.
  • Select a trigger: pick one (details below).

Click Create.

9

Test before enabling

On the routine detail page, click Run now. A session opens — watch it execute live.

If anything fails, copy the error, jump back to Claude Code, and paste:

My routine run just failed with this error: [paste]. Here's the prompt I used: [paste]. Figure out what's wrong, fix it in the repo, push the change, and tell me what you changed.

Re-run until clean. Only then do you trust the trigger.

The three triggers

Every routine needs at least one trigger. Here's how to pick the right one for your workflow.

Schedule — for anything on a clock
Daily, weekly, weekdays, or a custom cron expression (minimum 1 hour). Good for: morning performance reports, nightly data backfills, weekly review digests, end-of-month reconciliation. Anything you'd set a recurring calendar reminder for.
API — for anything triggered by another tool
Every routine gets a unique URL and bearer token. POST to it from any webhook, alert, or form submit. Good for: new lead hits your CRM → enrich and personalize outreach, monitoring alert → triage the error, deploy finishes → run smoke checks. Any event in another platform becomes a Claude run.
GitHub — for anything tied to code
React to PRs, pushes, issues, releases, check runs, and more. Filter by author, label, branch, or draft state. Good for: custom PR reviewers, auto-labeling issues, porting merged changes to other repos. You only need this if your workflow lives around a codebase.

Pitfalls

!
Don't enable "Allow unrestricted branch pushes" unless you need it. By default, routines can only push to branches prefixed with claude/. That's your guardrail — it stops a routine from clobbering main.
!
Don't assume the /schedule CLI command does everything. It only creates schedule triggers. API and GitHub triggers have to be added in the web UI after the routine is saved.
!
Don't lose the API bearer token. It's shown once. You can't retrieve it later. Paste it straight into your webhook tool's secret manager the moment it's generated.
!
Don't skip the test run. A silent failure at 6am looks identical to the routine working. "Run now" with eyes on the live session is the only way to catch missing env vars or broken paths before they matter.
Quick win

Want to feel it work in 30 seconds? Open Claude Code in any folder and type /schedule tomorrow at 8am summarize my GitHub notifications. One live Autonomous Loop, no repo required.

Tools used in this guide

Claude Code Routines
Saved Claude Code configurations — prompt, repos, connectors — that execute on Anthropic-managed cloud infrastructure. Triggered by schedule, API call, or GitHub event. In research preview on Pro, Max, Team, and Enterprise plans.
claude.ai/code/routines
Claude Code
Anthropic's agentic coding CLI. Runs in your terminal with full access to your project files. Used here to set up GitHub, scrub local paths, and rewrite your scripts as routine prompts.
claude.com/product/claude-code
GitHub
Where your code has to live so Routines can clone it every run. Free accounts support private repos. The Claude GitHub App is required for GitHub event triggers.
github.com

FAQ

Does my laptop have to stay on?
No. Routines run on Anthropic-managed cloud infrastructure. They keep going when your laptop is closed or your internet is off.
What plan do I need?
Pro, Max, Team, or Enterprise — with Claude Code on the web enabled in Feature previews.
Do I need to know how to code?
If you already have a working local workflow, Claude Code handles the GitHub setup, path cleanup, and prompt conversion for you. Scheduled triggers are pure point-and-click. API and GitHub triggers take slightly more familiarity.
What's the minimum run interval?
One hour. Schedules more frequent than hourly are rejected. Runs may also start a few minutes after the scheduled time due to stagger.
What if my routine fails silently?
Every run creates a session you can open after the fact. Click the routine, then any past run, to see exactly what Claude did, what errored, and where. Treat it like reviewing a recording.