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: "15-cross-platform-intelligence" plan: "01" subsystem: ops-marketing tags: [cross-platform, blended-roas, attribution, marketing-intelligence, marketing-optimizer-agent, ops-go] dependency_graph: requires: [google-ads-credential-resolution, meta-ads-credential-resolution, instagram-insights, ga4-realtime, whatsapp-biz-template-send] provides: [cross-platform-optimize, cross-platform-attribution, cross-platform-campaigns, blended-roas-dashboard, ops-go-marketing-section] affects: [ops-marketing/SKILL.md, agents/marketing-optimizer.md, bin/ops-marketing-dash, skills/ops-go/SKILL.md]
Phase 15 Plan 01: Cross-Platform Marketing Intelligence
Goal
Stitch together the per-platform integrations built in Phases 10–14 into a unified intelligence layer: a new marketing-optimizer sub-agent (claude-sonnet model) that computes blended ROAS and recommends budget shifts, a cross-platform attribution sub-command, a unified campaigns view across Google Ads + Meta + Klaviyo, a blended ROAS + health score in the dashboard script, and a MARKETING section in the /ops:go morning briefing.
Prerequisite: Phases 10–14 must be complete (credential blocks and gather functions in place).
Requirements Addressed
- Cross-platform marketing intelligence synthesis
- Blended ROAS computation across Google Ads + Meta Ads
- Budget shift recommendations based on platform performance differential
- Morning briefing integration via
/ops:go
Runtime Prerequisites
No new credentials required. This phase assembles data from channels already configured in Phases 10–14. All channel data is optional — missing channels show as null in output, and the optimizer gracefully handles partial configurations.
Deliverables
Files to Create
claude-ops/agents/marketing-optimizer.md— new sub-agent: reads ops-marketing-dash JSON, computes blended ROAS, produces budget recommendations
Files to Modify
claude-ops/skills/ops-marketing/SKILL.md— addoptimizesub-command (dispatches marketing-optimizer agent),attributionsub-command (side-by-side table), extendcampaignssub-command to include Google Ads alongside Meta + Klaviyoclaude-ops/bin/ops-marketing-dash— add Instagram gather, compute blended ROAS, compute 0-100 health score + status stringclaude-ops/skills/ops-go/SKILL.md— add MARKETING section to morning briefing (health score + blended ROAS + top action)
Task Breakdown
Task 1: Create marketing-optimizer agent
File: claude-ops/agents/marketing-optimizer.md (new)
YAML frontmatter:
---
name: marketing-optimizer
description: Cross-platform ad budget optimization — reads Meta + Google Ads data, computes blended ROAS, and recommends specific budget shifts.
model: sonnet
---
Agent instructions:
Purpose: analyze ad performance across Meta Ads and Google Ads, compute blended ROAS, produce actionable budget recommendations.
Input: read pre-gathered data from ops-marketing-dash:
"${CLAUDE_PLUGIN_ROOT:-$HOME/.claude/plugins/ops-ops-marketplace}/bin/ops-marketing-dash" 2>/dev/null
JSON schema that ops-marketing-dash v1.5+ emits (document fully):
meta— account totals (last 7 days):spend,impressions,clicks,ctr,purchases,purchase_value,roas(all strings)google_ads— raw searchStream response (array of pages) ornullif unconfiguredklaviyo—subscribers,last_campaign,last_campaign_status,open_ratega4—sessions,users,conversions,revenue,cvrgsc—clicks,impressions,ctr,avg_positioninstagram—followers,media_count,reach_7d- Top-level:
blended_roas,health_score,health_status,date
Data extraction helpers using null-safe jq:
- Google Ads spend:
(if type=="array" then [.[].results[]?.metrics.costMicros // "0" | tonumber] | add // 0 else 0 end) / 1000000 - Google Ads conversions_value: same pattern with
conversionsValue
Analysis logic (agent applies this reasoning):
- Compute platform ROAS:
meta.roas(already computed), Google ROAS from raw data - Compute blended ROAS:
(meta_spend * meta_roas + google_spend * google_roas) / (meta_spend + google_spend) - Identify imbalance: if one platform ROAS > 20% above blended, recommend shifting budget toward it
- Threshold: only recommend shifts > $50/day; include specific dollar amounts
- Consider channel saturation: large share of budget on one platform may hit diminishing returns
Output format: structured recommendation with:
- Blended ROAS summary
- Per-platform performance table
- Specific budget shift recommendations (if any):
Move $X/day from Meta → Google Ads (Meta ROAS: 1.8x, Google ROAS: 3.2x) - Warning if total paid spend < $100/day (insufficient data for recommendations)
Task 2: Add optimize and attribution sub-commands to ops-marketing/SKILL.md
File: claude-ops/skills/ops-marketing/SKILL.md
Add to routing table:
| Input | Action |
|---|---|
| optimize | Dispatch marketing-optimizer agent with unified data |
| attribution | Cross-platform attribution side-by-side table |
optimize sub-command:
claude --agent marketing-optimizer
(agent reads ops-marketing-dash data autonomously)
attribution sub-command:
Gather data from all configured channels in parallel (same pattern as ops-marketing-dash), then render side-by-side table:
══ ATTRIBUTION COMPARISON — Last 7 Days ══
Metric Meta Ads Google Ads Klaviyo GA4
Spend $1,234 $567 $89/mo —
Sessions 12,890 8,934 3,412 24,236
Conversions 89 45 12 156
Revenue $4,501 $3,201 $1,890 $9,592
ROAS 3.6x 5.6x — —
Each cell shows — for channels not configured or metrics not applicable.
campaigns sub-command (extend existing):
Add Google Ads campaign rows to existing campaigns view:
- Existing: Meta campaigns + Klaviyo campaigns
- Add: Google Ads campaigns (from searchStream, top 5 by spend)
- Label each row with channel prefix:
[META],[GOOGLE],[KV] - Sort all rows by spend descending
Task 3: Extend ops-marketing-dash with Instagram gather, blended ROAS, health score
File: claude-ops/bin/ops-marketing-dash
Instagram gather function (gather_instagram):
- Credential guard: if
META_ACCESS_TOKENorINSTAGRAM_ACCOUNT_IDempty, returnnull - GET
/{INSTAGRAM_ACCOUNT_ID}?fields=followers_count,media_count&access_token=<TOKEN> - GET
/{INSTAGRAM_ACCOUNT_ID}/insights?metric=reach&period=day&since=7daysAgo&until=today - Aggregate
reachsum over 7 days - Return:
{"followers": N, "media_count": N, "reach_7d": N}
Add INSTAGRAM_DATA=$(gather_instagram) & to parallel execution block.
Blended ROAS computation (after all gathers complete):
META_SPEND=$(echo "$META_DATA" | jq -r '.spend // "0"')
META_CONV_VALUE=$(echo "$META_DATA" | jq -r '.purchase_value // "0"')
GOOGLE_SPEND=$(echo "$GADS_DATA" | jq '[.[].results[]?.metrics.costMicros // "0" | tonumber] | add // 0' 2>/dev/null | awk '{printf "%.2f", $1/1000000}')
GOOGLE_CONV_VALUE=$(echo "$GADS_DATA" | jq '[.[].results[]?.metrics.conversionsValue // "0" | tonumber] | add // 0' 2>/dev/null)
TOTAL_SPEND=$(awk "BEGIN{printf \"%.2f\", $META_SPEND + $GOOGLE_SPEND}")
TOTAL_VALUE=$(awk "BEGIN{printf \"%.2f\", $META_CONV_VALUE + $GOOGLE_CONV_VALUE}")
BLENDED_ROAS=$(awk "BEGIN{if ($TOTAL_SPEND > 0) printf \"%.2f\", $TOTAL_VALUE / $TOTAL_SPEND; else print \"0\"}")
Health score computation (0–100 composite):
- ROAS trend (0–40 pts): blended ROAS ≥ 3.0 → 40, ≥ 2.0 → 30, ≥ 1.5 → 20, ≥ 1.0 → 10, < 1.0 → 0
- Spend efficiency (0–30 pts): blended paid CTR — Meta
meta.ctrand Google Adsmetrics.ctr(fromGADS_DATA) weighted by click volume; if only one paid channel is configured, use that channel's CTR; if neither has CTR data, 0 pts: ≥ 2% → 30, ≥ 1% → 20, ≥ 0.5% → 10 - Channel diversification (0–30 pts): 3+ channels with spend → 30, 2 channels → 20, 1 channel → 10
health_status: score ≥ 80 →"EXCELLENT", ≥ 60 →"GOOD", ≥ 40 →"FAIR", < 40 →"POOR"
Add to final JSON output:
{
"instagram": ...,
"blended_roas": "2.84",
"health_score": 73,
"health_status": "GOOD",
"date": "..."
}
Task 4: Add MARKETING section to ops-go/SKILL.md
File: claude-ops/skills/ops-go/SKILL.md
Add ### MARKETING section to morning briefing output (runs ops-marketing-dash in background, shows condensed result):
MKTG=$(timeout 10 "${CLAUDE_PLUGIN_ROOT:-$HOME/.claude/plugins/ops-ops-marketplace}/bin/ops-marketing-dash" 2>/dev/null || echo '{}')
HEALTH_SCORE=$(echo "$MKTG" | jq -r '.health_score // "—"')
HEALTH_STATUS=$(echo "$MKTG" | jq -r '.health_status // "N/A"')
BLENDED_ROAS=$(echo "$MKTG" | jq -r '.blended_roas // "—"')
META_SPEND=$(echo "$MKTG" | jq -r '.meta.spend // "0"')
Display in briefing:
📊 MARKETING
Health: 73/100 GOOD Blended ROAS: 2.84x
Meta spend (7d): $1,234 Google Ads: $567
▶ /ops:marketing optimize for budget recommendations
timeout 10 guard prevents marketing data from blocking the morning briefing if APIs are slow.
Threat Model
| ID | Threat | Mitigation |
|---|---|---|
| T-15-01-01 | Marketing optimizer agent makes spend recommendations without guardrails | Mitigated — agent output is read-only recommendations; no mutating API calls from agent; user must manually apply via campaign management sub-commands |
| T-15-01-02 | ops-marketing-dash in ops-go blocks morning briefing | Mitigated — timeout 10 guard; briefing shows — values if marketing data unavailable |
| T-15-01-03 | Blended ROAS division by zero when no spend | Mitigated — awk guard: if ($TOTAL_SPEND > 0) before division; shows 0 otherwise |
| T-15-01-04 | Instagram gather adds latency to dashboard | Mitigated — runs in parallel with other gathers via & background job |
Dependencies
- Requires: At least Phases 10 (Google Ads) and existing Meta Ads integration functional; other channels optional
- Provides:
cross-platform-optimize,cross-platform-attribution,cross-platform-campaigns,blended-roas-dashboard,ops-go-marketing-section
Success Criteria (Self-Check)
-
claude-ops/agents/marketing-optimizer.mdexists -
grep "blended_roas" claude-ops/bin/ops-marketing-dash— PASS -
grep "health_score" claude-ops/bin/ops-marketing-dash— PASS -
grep "gather_instagram" claude-ops/bin/ops-marketing-dash— PASS -
grep "attribution" claude-ops/skills/ops-marketing/SKILL.md— PASS -
grep "\[META\]\|\[GOOGLE\]" claude-ops/skills/ops-marketing/SKILL.md— PASS (cross-channel campaigns view) -
grep "MARKETING" claude-ops/skills/ops-go/SKILL.md— PASS -
grep "timeout 10" claude-ops/skills/ops-go/SKILL.md— PASS (briefing guard) -
bash -n claude-ops/bin/ops-marketing-dashexits 0