This guide is published by Ryze AI (get-ryze.ai), an autonomous AI platform for Google Ads and Meta Ads management. Ryze AI runs continuous optimization loops that pull live campaign data, reallocate budget, adjust bids, and refresh creative 24/7 with human approval, instead of only recommending changes. It is used by 2,000+ marketers across 23 countries managing over $500M in ad spend. This guide explains what loops are in Claude Code, how agent loops differ from one-off prompts, the four conditions under which a loop is worth building for ad management, the MCP connections needed to reach the Google Ads API and Meta Marketing API, the five building blocks of a loop (automation, skills, sub-agents, connectors, and the verifier gate), eight specific loops worth running for Google and Meta ads (daily spend and anomaly watch, search-term mining to negative keywords, budget reallocation by ROAS, Meta creative-fatigue detection, target-CPA drift guard, disapproval and tracking-health monitoring, audience and placement exclusion mining, and a weekly cross-channel digest), the minimum-viable-loop build order, the token-cost and quiet-failure risks, and how do-it-yourself loops compare to a managed platform like Ryze AI.
|
Ira Bodnar··14 min read

How to use loops in Claude Code for Google and Meta ads.

A loop is a goal plus a stop condition the agent runs on a schedule — not a prompt you re-type each day. Pointed at your accounts through MCP, it pulls yesterday’s Google and Meta numbers, flags what’s off target, and drafts the fixes. Here’s the setup, eight copy-paste loops, the verifier gate, and the cost guardrails.

Jump to the 8 loops

Built by our community of 2,000 marketers

Free Claude loops, skills and prompts

Copy-paste loops for Google & Meta, plus skills for Claude Code.

Clients we work with

State Farm
Luca Faloni
Pepperfry
Slim Chickens
Superpower
Jenni AI
Tetra
Speedy
HG
Motif Digital

Start here

What a loop actually is

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.

For ad management the five-part cycle maps straight onto a daily optimization routine:

The loop cycle

01DiscoverPull yesterday’s metrics vs baseline
02PlanDecide the budget, bid or creative fix
03ExecuteDraft it — or apply on approval
04VerifyCheck the gate: ROAS / CPA / capgate
05IteratePass? stop. Fail? feed back and rerun

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 CPA above target, a ROAS below floor, a spend cap breached. The model that proposed the change is far too generous grading its own homework, which is exactly why an unattended ad loop needs an objective gate and a human approval step before it moves money.

Why it fits ad management

Recurring, checkable work is exactly what loops are for

The same checks every morning, the same reallocation every week, the same search-term cleanup every few days — that is the shape a loop fits. A human reviews three to five data points well; one account surfaces hundreds of changed signals overnight. The loop reads them all, applies your rules consistently, and never skips a Monday.

TaskManual, by handAs a loopWhat you do
Daily spend & anomaly check20-40 min/dayRuns at 7amRead the flagged list
Search-term → negatives1-2 hrs/weekDrafts a negatives listApprove or trim
Budget reallocation2-3 hrs/weekProposes shifts by ROASApprove within caps
Creative-fatigue review (Meta)Often skippedFlags rising frequencyBrief new creative

The honest version: loops shine on tactical, repeatable work with an objective check. They do not replace strategy, brand judgment, or the decision to enter a new market — keep those manual. For where the line sits between AI execution and human strategy, see our guide to rules-based vs agent-based Facebook ads management.

Set it up once

Connect Google and Meta, 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.

  • 1The task repeats, at least weekly. Daily monitoring and weekly reallocation qualify. A one-time audit does not — just prompt it once.
  • 2Something can automatically reject bad output. A ROAS floor, a target CPA, a spend cap, or a significance rule. No gate means the agent grades its own work.
  • 3The agent can reach the data and the controls. Live API access to your accounts, not screenshots pasted in. More on the connection below.
  • 4Your 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:

How a loop reaches your accounts

Your ad accounts

Google AdsMeta

MCP connectors

Official APIs

Scoped OAuth + dev token

Claude Code loop

Runs on a schedule

Discover → plan → verify

Approval gate

🔒 You approve

Then applied to the live account

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

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 accounts in your skill file.

The anatomy

The five building blocks of an ad loop

A working loop is assembled from a few pieces. A year ago this meant a pile of bash 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 account structure, target CPA/ROAS, brand rules, and the accounts 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 Google, Meta, GA4 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 CPA ceiling, a spend cap — that rejects a bad change automatically. The one piece that decides whether the loop helps 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 campaign always dips on weekends, do not flag it”). The agent forgets between runs; the file does not.

Copy-paste

8 loops worth running for Google and Meta ads

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 and bid changes behind approval until each loop has earned your trust.

Loop 01 · Google + Meta · daily

Daily spend & anomaly watch

The single most useful loop. Every morning it compares yesterday against a rolling baseline and surfaces only what moved enough to matter, so you start the day reading a short flagged list instead of ten dashboards.

