Skip to content

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.

8.4 KB
Raw Blame

phase: "10-google-ads" plan: "01" subsystem: ops-marketing tags: [google-ads, oauth2, credentials, setup-wizard, dashboard] dependency_graph: requires: [] provides: [google-ads-credential-resolution, google-ads-token-refresh, google-ads-setup-flow, google-ads-dashboard-gather] affects: [ops-marketing/SKILL.md, skills/setup/SKILL.md, bin/ops-marketing-dash]

Phase 10 Plan 01: Google Ads Credential Foundation

Goal

Wire Google Ads authentication into the ops-marketing skill via a 3-tier credential cascade (userConfig → env → Doppler), provide an OAuth2 setup flow in the setup wizard, and add a campaign pre-gather function to the marketing dashboard script. This plan establishes auth only; sub-command implementations follow in Plans 02 and 03.

Requirements Addressed

  • GADS-07: Credential resolution and token refresh for Google Ads API access
  • Google Ads OAuth2 setup flow integrated into /ops:setup wizard

Runtime Prerequisites

STOP — the operator must provide the following before this plan can execute:

Credential Where to get it
GADS_DEV_TOKEN Google Ads API Center → Developer token (requires approved API access)
GADS_CLIENT_ID Google Cloud Console → APIs & Services → Credentials → OAuth 2.0 Client ID
GADS_CLIENT_SECRET Same OAuth 2.0 Client ID entry in Google Cloud Console
GADS_REFRESH_TOKEN Obtained via OAuth2 authorization flow (Plan 01 setup wizard generates this)
GADS_CUSTOMER_ID Google Ads account → Settings → Account details (10-digit, format 123-456-7890)
GADS_LOGIN_CUSTOMER_ID Only required for MCC (manager) accounts; the MCC account ID

API approval note: Google Ads API requires applying for access at https://developers.google.com/google-ads/api/docs/access-levels. Basic access is available immediately; Standard access requires application review.

Deliverables

Files to Modify

  • claude-ops/skills/ops-marketing/SKILL.md — add google_ads_* keys to Runtime Context, add ### Google Ads credential resolution block with 6-variable cascade, add access token refresh via oauth2.googleapis.com/token, add ## google-ads section with routing table placeholder and credential guard
  • claude-ops/skills/setup/SKILL.md — restructure marketing AskUserQuestion into two sequential calls (max 4 options per Rule 1), add #### Google Ads setup sub-section (Steps A–F: dev token → OAuth client → browser OAuth flow → customer ID discovery → smoke test → save to preferences.json)
  • claude-ops/bin/ops-marketing-dash — add 6-var Google Ads credential resolution block, add gather_google_ads() stub function that returns null when unconfigured, add it to parallel execution block

Task Breakdown

Task 1: Add Google Ads credential resolution to ops-marketing/SKILL.md

File: claude-ops/skills/ops-marketing/SKILL.md

Add the following to the Runtime Context section:

google_ads_dev_token, google_ads_client_id, google_ads_client_secret,
google_ads_refresh_token, google_ads_customer_id, google_ads_login_customer_id

Add ### Google Ads credential resolution block after the existing credential blocks:

# 6-variable cascade: preferences.json → env → Doppler
GADS_DEV_TOKEN="${google_ads_dev_token:-${GOOGLE_ADS_DEV_TOKEN:-$(doppler secrets get GOOGLE_ADS_DEV_TOKEN --plain 2>/dev/null)}}"
GADS_CLIENT_ID="${google_ads_client_id:-${GOOGLE_ADS_CLIENT_ID:-}}"
GADS_CLIENT_SECRET="${google_ads_client_secret:-${GOOGLE_ADS_CLIENT_SECRET:-}}"
GADS_REFRESH_TOKEN="${google_ads_refresh_token:-${GOOGLE_ADS_REFRESH_TOKEN:-$(doppler secrets get GOOGLE_ADS_REFRESH_TOKEN --plain 2>/dev/null)}}"
GADS_CUSTOMER_ID="${google_ads_customer_id:-${GOOGLE_ADS_CUSTOMER_ID:-}}"
GADS_LOGIN_CUSTOMER_ID="${google_ads_login_customer_id:-${GOOGLE_ADS_LOGIN_CUSTOMER_ID:-}}"
# Strip dashes from customer ID
GADS_CUSTOMER_ID="${GADS_CUSTOMER_ID//-/}"

Add access token refresh:

# Refresh short-lived access token from refresh token
if [ -n "$GADS_REFRESH_TOKEN" ] && [ -n "$GADS_CLIENT_ID" ]; then
  GADS_ACCESS_TOKEN=$(curl -sf -X POST https://oauth2.googleapis.com/token \
    -d "client_id=${GADS_CLIENT_ID}&client_secret=${GADS_CLIENT_SECRET}&refresh_token=${GADS_REFRESH_TOKEN}&grant_type=refresh_token" \
    | jq -r '.access_token // empty')
