Save 25%Labor Day sale on all three products. Applied for you at checkout (code: laborday). Ends Sept 7.Labor Day sale — ends Sept 7 (code: laborday)See pricing
← Running an AI agent on Robinhood

How to run an always-on trading agent with Claude Code’s /loop

Standing instructions, one /loop line, and a hard end. Then the two ways to take it off the terminal — a Desktop scheduled task or cron — with the permission flags that keep a headless run from stalling.

Guides · 9 min read · updated September 2026 — the Claude Code mechanics below are from Anthropic’s documentation as read on 2026-09-06; theirs is the copy that stays current

Coil is not affiliated with Robinhood or Anthropic. This page assumes your agent is already connected to Robinhood’s agentic-trading MCP (the setup guide covers that) and to a board it can read. It is about the part every connection tutorial stops short of: keeping the agent running without you sitting there, and without it running away from you.

Long-only, your machine, your account, your capital. An agent that loops unattended repeats a bad rule as faithfully as a good one, and the only cap it cannot argue around is the balance of the agentic account. Fund that like risk capital. Nothing here is investment advice.

What “always-on” should actually mean

Not a scalper. Not an agent with a hand on the order button all session. Always-on means a short pass on a fixed clock — regime first, then the ranked list, then the names it is serious about — and most passes ending in one line: nothing to do. The board’s first job is to tell the agent when to stand down; the schedule’s job is to make sure the agent asks. That framing decides everything below: how often it runs, what it is allowed to touch, and why every pass needs an end.

Three ways to schedule Claude Code, and which one this is

Anthropic ships three. /loop re-runs a prompt inside an open session: it inherits the session’s MCP servers and permissions, the floor is one minute, and it stops when the session does. A Desktop scheduled task starts a fresh session on your machine on a schedule, with no session open, your local files and MCP config available, a permission mode you set per task, and the same one-minute floor. A cloud routine runs on Anthropic’s infrastructure with your laptop closed, but it clones a repository rather than seeing your machine, takes MCP servers only as claude.ai connectors, and its minimum interval is an hour — too coarse for a market-hours pass, and the local claude mcp add servers this setup depends on don’t reach it. So: start with /loop while you watch, and graduate to a Desktop task or cron once the passes have been boring for a while. This page does both.

Step 1 — The standing instructions

Put the discipline in a file the session loads every time, not in the prompt you type. A CLAUDE.md in the folder you launch from is read at the start of every session and every scheduled run from that folder, so the loop’s prompt can be one line and the rules never drift. Coil’s guardrails template is the long form; this is the core:

# Trading pass. Read this before doing anything.

1. If the US market is closed, say so in one line and stop.
2. Call coil get_market_regime. If the ladder does not permit names, report
   "stand down" in one line and stop. Do not place orders.
3. Call coil get_buy_list and consider ONLY names on it.
4. Call coil get_stock_read on each candidate you are serious about.
5. Compare against the plan in plan.md. If nothing changed, say so and stop.
6. Size from MY rules below, never from Coil. It publishes scores and
   states, not position sizes, stops or targets.
7. Write the new plan to plan.md. Place orders through Robinhood only within
   the budget below, and only for the change you just described.
8. End the pass. Never wait for anything. Never start unrelated work.

My rules: max position size ___, max orders per pass ___, daily loss halt ___.
Kill switch: if plan.md contains the word HALT, do nothing and say so.

Two details carry the weight. The plan file is the memory between passes; without it every pass starts from zero and re-argues the same trade. And line 8 is the hard end, written into the agent’s own instructions, because the expensive failure in unattended sessions is the one that keeps going. Our own scheduled sessions taught us that: one review session that failed to finish ran for four days and by itself cost as much as every other scheduled session put together. Position size and exit rules stay in your half of the file. Coil publishes scores and states and never sizes, stops or targets.

Step 2 — The loop

With the two MCP servers loaded and the file in place, the whole schedule is one line:

/loop 15m run the trading pass in CLAUDE.md

