← index

25 Jul 2026 · 17 min · english

How I automated Meta Ads

A team of four Claude Code agents that analyses an ad account, produces the creatives and uploads them paused, with me at every gate that costs money.

One of the most interesting projects I worked on lately was a system that let a client automate their Meta Ads account end-to-end: performance analysis, idea generation, creative production, and rotation of the ads that stop pulling their weight.

The system runs on Claude Code, integrated with Meta Ads and Higgsfield for creative generation, but it could be built with any combination of tools. The nice part is that it can change and evolve over time, both in what it can do and which tools it uses.

The core

The core of the system is Claude, specifically Claude Code. The difference between the two products has nothing to do with coding, as most people think.

Claude (chat) is perfect for daily tasks that at most need access to a few tools like Gmail, Calendar, Notion and so on. It does that pretty well, but it is missing a few things Code does really well, the most important being:

  • consistent, repeatable context: I need a tool that repeats the same behavior every time without drifting
  • access to local applications: I need to use applications on my laptop. I could use Cowork instead, but for the steps that follow it would not be ideal
  • access to files on the machine: tied to the point above, I need to read and write files constantly to keep Claude's context updated and let it remember what it did and thought, without losing the thread
  • solid GitHub integration: repositories are basically projects that live in the cloud; connecting Claude to one gives it persistent memory I can reach from any machine, any time

I recommend the Claude desktop app, on a base subscription. You can start free; at least during development I recommend the latest Opus model, to write consistent and durable rules. For the execution phase, Sonnet-class models are enough.

A team of agents

Agents are what turn a simple set of instructions into a system that can make smart decisions on its own, while still staying supervised.

Put simply, an agent is an AI employee instructed to do one specific task, with clear boundaries: a fixed input and a defined output. I could have built this as one big agent that does everything, and that would probably have worked too, but splitting into smaller agents keeps every output consistent and focused. When you work with AI, always prefer small, goal-oriented tasks coordinated by an orchestrator, rather than one agent trying to hold the whole job in its head.

In my system the orchestrator is a single instructions file Claude reads at the start of every session on this project. It is the only "voice" I actually talk to: behind the scenes it delegates to four agents in sequence, but what reaches me is always the clean result, in plain language. The four agents never talk to each other directly, they hand off through files, and there is always a decision that only I can make between one and the next:

  1. The Analyst finds what is underperforming and drafts a plan.
  2. The Ideator turns the plan into a short list of creative angles.
  3. The Designer turns approved angles into finished creatives.
  4. The Publisher uploads everything paused, and only goes live on my word.

Here is each one in detail.

Who decides what

One principle runs through all four agents and is worth naming before the details: code decides what is measurable, Claude decides what needs judgment, I decide anything that touches money or the brand. Ranking ads, checking thresholds, refusing to publish anything except paused: that is code, deterministic, not up for negotiation. Reading a photo to check the product is recognizable, or judging whether a creative angle fits the brand: that is Claude's call, using its own perception. Approving a plan, approving a batch of creatives, pushing something live: that is always me, at a small, fixed number of checkpoints. Getting this split right, not "let it do everything" and not "approve every click" either, is most of what building something like this actually is.

Agent 1: the Analyst

The goal is not just a system that reads and writes on my Meta Ads account, but one that learns from itself, improves the account's performance and builds knowledge over time. To do that I taught Claude my campaign evaluation framework. This is the part that makes an account stand out: my business and marketing knowledge combined with Claude's ability to grind through data every week. There is no one-size-fits-all answer here, and Meta changes its tools and algorithms often enough that the best framework for you will always be the one you design yourself.

For this guide, and as a good starting point that works well today, here is how I built my analysis and evaluation process, with the prompt to implement it.

Once a week Claude opens the account, measures every active ad, ranks them inside their ad set, and tells me which ones deserve to be replaced. One thing before the details: the framework does not care what my campaigns are chasing. Every campaign already declares its own goal (leads, purchases, clicks, reach), and the system just reads it and treats it as the definition of a "result". A lead campaign is judged on cost per lead, a traffic campaign on cost per click, an awareness one on the cost of being seen. Same reasoning, different currency. With that in place, the framework stands on three legs:

  • A clear perimeter. I only judge what is actually running, and only compare like with like. Ranking happens inside each ad set, and every ad in an ad set chases the same goal, so an ad built for clicks is never measured against one built for purchases. Paused campaigns and archived ads stay out of the picture: they are history, not signal.
  • A fair measurement. Two time windows (a longer one to judge, a shorter one to catch fatigue early), a cost per result adjusted for volume so luck does not look like talent, and the discipline to skip ads that have not produced enough data to be judged yet. Most bad automation comes from skipping this last part. Notice what is missing: budget. An ad is never judged by how much it spends, only by what that spend buys.
  • Clear reasons to act. An ad gets flagged for one of three reasons only: it costs far more per result than its siblings, it spends without producing the result it exists for, or the audience is simply tired of seeing it. None of these depends on what the result is. Everything else keeps running undisturbed.