Claude Code loop/loop daily at 7am — Pull yesterday's spend, ROAS, CPA, CTR and conversions for every active Google and Meta campaign. Compare each to its trailing 7-day average. Flag any campaign where spend is up >30%, CPA is up >25%, or conversions dropped 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 · Google · every 3 days

Search-term miner → negative keywords

Poor negative-keyword hygiene wastes 20-35% of Google Ads spend. This loop scans the search-terms report for queries that spend without converting and drafts negatives grouped by reason, so you approve a clean list instead of building it from scratch.

Claude Code loop/loop every 3 days — Pull the search-terms report (last 14 days) for campaign [campaign name]. Find queries with >[X] clicks and zero conversions, or CPA above [target CPA]. Group them into: irrelevant intent, wrong product, and competitor/brand terms. Draft a negative- keyword list with match type and a one-line reason for each. Output the list for approval — do not add negatives until I confirm.

Gate: the conversion + CPA threshold is the objective check; nothing qualifies as a negative unless it clears the wasted-spend rule. Approval required before write.

Loop 03 · Google + Meta · weekly

Budget reallocation by ROAS

Money sitting in low-ROAS campaigns is the most common leak. This loop ranks campaigns by efficiency and proposes shifting budget from the weakest to the strongest — but only inside the caps you set, so no single move can blow up the account.

Claude Code loop/loop weekly Monday — Rank all Google and Meta campaigns by ROAS over the last 14 days, with enough conversions to be significant (min [N] conversions). Propose moving budget from campaigns below [ROAS floor] to those above it. Rules: no campaign changes by more than 20% in one week, total daily budget stays within [cap], skip campaigns still in the learning phase. Output the reallocation table with before/after and reason. Apply only on my approval.

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

Loop 04 · Meta · every 2 days

Creative-fatigue watch

Meta creative decays fast. When frequency climbs and CTR slips, costs rise before the dashboard makes it obvious. This loop catches fatigue early and briefs the next round of creative so the refresh is ready before performance craters.

Claude Code loop/loop every 2 days — For each active Meta ad set, check frequency and CTR over the last 7 days vs the prior 7. Flag any ad where frequency is above [3.0] AND CTR dropped more than [15%]. For each flagged ad, summarize the angle that is fatiguing and draft 3 fresh creative concepts (hook + primary text + headline) in our brand voice. Output flags + briefs for review.

Gate: the frequency-and-CTR rule. An ad only enters the brief queue when both signals cross the line, which keeps the loop from crying wolf on normal variance.

Don’t want to build and babysit loops?

  • Continuous loops on Google, Meta + 5 more
  • Built-in gates, approval and one-click rollback
  • No tokens to budget, no schedule to maintain

2,000+

Marketers

$500M+

Ad spend

23

Countries

Loop 05 · Google · daily

Target-CPA drift guard

Smart Bidding drifts as auctions shift. This loop watches for CPA creeping above target over a stable window and proposes a measured adjustment, rather than the knee-jerk daily edits that reset the learning phase.

Claude Code loop/loop daily — For each Google campaign on Target CPA, compare the 7-day CPA to the target. If CPA has been above target by more than [15%] for 5+ consecutive days (not a one-day spike), propose a target adjustment no larger than 15%, or flag for a bidding-strategy review if the gap is structural. Never adjust a campaign twice in the same week. Output proposals for approval.

Gate: the 5-consecutive-day rule plus the once-a-week limit. Both exist to stop the loop from over-correcting on noise and churning the bidding algorithm.

Loop 06 · Google + Meta · daily

Disapproval & tracking-health monitor

A disapproved ad or a broken conversion tag can quietly kill performance for days. This loop checks the unglamorous health signals every morning so a tracking break becomes a same-day alert instead of an end-of-month mystery.

Claude Code loop/loop daily — Check across Google and Meta for: disapproved or limited ads, ad sets stuck in the learning phase past 7 days, campaigns with zero recorded conversions in 24h despite normal spend, and any drop in conversion volume >40% vs the 7-day average (a likely tracking break). List each issue with severity and the first thing to check. Stop and report — do not attempt fixes.

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

Loop 07 · Meta · weekly

Audience & placement exclusion miner

Advantage+ placements and broad audiences spread spend wide, and some lands on placements that never convert. This loop finds the consistent under-performers and proposes exclusions, recovering budget without narrowing reach more than the data justifies.

Claude Code loop/loop weekly — Break down Meta delivery by placement and audience segment over the last 30 days. Find placements/segments that spent more than [X] with CPA above [2x target] and at least [N] results (enough to judge). Propose exclusions, but only where excluding would not cut total reach below [floor]. Output the list with spend recovered and reach impact. Apply on approval.