Claude converts the interval to a cron job and confirms it. Units are s, m, h and d; seconds round up to a minute, and an interval that isn’t a clean cron step (7m, 90m) is rounded to one that is, and it tells you what it picked. Leave the interval off and Claude chooses the next wait itself, between a minute and an hour, printing its reason each time — useful for a watch, wrong for a trading pass, which should run on a clock you chose.

The mechanics that matter, from the Claude Code documentation:

  • It fires only while the session is open and idle. Close the terminal and it stops. If a fire comes due while Claude is busy, it runs once when Claude is free; there is no catch-up for missed intervals.
  • It is jittered. Loops that run more often than hourly can fire up to half the interval late, so 15m means roughly every fifteen minutes, not on the minute. If exact timing matters, the pass reads the clock, not the schedule.
  • It expires after seven days. A recurring task fires one last time and deletes itself. That is a feature, since a forgotten loop cannot run all quarter, and it means you re-issue the line each Monday.
  • Stopping it. Esc ends a self-paced loop while it waits; a fixed-interval loop is cancelled by asking, in plain words, to cancel it. Resuming the session with --resume brings an unexpired loop back.

Fifteen minutes is deliberate. Every pass re-sends the whole conversation, so what a loop costs is passes times context, and the context only grows. A five-minute loop across a full US session is close to eighty passes against a conversation that gets longer each time; a fifteen-minute one is about twenty-six, and the board it reads is re-scored about every five minutes through the US market day, so nothing worth catching lives inside that gap. A read-and-report pass is a handful of tool calls. Keep it that way.

Step 3 — Taking it off the terminal

A loop needs the session open. For a pass that runs whether or not you are at the keyboard, use one of the two local options.

A Claude Desktop scheduled task

In the Desktop app’s Code tab: Routines, New routine, Local. Name it, paste the same one-line instruction, pick the working folder that holds your CLAUDE.md and plan.md, and set the schedule. The presets are hourly, daily, weekdays and weekly; for every fifteen minutes in market hours you ask Claude in any session to set it (“schedule the trading pass every 15 minutes, weekdays, 6:30 to 13:00 my time”). Then click Run now, watch for the permission prompts, and choose always allow for each tool the pass uses; future runs inherit those approvals and never stall. Three things the documentation is explicit about, and this setup lives or dies on them: the task runs only while the app is open and the computer is awake (there is a Keep computer awake setting; a closed lid still sleeps); a missed run is caught up exactly once on wake, which is why line 1 of the file checks the market clock first, because a 9:30 pass can fire at 11pm; and a task in manual permission mode that meets a tool it hasn’t been allowed to use stalls until you answer.

Cron and claude -p

The same pass from any scheduler, on a machine that stays awake:

*/15 6-12 * * 1-5  cd ~/trading && claude -p "run the trading pass in CLAUDE.md" --allowedTools "mcp__coil,mcp__robinhood-trading__get_equity_positions,mcp__robinhood-trading__get_equity_quotes,mcp__robinhood-trading__get_equity_orders,Read,Write" --permission-prompts none --output-format json >> passes.jsonl

Read that line slowly, because each piece is a rule. -p is print mode: one prompt, one answer, exit. Without --bare it loads the same context an interactive session would, including the MCP servers you registered with claude mcp add and the CLAUDE.md in that folder, which is exactly what you want here and exactly why you do not add --bare. --allowedTools names the tools the pass may use without asking: mcp__coil allows every Coil read, and the Robinhood reads are named one by one. Nothing here allows an order tool, so this pass can only read, plan and write the plan file. --permission-prompts none is the flag for a run nobody is watching: anything that would have prompted is denied and the pass is told not to retry, instead of sitting on a question forever (it needs a current Claude Code; older builds reject the flag, and a -p run with no one listening denies the request either way, so the flag’s job is the not-retrying). The JSON output carries an estimated cost per pass, which is how you find out what the loop really costs before the bill does. The cron hours are local time; those are Pacific for the US session, so shift them to yours.