fi
GADS_HEADERS=(-H "Authorization: Bearer $GADS_ACCESS_TOKEN" -H "developer-token: $GADS_DEV_TOKEN")
# Add login-customer-id header for MCC accounts
[ -n "$GADS_LOGIN_CUSTOMER_ID" ] && GADS_HEADERS+=(-H "login-customer-id: $GADS_LOGIN_CUSTOMER_ID")

Add routing table entry: google-ads, gads pointing to ## google-ads section.

Add ## google-ads section with credential guard and placeholder for Plans 02+03 sub-commands.

Add google-ads to ## setup auto-scan patterns: GOOGLE_ADS_* env vars, shell profile grep, Doppler filter, Dashlane, keychain, Chrome history.

Task 2: Add Google Ads setup flow to setup/SKILL.md and pre-gather to ops-marketing-dash

File: claude-ops/skills/setup/SKILL.md

Restructure the marketing service selection AskUserQuestion into two sequential calls (Rule 1: max 4 options per call):

  • Call 1: Klaviyo | Meta Ads | Google Ads | More…
  • Call 2 (if "More…"): GA4 | Google Search Console

Add #### Google Ads sub-section in Step 3j with the following steps:

  • Step A: Dev token — show auto-scan result if found; AskUserQuestion to keep or reconfigure
  • Step B: OAuth2 client ID + secret — prompt for Google Cloud Console OAuth credentials
  • Step C: Browser OAuth flow — launch localhost:8080 redirect server (run_in_background: true), construct accounts.google.com/o/oauth2/auth URL with https://www.googleapis.com/auth/adwords scope, print URL for user to open, capture authorization code from redirect, exchange for refresh token via oauth2.googleapis.com/token
  • Step D: Customer ID discovery — call listAccessibleCustomers to enumerate accounts; if multiple, AskUserQuestion to select; auto-detect MCC and set GADS_LOGIN_CUSTOMER_ID
  • Step E: Smoke test — listAccessibleCustomers round-trip; print ✓ or error message
  • Step F: Save to preferences.json under marketing.projects.<project>.google_ads.* (project slug from setup context — matches get_cred / ops-marketing-dash resolution path)

Add google-ads, gads shortcuts to the setup routing table.

File: claude-ops/bin/ops-marketing-dash

After the existing credential blocks, add:

GADS_DEV_TOKEN="..." # 6-variable cascade (same as SKILL.md)
GADS_CUSTOMER_ID="${GADS_CUSTOMER_ID//-/}"
# Doppler fallback for refresh token
[ -z "$GADS_REFRESH_TOKEN" ] && GADS_REFRESH_TOKEN="$(doppler secrets get GOOGLE_ADS_REFRESH_TOKEN --plain 2>/dev/null)"

Add gather_google_ads() function:

  • Guard: if GADS_REFRESH_TOKEN or GADS_DEV_TOKEN is empty, echo null and return
  • Refresh access token via oauth2.googleapis.com/token
  • GAQL searchStream query for campaign summary (last 7 days, top 20 by spend, status != REMOVED)
  • Include optional login-customer-id header for MCC
  • Return raw JSON

Add GADS_DATA=$(gather_google_ads) & to the parallel execution block. Add google_ads: $GADS_DATA to the final JSON output.

Threat Model

ID Threat Mitigation
T-10-01-01 refresh_token written to preferences.json on disk Preferences file is ~/.claude/plugins/.../preferences.json, user-only permissions; document that backup tools should exclude it; never commit the file
T-10-01-02 localhost:8080 OAuth redirect server left running Background server receives one request then exits; no persistent listener
T-10-01-03 access_token in memory for session duration Ephemeral, HTTPS-only transport; acceptable for CLI tool context
T-10-01-04 developer_token visible in curl command output Stored in preferences.json / env, never hardcoded in committed files; shell history is user's responsibility

Success Criteria (Self-Check)

  • grep -c "GADS_" claude-ops/skills/ops-marketing/SKILL.md returns ≥ 20
  • grep "oauth2.googleapis.com/token" claude-ops/skills/ops-marketing/SKILL.md — PASS
  • grep "google-ads" claude-ops/skills/setup/SKILL.md — PASS
  • grep "listAccessibleCustomers" claude-ops/skills/setup/SKILL.md — PASS
  • grep "gather_google_ads" claude-ops/bin/ops-marketing-dash — PASS
  • bash -n claude-ops/bin/ops-marketing-dash exits 0