# How to Build an AI Ad Generator With Claude Code

> You can build an AI ad generator without coding by describing it to Claude Code in plan mode, approving the plan, connecting a Supabase database and an image model, then improving it with feedback. The tool in this guide keeps a brand profile for each client, generates image ads from reference images, learns from likes and dislikes, and exports finished creatives.

Source: https://fluxomate.com/blog/build-an-ad-generator.html  
Published by Fluxomate (https://fluxomate.com/), 2026-05-05. Section: Claude Code builds.
Video: https://www.youtube.com/watch?v=tSSQJlpHHqo

## Key takeaways

- Start in plan mode and describe the tool in plain language, including what you want it to remember per client.
- Supabase stores the clients, projects, versions and images. Claude gives you the SQL to create the tables.
- Keep client reference images for brand understanding separate from per ad reference images for layout inspiration.
- The first output will be weak. Better prompts, a better image model and feedback improve it.
- Keep API keys in an environment file, not in the chat.

## What does an internal AI ad generator do?

This is an internal tool for an agency that launches image ads for many clients. It has four core features. You add clients and the tool researches their brand. You generate image ads from a written brief and optional reference images. You iterate with feedback, and the tool learns from it. You approve a winner and export it in the sizes you need.

The goal is a tool your team can use to produce more creative for each client, with each client's brand kept separate. This guide covers the build order, the setup, and the fixes that made the output usable. The video above walks through the whole session, including every error.


## How do you set up Claude Code for the build?

We used the Claude desktop app and its code tab, instead of a separate coding environment. It is a chat interface, which is friendlier for beginners. You need a paid Claude plan and a folder on your computer to build in. Open that folder in the code tab.

Claude Code has four permission modes: ask permissions, accept edits, plan, and bypass permissions. Ask permissions checks with you before it acts. Accept edits approves most edits for you. Plan mode proposes a plan before touching anything. Bypass permissions does everything without asking, so use it with care. You can also pick the model and the effort level, dictate prompts by voice, and watch your session and weekly usage limits.


## What should the first prompt say?

Switch to plan mode and describe the tool you want. Ours said, in plain speech, that we run a marketing agency that launches ads for clients in different niches. It asked for a tool that generates image ads for client profiles from specific prompts, with a client memory system and brand profiles for consistency, feedback that improves the images, a high quality prompt behind the scenes, and resizing. It said the tool was internal, so security did not need to be heavy at the start.

Claude asked clarifying questions about architecture, such as the image model, client memory and output sizes. We took the recommended answers, with one change: we chose an image tool we already used, because it offers many models in one place and lets you switch models without redoing the API setup. For client memory we kept brand basics, visual identity, reference images and notes that load automatically.

Read the plan even if you do not follow every detail. Check that it matches your idea. Ours described a brand profile, a brief in natural language, an automatic enhancement of the brief with brand context, conversational iteration, outputs in standard aspect ratios, and a learning step from thumbs up and thumbs down feedback. We asked Claude to give us the database setup instructions first, so we could do that while it built the files.


## How do you set up the database and keys?

Supabase is a database, which you can think of as a more structured Google Sheet. Claude gives you the steps.

1. Create a new Supabase project.
2. Copy the project URL, the anon public key and the service role key.
3. Paste the SQL Claude provides into the SQL editor and run it. This creates the tables: clients, client reference images, ad projects, ad versions and ad renders.
4. Create three storage buckets, for logos, references and ads, then run the follow up SQL.
5. Add a user in the authentication section so you can log in to the tool.
6. Create an API key for your image generation service and an Anthropic API key.
7. Ask Claude to create an environment file, then add the keys yourself. We avoid pasting keys into the chat.

## What happens when you first run it?

Ask Claude to confirm the keys are present and start the server. The tool runs locally, on your own machine. Log in, add a client with a niche, tagline, brand colours, reference images and a logo, and then create an ad from a brief.

Expect errors. Our first run failed with an authentication error, and we pasted the message back into Claude, which fixed it. When the first ad arrived, it looked poor: one of the client's reference images had been dropped straight into the ad. Marking it as disliked added a note to that client's memory, which is the learning loop working. We could also iterate with written feedback.


## How did we make the ads better?

We gave feedback in plan mode and changed the design in one go. A second Claude window can work on a separate feature at the same time. Opening a new window in the same folder keeps the shared context and uses less than repeating the work in one long session.

- Add automatic research when you add a client. Enter a name and website and the tool finds the logo, brand identity, tone and example images, shows them on a review screen, then saves them.
- Add a per ad reference image that acts as inspiration for layout, not something to copy.
- Use client level reference images only to understand the brand, never as part of the ad itself.
- Add a choice for how many outputs to generate, each in a different style.
- Research what makes Meta ads get attention and update the system prompts.
- Switch to a better image model. The first model was fast but gave weaker results.
- Rewrite the prompt builder. The root cause of weak ads was that the tool was writing photography prompts instead of ad creative prompts.
- Add a toggle for including the logo in each ad.

## How do you export and edit the finished ads?

Outputs improved once the prompts and model improved. Text inside the image remained the weakest point, so we made small edits with feedback, for example asking for a cleaner font and a blur behind the text instead of a white highlight. The tool only edited the section we asked about.

We then added features: a download button on each image, an upscale option with a limit on file size, a way to approve a winning image and generate more variations of it, and a version history so you can look back at earlier versions. To edit text and layout by hand, we exported an ad to Canva and used its magic layers feature, which splits an image into separate elements.

Last, we added a second client with a different brand to confirm that each client's memory stays separate, so one client's colours do not bleed into another's.


## What should you remember about security and deployment?

For an internal tool with a handful of users, security is less of a concern than for public software, but the basics still apply: do not expose API keys, keep everything behind a login, and ask Claude to run a security check at the end. To let your team use it, ask Claude to deploy it to a hosting service such as Vercel or Railway.

The first version is the worst version. It improves through feedback, so plan on going back and forth.


## Questions people ask

### Do I need to code to build an AI ad generator?

No. In this build Claude Code wrote the code, produced the database SQL and fixed its own errors when we pasted them back. You still need to set up accounts and paste API keys into an environment file.

### What does Supabase do in this tool?

It is the database that holds clients, client reference images, ad projects, ad versions and ad renders, plus storage buckets for logos, references and ads. It also handles the login.

### How does the tool keep each client's brand separate?

Each client has its own profile and memory, with brand basics, visual identity, reference images and notes. Likes and dislikes update that client's memory only, so one client's style does not spill into another's.

### Why were the first ads poor?

The first image model gave weaker results, reference images were being used inside the ad, and the prompts read like photography prompts. Fixing those, with more feedback, improved the output.

### Can I edit the finished ads?

Yes. You can give written feedback in the tool, or export the image to Canva and use its magic layers feature to edit text and elements by hand.

Tools used: Claude Code, Supabase, Anthropic API, Nano Banana 2, Canva, Vercel, Railway

Free templates for this guide: https://fluxomate.com/resources.html?r=build-an-ad-generator