This is the trap that looks like a strategy problem and isn’t: a headless run cannot answer a permission prompt. It sits there until something kills it, and from the outside it looks like an agent that read the market and decided to do nothing. If a scheduled pass produces no plan and no error, check the allowed-tools list before you touch the rules. The same goes for the broker sign-in: you signed in to Robinhood once, in a browser, and the headless run reuses that connection; when it lapses, the pass fails on its first Robinhood call, which is why line 8 says to end and report rather than wait.

Letting an unattended pass place orders is a separate decision, made once and on purpose: add the order tool to the allowed list by its full name, replace “show me the plan” with hard caps in the file, and accept that no one is confirming. Run the report-only version for weeks first. The plan file will tell you what it would have done.

What a pass looks like

Most days the transcript is four lines: market open, regime read, ladder says stand down, done. That is the loop working. An entry day is longer. The regime permits names, the list has two, one reads as ready, the plan changes by one line and, if you have allowed it, one order goes in under the cap. The close is your rule to write, not the board’s: Coil’s own engine makes one close-or-keep decision in the last minutes of each session, by rule, and never lets the clock alone exit a swing. Whatever you decide, write it into the file. An agent with no close rule holds whatever the last pass left it with.

Where the board comes from

A loop is only worth running against a board that moves as fast as the loop. The free Coil server (claude mcp add --transport http coil https://coil.trade/mcp, no key) is one market day delayed: right for a single pass before the open, pointless every fifteen minutes. The intraday board, re-scored about every five minutes through the US market day, comes with a Coil Scanner key ($12/mo), and the same tools upgrade in place. Coil Live ($29/mo) serves the engine-grade version of it — the structural stops, targets, conviction and lanes the live record trades — plus the served discipline, which is the half of the standing instructions above you would otherwise write yourself. What running by rule looks like over months is at /results, published every session next to SPY and QQQ, win or lose.

The risks, stated plainly

An unattended loop removes the one safeguard every other guide relies on: you, reading the plan before it acts. Everything else has to be structural. The account balance is the cap. The order caps in the file are the second cap. The kill word in the plan file is the brake you can pull from your phone by editing one line. Leveraged ETFs, where a strategy uses them, can lose value rapidly, including total loss. And the record you are building is yours: publish it to yourself the way we publish ours, next to the benchmark, every session, so the loop has to earn its keep.

Common questions

Does /loop keep running if I close the terminal?

No. A /loop task fires only while the session is open and idle; closing the terminal stops it, and a fire that comes due while Claude is busy runs once when it is free rather than once per missed interval. For a pass that must run with no terminal open, use a Claude Desktop scheduled task or cron with claude -p.

How often should a trading loop run?

Every fifteen minutes is the working default. Every pass re-sends the whole conversation, so a five-minute loop over a full US session is close to eighty passes against a context that only grows, and the board it reads is re-scored about every five minutes anyway. Sub-hourly loops are also jittered by up to half their interval, so the pass should read the clock rather than trust the schedule.

Why did my scheduled trading pass do nothing?

Usually because a headless run hit a permission prompt nobody could answer and waited until it was killed, which looks exactly like an agent that decided not to trade. Name every tool the pass uses in --allowedTools (or mark them always-allow after a Run now in Desktop), pass --permission-prompts none, and check the pass log before you touch the rules. The second cause is a lapsed broker sign-in, which fails on the first Robinhood call.

Why did my loop stop after a week?

Recurring /loop tasks expire seven days after creation: the task fires one final time and deletes itself. It is deliberate, so a forgotten loop cannot run indefinitely. Re-issue the line, or move the pass to a Desktop scheduled task, which has no expiry.

Can a cloud routine run the trading pass instead?

Not this one. Cloud routines run on Anthropic's infrastructure against a cloned repository, take MCP servers only as claude.ai connectors rather than the local claude mcp add registrations, and have a one-hour minimum interval. They are right for nightly work; a market-hours pass wants /loop, a Desktop scheduled task, or cron on your own machine.

Should an unattended pass be allowed to place orders?

Not at first. Run it report-only for weeks with no order tool in the allowed list, and read the plan file it writes. If you then allow the order tool by its full name, the standing instructions must carry hard caps on position size and orders per pass, the agentic account balance stays small, and the kill word in the plan file becomes the brake you can pull from anywhere.