Business operating system for Claude Code — 57 skills, 21 agents, smart daemon. Unified inbox (WhatsApp/Email/Slack/Telegram), autonomous PR merge, full-AWS monitoring, revenue (Stripe+RevenueCat), e-commerce (Shopify), marketing (Klaviyo/Meta/GA4), voice (Bland/ElevenLabs), APM (Datadog/NewRelic/OTEL), YOLO mode.
phase: "11-meta-ads" plan: "01" subsystem: ops-marketing tags: [meta-ads, facebook-marketing-api, campaigns, ad-sets, creatives, automation-rules, audiences, advantage-plus] dependency_graph: requires: [] provides: [meta-ads-campaign-management, meta-ads-targeting, meta-ads-creatives, meta-ads-automation-rules, meta-ads-audiences, meta-ads-advantage-plus] affects: [ops-marketing/SKILL.md]
Phase 11 Plan 01: Meta Ads Campaign Management
Goal
Implement Meta Ads campaign management sub-commands in ops-marketing/SKILL.md: campaign creation (always PAUSED), ad set targeting, creative assembly, automation rules, audience management (Custom + Lookalike), and Advantage+ Shopping Campaigns. All financial and destructive operations gated via Rule 5 confirmation.
Requirements Addressed
- Meta Ads campaign management via Facebook Marketing API v19+
- All creative and campaign operations start in PAUSED/INACTIVE state for safety review
Runtime Prerequisites
STOP — the following credentials must be configured before this plan can execute:
| Credential | Where to get it |
|---|---|
META_ACCESS_TOKEN |
Meta for Developers → App → Tools → Graph API Explorer → Generate token with ads_management, ads_read, pages_read_engagement permissions; or via System User in Business Manager |
META_AD_ACCOUNT_ID |
Meta Business Manager → Accounts → Ad Accounts → Account ID (format act_XXXXXXXXXX) |
META_APP_ID |
Meta for Developers → App → App ID |
META_APP_SECRET |
Meta for Developers → App → Settings → Basic → App Secret |
Token longevity note: User access tokens expire in ~60 days. Use a System User token for production (non-expiring). Long-lived tokens obtained via oauth/access_token?grant_type=fb_exchange_token.
API access note: Standard access for Ads APIs may require app review for production use. Development mode allows testing with limited accounts.
Deliverables
Files to Modify
claude-ops/skills/ops-marketing/SKILL.md— add## metacampaign management section with create-campaign, target, creative, rules, audiences, advantage sub-commands; credential resolution already wired; extend routing table
Task Breakdown
Task 1: Campaign Creation sub-command
File: claude-ops/skills/ops-marketing/SKILL.md → ## meta section
Implement meta create-campaign sub-command:
- AskUserQuestion: campaign name, objective (OUTCOME_AWARENESS / OUTCOME_TRAFFIC / OUTCOME_ENGAGEMENT / OUTCOME_LEADS / OUTCOME_APP_PROMOTION / OUTCOME_SALES), daily budget (USD), special ad category (NONE / CREDIT / EMPLOYMENT / HOUSING / ISSUES_ELECTIONS_POLITICS)
- Convert USD dollars to cents before the API call:
daily_budget=$(awk "BEGIN{printf \"%.0f\", usd_amount * 100}")— Meta'sdaily_budgetis an integer in the account's minor currency unit (cents for USD) - POST to
https://graph.facebook.com/v19.0/{META_AD_ACCOUNT_ID}/campaigns:{ "name": "<name>", "objective": "<objective>", "status": "PAUSED", "daily_budget": "<budget_cents>", "special_ad_categories": ["<category>"] } - Always set
"status": "PAUSED"— never create active campaigns (Rule 5 safety) - Print created campaign ID; instruct user to create ad sets and enable after review
Routing table additions in ## meta:
| Input | Action |
|---|---|
| create-campaign | Create new campaign (always PAUSED) |
| target <ADSET_ID> | Configure ad set targeting |
| creative <CAMPAIGN_ID> | Create ad creative and ad |
| rules | Create automation rules |
| audiences | Manage Custom and Lookalike audiences |
| advantage | Create Advantage+ Shopping Campaign |
Task 2: Ad Set Targeting sub-command
File: claude-ops/skills/ops-marketing/SKILL.md → ## meta section
Implement meta target <ADSET_ID> sub-command:
- AskUserQuestion (multi-step): geo targeting (countries comma-separated), age min/max (18-65), gender (ALL/MALE/FEMALE), placement device (ALL/MOBILE/DESKTOP), placement positions (feed/stories/reels/search — comma-separated)
- Build targeting spec JSON:
{ "geo_locations": {"countries": [...]}, "age_min": N, "age_max": N, "genders": [1] or [2] or [], "device_platforms": [...], "publisher_platforms": ["facebook","instagram"], "facebook_positions": [...], "instagram_positions": [...] } - POST to
https://graph.facebook.com/v19.0/{ADSET_ID}with targeting spec (Meta Graph API updates use POST, not PATCH) - Require AskUserQuestion confirmation (Rule 5) before applying
Task 3: Creative Assembly sub-command
File: claude-ops/skills/ops-marketing/SKILL.md → ## meta section
Implement meta creative <CAMPAIGN_ID> sub-command (two paths):
Image creative path:
- AskUserQuestion: image source (URL or local file path), headline, primary text, description, destination URL, call-to-action type
- If local file: multipart POST to
/{META_AD_ACCOUNT_ID}/adimagesto upload, captureimages[].hash - If URL: POST to
/{META_AD_ACCOUNT_ID}/adimages?url=<url> - Create adcreative: POST to
/{META_AD_ACCOUNT_ID}/adcreativeswithobject_story_spec - Create ad: POST to
/{META_AD_ACCOUNT_ID}/adslinking adset + creative;status: PAUSED
Video creative path:
- AskUserQuestion: video URL, thumbnail URL, headline, primary text, destination URL
- POST to
/{META_AD_ACCOUNT_ID}/advideos?file_url=<video_url>(async upload) - Poll
video_idstatus untilready == true(max 10 polls, 3s intervals) - Create adcreative and ad as above with
video_datainstead ofimage_data
Task 4: Automation Rules sub-command
File: claude-ops/skills/ops-marketing/SKILL.md → ## meta section
Implement meta rules sub-command:
- AskUserQuestion: rule type (pause-underperformers / scale-winners / custom)
- Pause underperformers preset: ROAS < 1.0 for 3 days → pause ad set
- Scale winners preset: ROAS > 3.0 → increase budget 20%
- POST to
/{META_AD_ACCOUNT_ID}/adrules_library - AskUserQuestion confirmation (Rule 5) before creating any rule; show rule summary
Task 5: Audience Management sub-command
File: claude-ops/skills/ops-marketing/SKILL.md → ## meta section
Implement meta audiences sub-command (two modes):
Custom Audience (website pixel):
- AskUserQuestion: audience name, pixel ID, rule (all website visitors / specific event / URL contains), lookback window (1-180 days)
- POST to
/{META_AD_ACCOUNT_ID}/customaudienceswithpixel_ruleJSON
Lookalike Audience:
- AskUserQuestion: source audience ID, target country, lookalike size (1-10% of country population)
- POST to
/{META_AD_ACCOUNT_ID}/customaudienceswithlookalike_spec - Note: Lookalike audience takes 1-6 hours to populate
Task 6: Advantage+ Shopping Campaign sub-command
File: claude-ops/skills/ops-marketing/SKILL.md → ## meta section
Implement meta advantage sub-command:
- AskUserQuestion: campaign name, daily budget (USD), pixel ID, catalog ID (optional)
- Convert USD dollars to cents:
daily_budget=$(awk "BEGIN{printf \"%.0f\", usd_amount * 100}")(same cents conversion as create-campaign) - POST to
/{META_AD_ACCOUNT_ID}/campaignswithobjective: OUTCOME_SALES,smart_promotion_type: AUTOMATED_SHOPPING_ADS,status: PAUSED - Auto-create ad set with
destination_type: WEBSITE, linking pixel - Print campaign + ad set IDs; instruct user to add creatives before enabling
- AskUserQuestion confirmation (Rule 5) — note that Advantage+ uses Meta's full automation
Threat Model
| ID | Threat | Mitigation |
|---|---|---|
| T-11-01-01 | Access token with ads_management scope has broad account access |
Mitigated — use System User token scoped to specific ad account; document minimum required permissions |
| T-11-01-02 | Campaign enable: financial impact without review | Mitigated — all new campaigns/ad sets created with status: PAUSED; user must explicitly enable |
| T-11-01-03 | Automation rule creates unintended spend changes | Mitigated — AskUserQuestion confirmation (Rule 5) showing full rule summary before creation |
| T-11-01-04 | Video upload URL leaks in curl command | Accepted — ephemeral S3 signed URL; visible in terminal only |
| T-11-01-05 | Lookalike audience creation uses customer PII indirectly | Accepted — pixel-based source; no PII leaves Meta's systems |
Dependencies
- Requires: Meta Ads credentials configured (existing
## metacredential resolution in ops-marketing) - Provides:
meta-ads-campaign-management,meta-ads-targeting,meta-ads-creatives,meta-ads-automation-rules,meta-ads-audiences,meta-ads-advantage-plus
Success Criteria (Self-Check)
-
grep "create-campaign" claude-ops/skills/ops-marketing/SKILL.md— PASS -
grep -c "status.*PAUSED" claude-ops/skills/ops-marketing/SKILL.mdreturns ≥ 3 -
grep "adrules_library" claude-ops/skills/ops-marketing/SKILL.md— PASS -
grep "customaudiences" claude-ops/skills/ops-marketing/SKILL.md— PASS -
grep "OUTCOME_SALES" claude-ops/skills/ops-marketing/SKILL.md— PASS -
grep -c "AskUserQuestion" claude-ops/skills/ops-marketing/SKILL.mdreturns ≥ 5 -
grep "smart_promotion_type.*AUTOMATED_SHOPPING_ADS" claude-ops/skills/ops-marketing/SKILL.md— PASS