An AI-powered pipeline that autonomously generates, deploys, and optimizes Meta (Facebook/Instagram) ads using Claude Code skills. From creative generation to daily optimization — fully automated.
Works for any business. Run /ad-setup and it walks you through everything.
- Scrapes your website for ad content (value props, testimonials, pricing)
- Monitors competitor ads via Meta Ad Library and generates counter-positioning
- Generates UGC-style video ads (fal.ai / Kling v3 Pro) and static image ads (Gemini Imagen 4)
- Deploys ads to your Meta Ads account with a proven 3-campaign structure
- Optimizes daily: pauses underperformers, scales winners, detects creative fatigue
- Sends daily performance briefings via Slack
This system uses a proven Meta Ads structure that separates testing from scaling:
Your Account
├── Prospecting Campaign (60-70% of budget)
│ Find new customers. Only proven creatives run here.
│ Meta's algorithm optimizes delivery automatically.
│
├── Retargeting Campaign (15-25% of budget)
│ Convert people who already visited your site or watched your videos.
│ Smaller audience, higher conversion rate.
│
└── Testing Campaign (10-15% of budget)
Test new creatives in isolation (1 creative per ad set).
Winners get promoted to Prospecting. Losers get paused.
Why this works: Testing in isolation prevents unproven creatives from disrupting your winning campaigns. Budget follows performance — not guesswork.
/ad-setup
That's it. The setup skill walks you through everything interactively:
- Your business info and pricing
- API keys (Meta, fal.ai, Gemini)
- Brand config (colors, voice, personas, competitors)
- Verification that everything connects
Then it hands you off to the next skill. Each skill recommends what to run next:
/ad-setup → /ad-scrape → /ad-strategy → /ad-monitor → /ad-ideas → /ad-generate → /ad-deploy → /ad-manager
- Claude Code (CLI, VS Code extension, or Desktop app)
- A Meta Ads account (see "Getting Meta API Access" below)
- fal.ai account for video generation (fal.ai) — free tier available
- Gemini API key for image generation (aistudio.google.com) — free tier available
# 1. Clone the repo
git clone https://github.com/yourusername/social-ad-generator
cd social-ad-generator
# 2. Install Python dependencies
pip install fal-client mlx-whisper Pillow
# 3. Install ffmpeg (required for video stitching and captions)
# macOS:
brew install ffmpeg
# Ubuntu/Debian:
sudo apt-get install ffmpeg
# Windows: Download from https://ffmpeg.org/download.html
# 4. Copy example config files
cp .env.example .env
cp .mcp.json.example .mcp.json
cp brand/brand.example.json brand/brand.json
cp brand/config.example.json brand/config.json
# 5. Open in Claude Code and run:
/ad-setupIf you've never used the Meta Ads API, here's how to get started:
- Go to developers.facebook.com
- Click "Get Started" and follow the prompts (free)
- You need a personal Facebook account to create a developer account
- Go to developers.facebook.com/apps
- Click "Create App" → select "Other" → select "Business"
- Give it a name (e.g., "My Ads Automation")
- In your app dashboard, click "Add Product"
- Find "Marketing API" and click "Set Up"
- Go to developers.facebook.com/tools/explorer
- Select your app from the dropdown
- Click "Generate Access Token"
- Grant these permissions when prompted:
ads_management— create and manage adsads_read— read ad performance datapages_read_engagement— read page data for ad creativespages_manage_ads— create ads linked to your page
- Short-lived tokens expire in 1 hour — you need a long-lived token (60 days)
- In the Access Token Tool, click "Get Long-Lived Token"
- Copy this token — you'll paste it during
/ad-setup
After setup, you'll have these (all collected during /ad-setup):
- Access Token — the long-lived token from step 5
- Ad Account ID —
/ad-setupwill list your accounts and let you pick - Page ID —
/ad-setupwill list your pages and let you pick - Pixel ID —
/ad-setupwill find your pixel (or tell you how to create one)
Don't worry about finding these manually — /ad-setup automates the discovery.
| Skill | What it does |
|---|---|
/ad-setup |
First-time onboarding — collects API keys, business info, creates config files |
/ad-scrape |
Scrapes your website for value props, testimonials, features, pricing |
/ad-strategy |
Designs your Meta Ads account structure (campaigns, ad sets, budgets, audiences) |
/ad-monitor |
Scans competitor ads via Meta Ad Library, generates counter-positioning briefs |
/ad-ideas |
Generates creative concepts — UGC video scripts, shot lists, messaging angles |
/ad-generate |
Produces video ads (Kling v3 Pro) and static images (Gemini Imagen 4) |
/ad-deploy |
Deploys creatives to your Meta account (all created as PAUSED for review) |
| Skill | What it does |
|---|---|
/ad-manager |
Orchestrator — runs the full pipeline daily via /schedule |
/ad-optimize |
Pauses losers, scales winners, promotes test winners, detects fatigue |
/ad-report |
Generates daily/weekly performance briefings, sends to Slack |
/caption |
Burns social-media-style word-by-word captions onto video ads |
Every skill is interactive — it asks questions one at a time, explains its reasoning, and gets your approval before taking action. No silent changes.
- In interactive mode (you run the skill manually): Skills present recommendations with selectable options, explain WHY, and wait for your approval.
- In automated mode (via
/ad-manageron a schedule): Skills execute using your config, log all decisions, and surface findings in the daily report. - Escape hatches: If you say "just do it", skills use smart defaults and proceed without asking.
brand/brand.json ← Your brand config (personas, competitors, voice)
brand/config.json ← Runtime config (budgets, thresholds, targeting)
brand/content.json ← Scraped website content (auto-generated)
brand/competitors.json ← Competitor intelligence (auto-generated)
brand/ad-ideas.json ← Creative concepts (auto-generated)
brand/creatives/ ← Generated video + image ads (auto-generated)
state.json ← Campaign state (IDs, optimization log, flags)
.mcp.json ← MCP server config (Meta Ads API, Gemini)
Skills communicate through shared files. /ad-monitor writes creative briefs that /ad-ideas reads. /ad-optimize sets flags that /ad-manager checks. /ad-report reads the optimization log.
Once set up, schedule the pipeline to run daily:
/schedule create --name "ads-daily" --cron "0 9 * * *" --prompt "/ad-manager"
The manager runs: optimize → generate (if needed) → deploy (if needed) → monitor (weekly) → report.
"Invalid Access Token"
- Tokens expire after 60 days. Regenerate at developers.facebook.com/tools/explorer
- Get a new long-lived token and update
.mcp.json
"No Ad Accounts Found"
- Create an ad account at business.facebook.com
- Link it to your developer app
- Wait a few minutes for propagation, then retry
"Pixel Has Never Fired"
- Install the Meta Pixel on your website first
- Verify at facebook.com/events_manager
- The system starts with a warmup phase (Landing Page Views) that doesn't require pixel events
"ModuleNotFoundError: No module named 'fal_client'"
pip install fal-clientfal.ai rate limit errors
- The system staggers requests with 2-second delays
- If you still hit limits, wait 60 seconds and retry
- Consider upgrading your fal.ai plan for higher limits
ffmpeg not found
# macOS
brew install ffmpeg
# Ubuntu/Debian
sudo apt-get install ffmpegSkills don't appear in Claude Code
- Make sure you're in the project directory
- The skills folder must be at
skills/mikla-ads/relative to the project root - Restart Claude Code if you just cloned the repo
Config validation fails during /ad-setup
- Make sure you copied all example files (step 4 of Installation)
- Check that
.envand.mcp.jsonhave your real API keys, not the placeholder values
"BLOCKED" status from any skill
- Read the REASON and RECOMMENDATION in the output
- Most blocks are due to expired tokens or missing config
- Run
/ad-setupagain to re-verify your setup
PRs welcome. The skill files are in skills/mikla-ads/*/SKILL.md — each is a self-contained Claude Code skill definition.
To add a new skill:
- Create a directory under
skills/mikla-ads/ - Add a
SKILL.mdwith frontmatter (name, description, allowed-tools) - Follow the Interaction Protocol pattern from existing skills
- Add a "What's Next" handoff section
MIT — see LICENSE