Every run ends with a written report, saved to a ledger the system keeps across cycles. That is not bureaucracy: it is the memory the next agent, and the next run, will build on. One thing never changes though: the final call on what goes live stays with me.

"You are the analyst of my Meta Ads account, and your job is to tell me which ads deserve to keep running and which ones should be replaced. Work only on what is active: campaigns, their active ad sets, their active ads. Everything paused or archived is history, not signal.

Before judging anything, read each campaign's objective and treat it as the definition of a result: a lead, a purchase, a click, a thousand impressions. That is the only currency you will judge its ads in. Never compare ads that chase different results, and never judge an ad by how much it spends: only by what that spend buys.

Judge every ad on the last 30 days, because an ad needs time to prove itself. But also keep an eye on the last 7, to spot the ones that are starting to tire before they become a problem.

When you rank the ads inside an ad set, use cost per result, adjusted for volume: an ad with two lucky results is not a star, it is just early. For the same reason, if an ad has not spent or produced enough to be judged fairly, leave it out of the ranking instead of guessing.

Recommend replacing an ad only when there is a clear reason to. Maybe it costs far more per result than the best ad in its group. Maybe it keeps spending without producing the result it exists for. Or maybe people have simply seen it too many times and stopped clicking. One good reason is enough, vague feelings are not.

Every time you run, save your analysis and your reasoning to a report file, so I can review it and you can compare it with past runs and learn.

One hard rule to close: budgets and targeting are mine. You analyze, you propose, I decide."

As you might have guessed by now, campaign structure, goals, targeting, audiences and budgets stay in my hands. Not because Claude could not touch them, but because whoever manages the account is the one with the full business context to structure them well. This agent exists to run continuous, autonomous improvement on top of what is already built.

The system memory

When you work on something that needs constant iteration to perform well, like a Meta Ads account, accumulated experience is the whole game: what worked before, in which market, in which season, for which audience. That is what makes a paid social account perform, and it is where a good performance marketer earns their keep. So how do you get Claude to hold onto that?

Two different kinds of files, and the split matters. One kind I maintain by hand, because it encodes decisions only I can make. The other kind the system maintains for itself, because it is just the record of what already happened.

What I feed it by hand:

  • A brand brief: who I am, what I sell, to whom, the tone I want, the visual identity. The first thing every agent reads, and what keeps the output from sounding like every other AI-written ad on the platform.
  • An offers file: the single source of truth for anything factual that ends up in an ad. Prices, conditions, deadlines, one file, nothing else. Every number in a creative is required to trace back to this file; if it is not there, the system asks instead of guessing.
  • Competitor notes: what I am seeing in the market, used as inspiration, never treated as proof that something will work for me too.

What the system keeps for itself:

  • A ledger of flagged ads, so a weak performer does not have to be rediscovered from scratch every week.
  • A log of every creative idea ever proposed, with its status, so nothing gets pitched twice and nothing good gets forgotten while waiting for the right season.
  • A ledger of everything uploaded, which doubles as duplicate protection: the system will not quietly recreate a creative that already exists.
  • A record of every swap: what replaced what, when, and how it turned out, which is what eventually lets the system tell me a challenger has actually proven itself and is not just on a lucky streak.

Notice one thing about all of it: it lives in a GitHub repo, not inside a chat session that expires. That is the quiet trick of the whole system. The memory is versioned, I can read it myself at any time, and it is available from any machine. The agents read it at the start of every run and update it at the end, which is what makes each cycle a little smarter than the one before it. (In my repo these live in two folders: one for what I maintain by hand, one for what the system writes on its own, kept strictly separate so I always know which files are safe to hand-edit.)

Agent 2: the Ideator

With a plan in hand, the second agent turns it into ideas. It reads the same context files as the analyst, plus everything flagged for replacement, and proposes a short list, two or three general creative angles, never one idea per weak ad. Keeping the list short matters: the test budget is small, and the angle that wins gets adapted to every region and audience afterwards, so it is worth spending the judgment upfront rather than spraying variations.

Ideas do not come from thin air. Before proposing anything, this agent does a quick round of research on current creative trends, from sources I trust, and logs where each observation came from. That log matters more than it sounds: without it, "trend research" quietly turns into the model repeating whatever it half-remembers from training. And sometimes the best idea is not a new AI-generated angle at all: real customer photos, a genuine testimonial, a believable before/after often beat a polished AI creative outright, so this agent knows to propose using real content when the evidence points that way, instead of defaulting to generating something new.

