Skip to the article
By Nation 13 min read

Claude Code loops for a Shopify store

A goal plus a stop condition the agent runs on a schedule. Pointed at your store through MCP, it joins Shopify orders to your ad spend, flags products losing money, and drafts the fixes.

One prompt builds, runs and markets your store

AI agents set it up, handle the orders and run the ads. You approve with one click.

Most people use an AI agent the slow way: ask, wait, read, fix, ask again — every turn runs through you, and the moment you stop, it stops. A loop changes who drives. You state the goal once and the agent runs the cycle itself, on a schedule. In Claude Code the command is /loop.

What a loop actually is

For a Shopify store the five-part cycle maps straight onto a daily growth routine:

  1. Discover — Join orders to ad spend vs baseline
  2. Plan — Decide the budget, price or catalog fix
  3. Execute — Draft it — or apply on approval
  4. Verify — Check the gate: ROAS / margin / stock
  5. Iterate — Pass? stop. Fail? feed back and rerun

The cycle runs on a schedule and repeats until the gate passes or the stop condition — success, or a maximum number of tries — is hit.

Verify is the part people get wrong. Without a real check on each pass, you do not have a loop — you have the agent agreeing with itself on repeat. The check has to be something that can fail the work: a product ROAS below floor, a contribution margin gone negative, an item that just went out of stock. The model that proposed the change is far too generous grading its own homework, which is exactly why an unattended store loop needs an objective gate and a human approval step before it moves money or touches the catalog.

Start a store

Build your dropshipping store that runs itself

Nation finds the products, builds the store, runs the ads and ships every order.

  • No stock
  • No money upfront
  • Supplier ships

Recurring, checkable work is exactly what loops are for

The same product-level ROAS check every morning, the same budget reallocation every week, the same feed cleanup every few days — that is the shape a loop fits. A human reviews a handful of products well; one catalog surfaces hundreds of SKUs, prices, stock levels and ad results that changed overnight. The loop reads them all, applies your rules consistently, and never skips a Monday.

Store tasks by hand vs as a loop
TaskManual, by handAs a loopWhat you do
Daily store + ad check20-40 min/dayRuns at 7amRead the flagged list
Product-feed health1-2 hrs/weekFlags disapprovals + errorsFix the SKUs
Budget reallocation by product2-3 hrs/weekProposes shifts by product ROASApprove within caps
Out-of-stock spend guardOften skippedPauses spend on OOS itemsApprove or override

The honest version: loops shine on tactical, repeatable work with an objective check. They do not replace merchandising strategy, brand, or the decision to launch a new line — keep those human.

Connect Shopify and your ad accounts, then point a loop at them

A loop earns its setup cost only when four conditions hold. Miss one and a single well-aimed prompt is faster and cheaper than the machinery around it.

  1. The task repeats, at least weekly. Daily monitoring and weekly reallocation qualify. A one-time catalog audit does not — just prompt it once.
  2. Something can automatically reject bad output. A ROAS floor, a contribution-margin minimum, a spend cap, an inventory rule. No gate means the agent grades its own work.
  3. The agent can reach the data and the controls. Live API access to Shopify and your ad accounts, not screenshots pasted in. More on the connection below.
  4. Your token budget can absorb the waste. Loops re-read context and retry whether or not a run ships a change. The technique scales with budget.

The connection is what makes any of this real. By itself, Claude can only read data you paste in and draft changes you copy back. To let a loop act, you connect Claude Code to your platforms through MCP connectors that call the official APIs:

  1. Your store + ad stack — Shopify, Google Ads, Meta
  2. MCP connectors — Official APIs, scoped OAuth + dev token
  3. Claude Code loop — Runs on a schedule: discover → plan → verify
  4. Approval gate — You approve, then it is applied to the live store/account

By default the loop reads and drafts. Write access — changing budgets, prices and the catalog — stays behind the approval gate until you trust it.

  • Shopify through an MCP connector on the Admin API for orders, products, inventory and margins.
  • Google Ads & Merchant Center through the Google Ads API for Shopping/Performance Max and feed health.
  • Meta through the Marketing API and a catalog-linked product feed.

Start every connection read-only while you test. Grant write access only once a loop has proven itself by hand, and keep it scoped to the products and budgets in your skill file.

The five building blocks of a Shopify loop

