โ† Back to Resources

Prompt Database

๐Ÿค– Claude Code Routines โ€“ Setup Guide

๐Ÿ’ก What are Routines? Routines are saved AI agent configurations (prompt + repos + connectors + trigger) that run on Anthropic's cloud โ€” no laptop, no terminal, no you required.

๐Ÿ“‹ What You Need Before Starting

Requirement Details
Claude Plan Pro, Max, Team, or Enterprise
Claude Code Must be enabled on web (claude.ai/code)
GitHub Repo Clean, focused repo per routine
API Keys Added as environment variables in Claude Cloud
MCP Connectors Slack, Gmail, Linear, ClickUp, etc.

โšก 3 Ways to Trigger a Routine

๐Ÿ• 1. Scheduled (Time-Based)
  • Pick a cadence: hourly, daily, weekdays, weekly
  • Minimum interval: 1 hour
  • Times auto-convert to your local timezone
  • For custom intervals (every 2 hrs, 1st of month) โ†’ use CLI:

<p> ```bash</p>

<p>/schedule update --cron "0 <em>/2 </em> <em> </em>"</p>

<p> ```</p></div></details>

๐ŸŒ 2. API Trigger (HTTP Endpoint)
  • Every routine gets its own HTTP endpoint + bearer token
  • POST to it to fire the routine
  • Pass extra context in the text field of the body
  • Response returns a session ID + URL to watch Claude work live

<p> ```bash</p>

<p>curl -X POST https://your-routine-endpoint \</p>

<p> -H "Authorization: Bearer YOUR_TOKEN" \</p>

<p> -H "Content-Type: application/json" \</p>

<p> -d '{"text": "New lead from Acme Corp โ€“ check CRM"}'</p>

<p> ```</p>

<p> <strong>Use case:</strong> Your monitoring tool catches an error โ†’ hits the endpoint โ†’ Claude investigates and fixes.</p></div></details>

๐Ÿ™ 3. GitHub Events
  • Fires on: PR opened, code pushed, issue created
  • Granular filters: specific authors, branches, PR labels
  • Requires: Claude GitHub App installed on your repo (separate from web setup)

<p> &gt; โš ๏ธ If the app isn't installed, the trigger setup will flag it for you.</p></div></details>


๐Ÿ—๏ธ How to Create a Routine (Step-by-Step)

Access points:

  • Web: claude.ai/code/routines
  • Desktop app
  • CLI: /schedule command
๐Ÿ“ Note: CLI can only create scheduled routines. For API or GitHub triggers, edit on the web after.

Step 1 โ€” Write the Prompt

Write it like you're handing off to someone who cannot reach you. No approvals, no questions.

Check for any new form submissions in the last 24 hours
using the API key available as the environment variable FORM_API_KEY.
For each lead:
1. Research their company using web search
2. Draft a personalized welcome email
3. Add them to HubSpot CRM
4. Post a summary to #new-leads in Slack

If any step fails, post what went wrong to #alerts in Slack.

Step 2 โ€” Add Environment Variables

โš ๏ธ Critical: Your .env file is NOT available. Routines clone your repo fresh each run โ€” no local files.
  • Add all API keys to the Claude Cloud environment as env vars
  • Tell Claude explicitly: use the API key from the environment variable, do not look for a .env file

Step 3 โ€” Configure the Repo

  • Attach a lean, focused repo (not your massive main project)
  • Any changes Claude makes โ†’ pushed to a new branch, never straight to main

Step 4 โ€” Set Network Access

Setting What it means
Default (Trusted) Anthropic's vetted domains only
Full Open internet access
Custom Your specified allowlist

Step 5 โ€” Add Connectors

All your MCP integrations are included by default. Remove anything the routine doesn't need.

Step 6 โ€” Test Before Scheduling

Hit Run Now first. Watch the run log โ€” green = worked. Click in for full session detail (every tool call, every decision).


๐ŸŽฏ Best Routines to Run for Your Business

Routine Trigger What It Does
๐Ÿš€ Speed to Lead New form submission (API) Research lead โ†’ draft email โ†’ add to CRM โ†’ notify Slack
๐Ÿ“Š Client Reporting Weekly schedule Pull data โ†’ generate report โ†’ send to client
๐Ÿงน Pipeline Cleanup Daily schedule Flag stale deals โ†’ update statuses โ†’ post summary
๐Ÿ“ฅ Inbound Triage Hourly schedule Check new emails โ†’ categorize โ†’ draft responses โ†’ Slack drafts
๐Ÿ“„ Document Processing GitHub push New file in repo โ†’ extract data โ†’ update database
๐Ÿ”” Error Response API (monitoring tool) Alert fires โ†’ Claude investigates โ†’ auto-fix or escalates

๐Ÿ“ฆ Plan Limits

Plan Runs/Day Extra Usage?
Pro 5 โœ… (metered overage)
Max 15 โœ…
Team / Enterprise 25 โœ…

Each run gets: 4 vCPUs ยท 16GB RAM ยท 30GB disk

โš ๏ธ Routine runs draw from the same token pool as your interactive sessions.

โœ… 5 Tips Before Going Live

1๏ธโƒฃ Always test with Run Now first

Don't schedule anything you haven't watched run successfully at least once.

2๏ธโƒฃ Add a failure fallback to your prompt
If any step fails, post a message to #alerts in Slack

with what went wrong and which step failed.

```</code></pre></div></details>

3๏ธโƒฃ Keep a lean repo per routine

Your main project's CLAUDE.md may be massive. Every token Claude spends reading irrelevant context = fewer tokens on the actual task.

4๏ธโƒฃ Use setup scripts for dependencies

Add a script in Claude Cloud environment that runs before Claude launches โ€” pre-installs Python libraries, CLI tools, etc. Saves time every single run.

5๏ธโƒฃ Migrate from n8n / Make / Zapier instantly
1. Open your workflow in n8n / Make / Zapier
  1. Export / copy the workflow JSON
  2. Paste into Claude Code
  3. Prompt: &quot;Convert this into a Claude Code routine prompt&quot;

```

No rewriting from scratch.</code></pre></div></details>


๐Ÿ”„ Routines vs. Local Tasks vs. /loop

Tool Best For Min Interval
Routines Stateless, cloud, no hardware needed 1 hour
Local Scheduled Tasks Needs local files, cookies, browser sessions Minutes
/loop Recurring tasks inside a single terminal session 1 minute

โš ๏ธ What Routines Can't Do

  • No persistent memory between runs (stateless)
  • No local file access
  • No browser sessions or cookies
  • No stored state from previous runs

โ†’ For any of these, keep it as a local scheduled task.