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 AIAnthropic 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
.envfile (or somewhere you can copy them from).
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.
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:
[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.
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:
/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.List your secrets
Ask Claude Code:
.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.
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
.envin 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.
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.
Turn your workflow into a routine prompt
A routine prompt is instructions to an autonomous agent, not code. Back in Claude Code, paste:
Copy the prompt Claude gives you.
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.
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:
[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.
Pitfalls
claude/. That's your guardrail — it stops a routine from clobbering main./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.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.