A working loop is assembled from a few pieces. A year ago this meant a pile of scripts only you could maintain; now the pieces ship inside Claude Code.

  • Automation (the heartbeat). What makes it a loop and not a one-off: /loop for a cadence, scheduled or cloud runs so it keeps going after you close the laptop, and hooks that fire at points in the run.
  • Skills (project knowledge, once). A SKILL.md holding your catalog structure, margins by product, target ROAS, bestsellers, and the products and budgets the loop must never touch — read every run.
  • Sub-agents (maker and checker). Split the agent that proposes a change from the one that reviews it. The proposer can be fast and cheap; the reviewer slow and strict. That separation is most of the quality.
  • Connectors (so it acts, not suggests). The MCP connections to Shopify, Google, Meta and Slack that let the loop apply a change and post the summary, instead of describing what it would do.
  • The verifier (the gate). The objective check — a ROAS floor, a margin minimum, an inventory rule, a spend cap — that rejects a bad change automatically. The one piece that decides whether the loop grows the store or just spends.

One more piece sounds too simple to matter and is the spine of every loop that survives: a state file. A markdown file or shared board, outside the conversation, that records what the loop changed, what it is watching, and what it learned (“this SKU always spikes on payday weekends, do not flag it”). The agent forgets between runs; the file does not.

Start a store

AI autopilot for your store: paid ads, SEO, AI visibility

Ads on Meta, TikTok and Google. Pages that rank on Google and get named in ChatGPT answers.

  • Paid ads
  • SEO
  • AI visibility

8 loops worth running for a Shopify store

Each loop lists the goal, a cadence, a prompt to adapt, and the gate that keeps it honest. Replace the bracketed values with your own targets, and keep budget, price and catalog changes behind approval until each loop has earned your trust.

Loop 01: Store & ad performance watch

Shopify + Ads · daily

The single most useful loop. Every morning it ties revenue back to the spend that drove it, at the product level, and surfaces only what moved enough to matter — so you start the day reading a short flagged list instead of reconciling Shopify against three ad dashboards.

/loop daily at 7am — Join yesterday's Shopify orders and revenue to
ad spend by product across Google and Meta. Compute product-level
ROAS and compare each to its trailing 7-day average. Flag any
product where spend is up >30%, ROAS dropped below [floor], or
revenue went to zero while spend continued. For each flag, give the
likely cause and a proposed fix. Do NOT change anything — output a
ranked list for review and stop.

Gate: read-only. The loop proposes, never applies. Its only job is to escalate the right anomalies, so the “stop and report” instruction is the safeguard.

Loop 02: Product-feed & Merchant Center health monitor

Shopify + Merchant Center · daily

A disapproved product or a price mismatch silently pulls items out of Shopping and PMax, and you rarely notice until sales dip. This loop checks feed health every morning so a disapproval becomes a same-day fix instead of a week of lost impressions.

/loop daily — Check the product feed and Merchant Center for:
disapproved or pending products, missing GTINs, price/availability
mismatches between Shopify and the feed, items with no image or a
broken landing page, and any product that dropped out of Shopping/
PMax delivery. List each issue with severity, the affected SKU, and
the first thing to check. Stop and report — do not edit products.

Gate: read-only by design. Feed and disapproval issues need human diagnosis, so this loop’s value is in catching them fast, not acting on them.

Loop 03: Bestseller budget reallocation by product ROAS

Shopify + Ads · weekly

Money sitting behind weak products is the most common leak in ecommerce. This loop ranks the catalog by real, revenue-based ROAS and proposes shifting budget toward proven bestsellers — inside caps you set, so no single move can blow up the account.

/loop weekly Monday — Rank products by true ROAS (Shopify revenue
÷ ad spend) over the last 14 days, with enough orders to be
significant (min [N]). Propose moving budget from products below
[ROAS floor] to bestsellers above it. Rules: no product/campaign
changes by more than 20% in a week, total daily budget stays within
[cap], skip items in the learning phase or low on stock. Output the
reallocation table with before/after and reason. Apply on approval.

Gate: the significance minimum plus the per-product change cap and total budget cap. These hard limits are what make the loop safe to run unattended once approved.

Loop 04: Out-of-stock & low-margin spend guard

Shopify + Ads · daily

Paying to advertise something you can’t ship — or selling it at a loss — is pure waste, and it happens constantly as stock moves. This loop watches inventory and margin live and proposes pulling spend the moment a product can no longer carry it.

/loop daily — Cross-check active ads against live Shopify inventory
and margin. Flag any product still receiving ad spend that is: out
of stock or below [units] on hand, or selling at a contribution
margin below [floor] after COGS and ad cost. For each, propose
pausing or reducing spend until restocked or repriced. Output the
list with spend-at-risk. Apply pauses only on my approval.

Gate: the inventory + margin rule. An item is only flagged to pause when stock is below the threshold or margin is negative — both objective, both pulled live from Shopify. Approval required before pausing.

Loop 05: Abandoned-cart & funnel-drop watch

