Protocol 15 of 18Track, BuildingWhat we ship

Agents in the cloud

Everything so far ran on your laptop with you in the loop. A cloud agent runs without you: a function on Vercel wakes on a schedule, reads your database, thinks with Claude, acts within its guardrails, and logs what it did.

← All 18 protocols
Protocol 14Admin interfaces and dashboardsAll 18Protocol 16Harden the code
Why this matters

The pain it
solves

Claude Code on your laptop is an agent with you watching. The moment you close the lid, it stops. The leverage you actually want is the colleague who starts at 7 AM whether or not you are awake: reads what came in overnight, scores it, drafts the reply, and puts a digest in your inbox.

Most people imagine this requires infrastructure they cannot run. It does not. It is one scheduled function on the Vercel project you already have, calling the Claude API with the same role file you wrote in Protocol 03, writing to the same Supabase tables. Same folder idea, different home.

The teaching

What this
actually is

Three kinds of agent

The folder is the same in all three. What changes is where it runs and who is watching.

  • Claude Code: an agent that writes code
    Runs on your laptop with you in the loop. You give it a plan, it builds, you read the diff. This is the agent you have used for two days. Close the lid and it stops.
  • Routines: agents that run on your laptop
    Claude Routines, GrokBot and the like. The same folder on a schedule or a trigger, on your machine: every morning at seven, read the inbox and draft. No server. It stops when the laptop sleeps, which is fine for a daily routine and wrong for anything a customer waits on.
  • Server agents: Claude remote agents and Vercel functions
    The same role definition, running in the cloud with nobody watching. A Vercel cron wakes it, it reads your database, thinks with Claude, writes its notes and its log. Always on, costs cents, and this is the one you build this afternoon.

The five parts

Every cloud agent you will ever build has these five parts. Name them before you build and the build is short.

  • Trigger
    A cron schedule in vercel.json (every morning at 7, converted to UTC) or a webhook (a form was submitted). Protected by a secret so nobody else can fire it.
  • Context
    The rows it reads from Supabase. Inquiries created in the last 24 hours. Anything stuck in new_lead for more than a week. Never the whole database; exactly what the job needs.
  • Instructions
    The role file at agents/<name>/ROLE.md. Who it is, your hot-lead rules, the forbidden list, and the exact JSON it must return per row: a score, a one-sentence reason, a suggested next step, a draft reply.
  • Tools
    What it may do: write a note, write a draft, send you a digest. What it may never do: email a customer, delete anything, change a stage past contacted. Least privilege. Widen when you trust it.
  • Log
    agent_runs (when it ran, how many rows, status, error) and agent_notes (every decision, every draft, whether you approved it). If it is not in the log, it did not happen.

Where the key lives

The Claude API key is an environment variable on Vercel and in your local .env.local, and nowhere else. Not in code. Not sent to the browser. Not pasted into a prompt. Search the repo for the key prefix before you merge: zero hits, every time.

Cost, rhythm, and the human in the loop

A daily agent that reads fifty rows and writes fifty notes costs cents. The rhythm matters more than the model: once a day at 7 AM is a colleague, every minute is a bill. Start daily. Speed up only when the log shows it would have mattered.

The agent drafts. The admin page shows the draft. You approve. That single button is the difference between a helpful colleague and a liability. Your first cloud agent keeps it. So does your tenth.

Try it yourself60 minutes

Ship a morning lead-triage agent in 60 minutes

You need a CRM with inquiries in it (synthetic is fine, Protocol 14), Resend wired (Protocol 13), and an Anthropic API key. Open Claude Code in the project.

  1. Step 01
    Design it before you build it

    Tell the PM agent: "Ask me what makes a lead hot, what the agent must never do on its own, and what time my digest should arrive. Then write Working Files/agent-plan.md and docs/plans/agent-build-plan.md." The forbidden list is the important answer.

  2. Step 02
    Build it

    "Execute docs/plans/agent-build-plan.md: the role file, agent_runs and agent_notes tables, a Vercel cron route protected by CRON_SECRET, the Claude call with the official SDK, a digest via Resend, and /admin/agent with Run now and Approve and send. ANTHROPIC_API_KEY lives only in env vars."

  3. Step 03
    Run it against your synthetic pipeline

    Press Run now. Read the agent_runs row and three agent_notes. If the reasons sound like you, the role file is right. If not, edit ROLE.md and run again.

  4. Step 04
    Prove the guardrail

    Try Approve and send on a synthetic lead. It must refuse with a clear message. Then submit your own email through the live form, run again, approve the draft, and confirm the email arrives.

  5. Step 05
    Check the key

    Search the repo for the key prefix. Zero hits. Then tell Claude: "In three sentences, what happens at 7 AM tomorrow?" If the answer is right, you have a colleague.

Outcome

An agent on a schedule in the cloud, reading your CRM, drafting replies you approve, logging every decision, with a digest in your inbox every morning. Built from the same folder idea as every agent on your laptop.

Official resources

Straight from
the source

Verceldoc
Vercel cron jobs
Anthropicdoc
Anthropic SDK for TypeScript
Anthropicarticle
Anthropic on building effective agents
What you walk out with

By the end of this
protocol

At the retreat

You learn it by
doing it

You design the agent's forbidden list before a line of code exists, build it, press Run now against your synthetic pipeline, and read three of its reasons. If they sound like you, the role file is right.

Saigon, Jun 20See all 18 protocols
Connects to

Other protocols this
compounds with

Protocol 03
Agents are folders
Protocol 09
The plan is the prompt
Protocol 13
Communications
← Previous, Protocol 14
Admin interfaces and dashboards
Next, Protocol 16 →
Harden the code