"Read my business context, offers, past learnings and the log of ideas already tried. For each ad flagged for replacement, propose two or three creative concepts overall, not one per ad: the angle, who it speaks to, and why it should work better than what it is replacing. Do a quick check on current trends in ads like mine, from sources you trust, and note where each idea came from. If real customer content would likely beat a generated one for a given angle, say so and propose that instead. Do not repeat anything already in the log, do not contradict what I have learned so far, and record whatever I approve."

I do not generate a single image at this stage. This agent only decides what to say and why; turning that into an actual creative is entirely the next agent's job.

Agent 3: the Designer (with Higgsfield)

This is where the approved ideas become real creatives, and it is the agent I was most careful building, because it is the one place where an AI system publishing on your behalf can embarrass you fastest.

For the images I used Higgsfield, a platform that sits on top of several generation models. It worked well for me, but nothing in the system depends on it specifically: I would get the same result going straight to Google's Nano Banana, ByteDance's Seedream and Seedance, Flux, or whatever is winning the benchmarks by the time you read this. The image model is a replaceable part of the machine. Pick one, wire it in, move on.

There is one rule that matters more than which model you pick: generate the image clean, with no text on it. Ask an image model to write your headline and it will happily invent brands, prices and typos. I learned this on my very first dry run, when a perfectly good background came back with a made-up brand name printed on it.

So the text goes on separately, and not by an image model: a small script overlays headline, offer numbers, logo and call to action on top of the clean image, using the fonts and colors from my brand guidelines and pulling every number strictly from my offers file. Code does not hallucinate a discount. The result is pixel-identical branding across every creative, and words I can actually trust.

Before anything ships, this agent looks at its own output: does the text sit over a face or over the product, is the price legible, is the product actually recognizable in the shot. If something is off, it fixes it and looks again, on its own, until the creative passes. I never see the broken drafts, only the ones that clear the bar.

One more thing that only became necessary once the account had more than a couple of ad sets running at once: I can ask for several creatives at the same time, one per idea or ad set, produced in parallel. Each one gets its own folder and its own self-contained brief, and they do not coordinate with each other, so a batch never ends up with several near-identical versions of the same idea, which is the kind of thing that gets flagged as duplicate content and quietly suppressed anyway.

"For each approved concept, generate the background image clean, with no text on it. Then overlay headline, offer numbers, logo and call to action, following my brand guidelines and taking every number from my offers file. Check your own output for overlapping text, illegible price, or a product that is not recognizable, and fix it before showing me. Show me the finished creatives before anything gets uploaded."

This agent never touches Meta. Its job stops at a folder full of finished files and a preview for me to look at.

Agent 4: the Publisher

The last agent is the only one allowed to write to Meta, and by design it is also the one I never let run unsupervised in the background: every upload happens with me watching.

Every ad it creates is born paused with no exceptions. By default the new creative goes live alongside the old one for about a week, so it earns its own track record before the group loses the old ad's history. Only once the weak ad is clearly not worth its spend anymore does this agent pause it outright, no cohabitation period, because at that point every extra day is just wasted budget.

Going live is its own separate step from uploading. Getting a creative onto the account paused is routine; making it spend money is not, so it always waits for one more explicit word from me, either one ad at a time or, when I trust a whole batch, all at once.

"Upload the approved creatives as paused, always. When replacing a weak ad, keep it running alongside the new one for about a week unless it is pure dead spend, in which case pause it immediately. Tell me clearly what got uploaded and what is waiting for me. Nothing goes live until I say so, one ad at a time unless I tell you otherwise."

This is the one place where the guardrails matter more than the intelligence. Everything upstream can be a little wrong and get caught at the next weekly review; a mistake here spends real money in public.

Try it and enjoy the ride

Congratulations, you have a Meta Ads assistant built from four agents that hand off to each other through files, with your approval sitting at exactly the points where money or brand are on the line. The best part of building it this way is that nothing is fixed in stone: I still tune it, sometimes weekly, based on what the account teaches me.

To recap, here is the loop and how to run it:

  1. Analyze: "How are the campaigns doing?", the Analyst pulls fresh data and hands me a plan.
  2. Approve the plan: I trim or approve what gets replaced and where (gate one).
  3. Get ideas: "What should I test this week?", the Ideator proposes two or three angles.
  4. Approve the ideas: I pick which ones move forward (gate two).
  5. Produce: the Designer builds the actual creatives, in parallel if there is more than one.
  6. Visual check: I look at the finished creatives before anything gets uploaded (gate three).
  7. Publish, paused: the Publisher uploads everything, spending nothing yet.
  8. Go live: my call, one ad at a time or in a batch I trust (gate four).

The system could technically run start to finish without me. Nothing in the code stops it. I chose not to let it, for two reasons: safety, and my own budget. It is my money on the line, and a system that learns is still a system that can be wrong.

If you want to build something like this for your own account, or want help adapting it to yours, reach out.

#meta-ads #claude-code #ai-agents

blog / how-i-automated-meta-ads2026