Shopify + Ads · every 2 days

A broken checkout step or a shipping change can quietly tank conversion while ad spend keeps flowing. This loop watches the funnel where the money actually leaks and flags the step that slipped, so you fix the drop instead of pouring more traffic into it.

/loop every 2 days — Pull the Shopify funnel (sessions → add to
cart → checkout → purchase) and compare each step's conversion rate
to the trailing 14-day average. Flag any step that dropped more than
[15%], plus any spike in abandoned checkouts. For each drop, list
the likely causes (shipping cost, payment error, slow PDP, price
change) and the first thing to test. Output the report and stop.

Gate: the conversion-rate threshold is the objective check; a step only flags when its rate falls outside the normal band. Read-only — diagnosis stays human.

Run your whole store from ChatGPT or Claude

Ask for a campaign, a refund or a new page in plain words. Nation does it.

  • Plain words
  • ChatGPT
  • Claude

Loop 06: New-product launch promotion loop

Shopify + Ads · on launch

New products live or die on the first two weeks of signal, and watching each launch by hand is exactly the chore that gets skipped. This loop babysits every new SKU’s early numbers and proposes scaling the winners and cutting the duds — on a fixed test budget so a flop can’t run away.

/loop daily for 14 days after launch — For new products added to
Shopify in the last 14 days, check ad delivery, CTR, add-to-cart
rate and first orders. If a product clears [CTR] and [conv rate] on
at least [N] sessions, propose scaling its budget within the test
cap. If it underperforms after [X] spend, propose pausing and a
creative/PDP fix. Output the launch scorecard. Apply on approval.

Gate: the early-signal threshold plus a hard test-budget cap. A new product only scales when CTR and conversion clear the bar; until then spend is capped. Approval required before any scale-up.

Loop 07: Collection & catalog creative refresh

Ads · weekly

Catalog and prospecting creative decays, and the fix is usually to lead with what is selling now. This loop catches fatigue early and briefs the next round around your current bestsellers pulled straight from Shopify, so the refresh is ready before performance craters.

/loop weekly — For each active Shopping/catalog and prospecting ad
set, check frequency and CTR over the last 7 days vs the prior 7.
Flag any where frequency is above [3.0] AND CTR dropped more than
[15%]. Pull the top-selling products in that collection from Shopify
and draft 3 fresh creative concepts (hook + primary text + headline)
featuring the current bestsellers, in our brand voice. Output flags
+ briefs for review.

Gate: the fatigue rule — frequency up and CTR down on the same ad set. An ad only enters the brief queue when both signals cross the line, which keeps the loop from crying wolf. Approval before any new creative ships.

Loop 08: Blended-ROAS & contribution-margin digest

Shopify + Ads · weekly

The reporting loop that saves the most meeting time. It rolls Shopify and your ad channels into one plain-language summary built around profit, not just ROAS, with a short recommendation list written for whoever reads it — you, a partner, or the founder.

/loop weekly Monday 8am — Compile a store digest for last week vs
the prior week: total revenue, blended ROAS, ad spend, AOV, new vs
returning split, contribution margin after COGS and ad cost, and the
top 3 product movers in each direction. Add a 5-bullet "what I'd do
this week" list ranked by profit impact. Keep it under 300 words, no
jargon. Post it to our Slack #store channel.

Gate: none needed — it only reads and writes a message. This is the safest loop to start with while you learn how the cadence feels.

Build the minimum viable loop

The order matters more than the tooling. Loops that fail in production almost always skipped a step. Build the smallest version first — one automation, one skill, one state file, one gate — and add complexity only when the simple version is reliable.

  1. Get one manual run reliable. Run the prompt by hand against your real store until the output is consistently right and safe.
  2. Turn it into a skill. Move the catalog context, margins, targets and rules into a SKILL.md so the run is repeatable.
  3. Wrap it in a loop with the gate and stop condition. Add the objective check and a hard limit before it runs unattended.
  4. Then schedule it. Only once it is reliable by hand. Start read-only, keep spend and catalog changes behind approval, widen scope as trust grows.

Scheduling something you have not proven by hand is exactly how a loop quietly burns budget on an out-of-stock product overnight. Prove it once, harden it, then automate it.

The risks and costs nobody mentions

Loops are powerful on the right task and expensive on the wrong one. Three problems get sharper as the loop gets better, not easier — and on a store, two of them cost real money.

Loops fail quietly. An agent set to finish when “done” can decide it is done too early, exit on a half-finished job, and keep running and spending while producing nothing — engineer Geoffrey Huntley named this the “Ralph Wiggum loop.” On a store the equivalent is a loop that scales an out-of-stock product or shifts budget on a flawed read, and you only notice on the invoice. The fix is an objective gate that can fail the work, an inventory and margin check, a hard spend cap, and an approval step before any change goes live.