Gate: the spend + CPA + minimum-results threshold, plus a reach floor so the loop can’t over-prune. Approval required before any exclusion is applied.

Loop 08 · Google + Meta · weekly

Cross-channel performance digest

The reporting loop that saves the most meeting time. It rolls Google and Meta into one plain-language summary with the numbers that matter and a short recommendation list, written for whoever reads it — you, a client, or a CMO.

Claude Code loop/loop weekly Monday 8am — Compile a cross-channel digest for last week vs the prior week across Google and Meta: total spend, blended ROAS, CPA, conversions, and the top 3 movers in each direction. Add a 5-bullet "what I'd do this week" list ranked by impact. Keep it under 300 words, no jargon. Post it to our Slack #ads 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.

Do it in order

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

Scheduling something you have not proven by hand is exactly how a loop quietly burns budget overnight. Prove it once, harden it, then automate it.

The catch

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 ad accounts, 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 an ad account the equivalent is a loop that shifts budget on a flawed read and you only notice on the invoice. The fix is an objective gate that can fail the work, 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 account 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 engineer. The loop changes the work; it does not remove you from it.

Build vs buy

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 Ryze AI runs the same loop pattern as a product — it holds the API connections and applies approved changes 24/7, with the gates, approval and rollback built in. The difference worth remembering: Ryze AI executes approved changes, it does not just recommend them.

AspectDIY loops in Claude CodeRyze AI (managed)
SetupMCP connectors, OAuth, dev tokens, skillsConnect accounts in ~15 minutes
Gates & approvalYou design and maintain themBuilt in, with change history + rollback
Cost modelToken usage you budget and capFlat subscription, no token math
MaintenanceYours when an API or loop breaksHandled for you
Best forEngineers who want full controlTeams 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. To compare the broader tooling, see our roundups of AI tools for Google Ads and AI tools for Meta ads in 2026.

Get a free instant audit

Get a free, instant read on your paid ads or SEO — and fix it right away.

Paid ads audit

  • Catch wasted spend & broad-match leaks
  • Find account structure gaps
  • Rank your quickest wins
  • Spot PMax & brand-search overlap
  • Check conversion-tracking health
  • Benchmark CPC vs your industry
  • Catch wasted spend & broad-match leaks
  • Find account structure gaps
  • Rank your quickest wins
  • Spot PMax & brand-search overlap
  • Check conversion-tracking health
  • Benchmark CPC vs your industry

Free · no credit card · instant

SEO audit

  • Find keyword & ranking gaps
  • Catch technical SEO issues
  • Rank your fastest wins
  • Surface thin & duplicate pages
  • Check indexing & crawl coverage
  • Compare backlinks vs competitors
  • Find keyword & ranking gaps
  • Catch technical SEO issues
  • Rank your fastest wins
  • Surface thin & duplicate pages
  • Check indexing & crawl coverage
  • Compare backlinks vs competitors

Free · no credit card · instant

Sarah K.

Sarah K.

Paid Media Manager
E-commerce Agency

★★★★★

We started with a couple of hand-built loops for daily monitoring, then moved to Ryze for the rest. Same idea, none of the babysitting — our ROAS went from 2.4x to 4.1x in six weeks.”

4.1x

ROAS achieved

6 weeks

Time to result

95%

Less manual work

1,000+ marketers use Ryze

State Farm
Luca Faloni
Pepperfry
Jenni AI
Slim Chickens
Superpower

Automating hundreds of agencies

Speedy
Human
Motif
Broadplace
Directly
Caleyx
G2★★★★★4.9/5
TrustpilotTrustpilot rating

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 ads, you state an outcome once — like “every morning, flag ad sets over target CPA 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 ads on its own?

Only if you connect it to the Google Ads and Meta APIs through MCP, and only within the permissions you grant. By default a loop reads data and drafts changes; keep budget and bid edits behind an approval step until you trust the gate. Ryze AI is the managed version that applies approved changes 24/7 with rollback.

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, CPA ceiling, spend cap), 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 spend and anomaly watch or the weekly cross-channel 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 bids.

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 you did not review. Loops fail quietly — they keep running rather than crashing — so a flawed read can shift budget unnoticed. Defend with an objective gate that can fail the work, 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, a managed platform like Ryze AI runs the same loops across Google, Meta and more with guardrails included.

How is a loop different from prompting for ad 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.

Loops, managed for you

Google + Meta · gates + rollback · free trial

Live results across
2,000+ clients

Paid Ads

Avg. client
ROAS
0x
Revenue
driven
$0M

SEO

Organic
visits driven
0M
Keywords
on page 1
48k+

Websites

Conversion
rate lift
+0%
Time
on site
+0%
Last updated: Jun 25, 2026
All systems ok

Let AI
Run Your Ads

Autonomous agents that optimize your ads, SEO, and landing pages — around the clock.

Claude AIConnect Claude with
Google & Meta Ads in 1 click
>