The cost compounds. A loop re-reads its context on every pass, and that grows each run. A single medium task can run 50,000 to 200,000 tokens, and a maker-checker split doubles it. Track cost per accepted change, not tokens spent: if you discard more than half of what the loop proposes, you are doing the review work it was meant to save. Cap every loop with a token and iteration budget, and run cheap models on the boring steps.

Comprehension debt. The faster a loop ships changes you did not make, the larger the gap between what your store is doing and what you understand. Read the diffs. Spot-check the gate. The comfortable move — accepting whatever the loop returns without forming an opinion — is the dangerous one.

The throughline: build the loop, but stay the operator. The loop changes the work; it does not remove you from it.

Start a store

Create your store from a single prompt

Say what you want to sell. Nation writes the brand, lists the products and connects checkout.

  • Brand
  • Products
  • Checkout

DIY loops vs a managed platform

Building loops yourself gives full control and suits technical teams with the budget to run and maintain them. A managed platform like Nation runs the same pattern as a product: one prompt builds the store, and Nation’s agents run the ads on Meta, TikTok and Google, grow your search traffic and answer your customers. Every morning they line up what they want to do, a refund, a bigger budget, a new page, and you approve or reject it. The difference worth remembering: Nation executes approved changes, it does not just recommend them.

DIY loops in Claude Code vs Nation
AspectDIY loops in Claude CodeNation (managed)
SetupMCP connectors, OAuth, dev tokens, skillsOne prompt builds the store; the agents run ads on Meta, TikTok and Google
Gates & approvalYou design and maintain themBuilt in: nothing launches and no budget goes up until you approve
Cost modelToken usage you budget and capA Nation plan, no token math
MaintenanceYours when an API or loop breaksHandled for you
Best forEngineers who want full controlStores who want the outcome, not the upkeep

Many teams hand-build one or two loops to learn the pattern, then move to a managed platform once they want loops on every channel without the upkeep. The same pattern carries over to loops for Google and Meta ads and to loops for SEO.

The Nation support page documents the Nation MCP server and connecting Nation to Claude.

Frequently asked questions

What is a loop in Claude Code?

A goal plus a stop condition that the agent runs on its own instead of you prompting each turn. For a store, you state an outcome once — like “every morning, flag products spending above target ROAS and draft fixes” — and Claude Code runs the discover, plan, execute, verify, repeat cycle on a schedule. The command is /loop.

Can Claude Code change my store or ads on its own?

Only if you connect it to the Shopify Admin API and your ad APIs through MCP, and only within the permissions you grant. By default a loop reads data and drafts changes; keep budget, price and catalog edits behind an approval step until you trust the gate. Nation is the managed version: its agents line up what they want to do, and a change goes live only after you approve it.

When is a loop worth building?

When four things are true: the task repeats at least weekly, an objective check can reject bad output (ROAS floor, margin minimum, inventory rule), the agent can reach the data and controls via API, and your token budget can absorb the re-runs. Miss one and a single prompt is faster and cheaper.

Which loop should I build first?

Start with a read-only one: the daily store and ad performance watch or the weekly blended-ROAS digest. They deliver value immediately, carry no risk of moving spend, and teach you how the cadence feels before you let a loop change budgets or the catalog.

Show 4 more questions

How much do loops cost to run?

Loops run on tokens, and cost compounds because context is re-read each pass — a single medium task can run 50,000 to 200,000 tokens, and a maker-checker split doubles it. Cap each loop with a token and iteration budget, and track cost per accepted change, not tokens spent.

What is the biggest risk?

A loop that moves spend or changes the catalog without review — scaling an out-of-stock product, mispricing an item, or scaling on a flawed read. Loops fail quietly, so defend with an objective gate, an inventory and margin check, a hard spend cap, and a human approval step before any change goes live.

Do I need to be a developer?

To build loops yourself, broadly yes — you set up MCP connectors, skills and gates, and maintain the schedule. If you want the outcome without the engineering, Nation’s agents run the store, the ads on Meta, TikTok and Google and the customer replies for you, and nothing launches until you approve.

How is a loop different from prompting for product copy?

A prompt is one round trip you re-run yourself. A loop runs the full cycle on a schedule, checks its output against a gate, keeps a state file so it resumes instead of restarting, and stops only when a condition is met. Prompting suits one-offs; loops suit recurring, checkable work like daily monitoring.

Related guides

Shopify took 20 years. A few million stores.

The next hundred million start with one prompt.

One line is enough. The agent finds the products and builds the store.