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.
Shell agent-teamsai-agentai-automationanthropicautonomous-agentawsbusiness-operationsclaudeclaude-codeclaude-code-plugindevopsecommerceinbox-zeroklaviyomarketingmcpmorning-briefingpr-automationshopifyterminal
feat(10-01): add Google Ads OAuth setup flow to setup wizard and pre-gather to dashboard
auroracapital2af9eecf2a6f
diff --git a/claude-ops/bin/ops-marketing-dash b/claude-ops/bin/ops-marketing-dashindex 98c8caec..5f3d05ce 100755--- a/claude-ops/bin/ops-marketing-dash+++ b/claude-ops/bin/ops-marketing-dash@@ -10,6 +10,12 @@ META_TOKEN="${META_ADS_TOKEN:-$(claude plugin config get meta_ads_token 2>/dev/nMETA_ACCOUNT="${META_AD_ACCOUNT_ID:-$(claude plugin config get meta_ad_account_id 2>/dev/null || echo "")}"GA4_PROPERTY="${GA4_PROPERTY_ID:-$(claude plugin config get ga4_property_id 2>/dev/null || echo "")}"GSC_SITE="${GOOGLE_SEARCH_CONSOLE_SITE:-$(claude plugin config get google_search_console_site 2>/dev/null || echo "")}"+GADS_DEV_TOKEN="${GOOGLE_ADS_DEVELOPER_TOKEN:-$(claude plugin config get google_ads_developer_token 2>/dev/null || echo "")}"+GADS_CLIENT_ID="${GOOGLE_ADS_CLIENT_ID:-$(claude plugin config get google_ads_client_id 2>/dev/null || echo "")}"+GADS_CLIENT_SECRET="${GOOGLE_ADS_CLIENT_SECRET:-$(claude plugin config get google_ads_client_secret 2>/dev/null || echo "")}"+GADS_REFRESH_TOKEN="${GOOGLE_ADS_REFRESH_TOKEN:-$(claude plugin config get google_ads_refresh_token 2>/dev/null || echo "")}"+GADS_CUSTOMER_ID="${GOOGLE_ADS_CUSTOMER_ID:-$(claude plugin config get google_ads_customer_id 2>/dev/null || echo "")}"+GADS_LOGIN_CUSTOMER_ID="${GOOGLE_ADS_LOGIN_CUSTOMER_ID:-$(claude plugin config get google_ads_login_customer_id 2>/dev/null || echo "")}"# Doppler fallbackif [ -z "$KLAVIYO_KEY" ]; then@@ -19,6 +25,12 @@ if [ -z "$META_TOKEN" ]; thenMETA_TOKEN="$(doppler secrets get META_ADS_TOKEN --plain 2>/dev/null || echo "")"META_ACCOUNT="$(doppler secrets get META_AD_ACCOUNT_ID --plain 2>/dev/null || echo "")"fi+if [ -z "$GADS_REFRESH_TOKEN" ]; then+ GADS_REFRESH_TOKEN="$(doppler secrets get GOOGLE_ADS_REFRESH_TOKEN --plain 2>/dev/null || echo "")"+fi++# Strip dashes from customer ID (API requires no dashes)+GADS_CUSTOMER_ID="${GADS_CUSTOMER_ID//-/}"TODAY=$(date +%Y-%m-%d)@@ -167,11 +179,39 @@ gather_gsc() {'{clicks: $clicks, impressions: $impressions, ctr: $ctr, avg_position: $position}'}+# --- Google Ads ---+gather_google_ads() {+ if [ -z "$GADS_REFRESH_TOKEN" ] || [ -z "$GADS_DEV_TOKEN" ]; then+ echo "null"+ return+ fi++ # Refresh access token+ GADS_ACCESS_TOKEN=$(curl -s -X POST https://oauth2.googleapis.com/token \+ --data "client_id=${GADS_CLIENT_ID}&client_secret=${GADS_CLIENT_SECRET}&refresh_token=${GADS_REFRESH_TOKEN}&grant_type=refresh_token" \+ | jq -r '.access_token // empty')+ if [ -z "$GADS_ACCESS_TOKEN" ]; then+ echo "null"+ return+ fi++ # Campaign summary (last 7 days)+ curl -s -X POST \+ "https://googleads.googleapis.com/v23/customers/${GADS_CUSTOMER_ID}/googleAds:searchStream" \+ -H "Content-Type: application/json" \+ -H "Authorization: Bearer ${GADS_ACCESS_TOKEN}" \+ -H "developer-token: ${GADS_DEV_TOKEN}" \+ ${GADS_LOGIN_CUSTOMER_ID:+-H "login-customer-id: ${GADS_LOGIN_CUSTOMER_ID}"} \+ --data-binary '{"query": "SELECT campaign.id, campaign.name, campaign.status, metrics.cost_micros, metrics.impressions, metrics.clicks, metrics.conversions, metrics.conversions_value FROM campaign WHERE segments.date DURING LAST_7_DAYS AND campaign.status != REMOVED ORDER BY metrics.cost_micros DESC LIMIT 20"}' \+ 2>/dev/null || echo "null"+}+# Run all in parallel (subshells)KLAVIYO_DATA=$(gather_klaviyo) &META_DATA=$(gather_meta) &GA4_DATA=$(gather_ga4) &GSC_DATA=$(gather_gsc) &+GADS_DATA=$(gather_google_ads) &wait# Emit unified JSON@@ -180,5 +220,6 @@ jq -n \--argjson meta "$META_DATA" \--argjson ga4 "$GA4_DATA" \--argjson gsc "$GSC_DATA" \+ --argjson google_ads "$GADS_DATA" \--arg date "$TODAY" \- '{date: $date, klaviyo: $klaviyo, meta: $meta, ga4: $ga4, gsc: $gsc}'+ '{date: $date, klaviyo: $klaviyo, meta: $meta, ga4: $ga4, gsc: $gsc, google_ads: $google_ads}'diff --git a/claude-ops/skills/setup/SKILL.md b/claude-ops/skills/setup/SKILL.mdindex c6970483..779b9657 100644--- a/claude-ops/skills/setup/SKILL.md+++ b/claude-ops/skills/setup/SKILL.md@@ -1778,14 +1778,15 @@ For any partner not in this table, always web search for current auth docs befor```bash# Shell envprintenv KLAVIYO_API_KEY KLAVIYO_PRIVATE_KEY META_ACCESS_TOKEN FACEBOOK_ACCESS_TOKEN META_AD_ACCOUNT_ID GA4_PROPERTY_ID GA_MEASUREMENT_ID 2>/dev/null+printenv GOOGLE_ADS_DEVELOPER_TOKEN GOOGLE_ADS_CLIENT_ID GOOGLE_ADS_CLIENT_SECRET GOOGLE_ADS_REFRESH_TOKEN GOOGLE_ADS_CUSTOMER_ID 2>/dev/null# Shell profiles-grep -h 'KLAVIYO\|META_\|FACEBOOK\|GA4\|GA_MEASUREMENT' ~/.zshrc ~/.bashrc ~/.zprofile ~/.envrc 2>/dev/null | grep -v '^#'+grep -h 'KLAVIYO\|META_\|FACEBOOK\|GA4\|GA_MEASUREMENT\|GOOGLE_ADS' ~/.zshrc ~/.bashrc ~/.zprofile ~/.envrc 2>/dev/null | grep -v '^#'# Doppler across all projectsfor proj in $(doppler projects --json 2>/dev/null | jq -r '.[].slug'); dodoppler secrets --project "$proj" --config prd --json 2>/dev/null | \- jq -r --arg proj "$proj" 'to_entries[] | select(.key | test("KLAVIYO|META|FACEBOOK|GA4|GOOGLE")) | "\(.key)=\(.value.computed) (doppler:\($proj)/prd)"'+ jq -r --arg proj "$proj" 'to_entries[] | select(.key | test("KLAVIYO|META|FACEBOOK|GA4|GOOGLE|GOOGLE_ADS")) | "\(.key)=\(.value.computed) (doppler:\($proj)/prd)"'done# Dashlane@@ -1799,14 +1800,25 @@ jq -r '.agents.defaults.env | to_entries[] | select(.key | test("KLAVIYO|META_|FCache these results — use them to pre-fill answers for each sub-step below. For each service below, check if already configured (check `$PREFS_PATH` under `marketing.*`, then the auto-scan results above) before prompting. If already set, show `✓ <service> — already configured` and offer `[Keep]` / `[Reconfigure]`.-Ask which marketing integrations to configure via `AskUserQuestion` with `multiSelect: true` (4 options — fits in one call):+Ask which marketing integrations to configure via two sequential `AskUserQuestion` calls with `multiSelect: true` (max 4 per Rule 1):++**First call** (primary integrations):++| Option | Header | Description |+| ----------------------- | ------------- | --------------------------------------------- |+| Klaviyo | klaviyo | Email/SMS marketing — private API key |+| Meta Ads | meta | Facebook/Instagram ads — access token + ad account ID |+| Google Ads | google-ads | Paid search ads — OAuth2 + developer token |+| More... | more | Google Analytics 4, Search Console |++If user selects `[More...]`, present **second call**:| Option | Header | Description || ----------------------- | -------- | --------------------------------------------- |-| Klaviyo | klaviyo | Email/SMS marketing — private API key |-| Meta Ads | meta | Facebook/Instagram ads — access token + ad account ID || Google Analytics 4 | ga4 | Web analytics — GA4 property ID |-| Google Search Console | gsc | SEO data — site URL (uses gcloud auth) |+| Google Search Console | gsc | SEO data — site URL (uses gcloud auth) |++Run the selected sub-step(s) below in the order selected.#### Klaviyo@@ -1838,6 +1850,100 @@ Smoke test:curl -s "https://graph.facebook.com/v20.0/$AD_ACCOUNT_ID/campaigns?access_token=$TOKEN&limit=1" | jq '.data | length'```+#### Google Ads++Google Ads requires three credential groups. Guide the user through each step sequentially.++**Step A — Developer Token:**+If `GOOGLE_ADS_DEVELOPER_TOKEN` was found in auto-scan, present it and offer `[Keep]` / `[Reconfigure]`.+Otherwise, ask via free text:+> Your Google Ads developer token (found in Google Ads → Tools & Settings → API Center).+> Note: New developer tokens start in "test" mode — they work against test accounts only. For production data, apply for Basic Access at https://ads.google.com/home/tools/manager-accounts/++**Step B — OAuth2 Client Credentials:**+If `GOOGLE_ADS_CLIENT_ID` and `GOOGLE_ADS_CLIENT_SECRET` were found in auto-scan, present and offer `[Keep]` / `[Reconfigure]`.+Otherwise, ask via free text (two prompts):+1. OAuth2 Client ID (from Google Cloud Console → APIs & Services → Credentials → OAuth 2.0 Client ID, type: Desktop app, Google Ads API must be enabled)+2. OAuth2 Client Secret (shown alongside the client ID)++**Step C — Refresh Token (browser OAuth flow):**+If `GOOGLE_ADS_REFRESH_TOKEN` was found in auto-scan, present and offer `[Keep]` / `[Reconfigure]`.+Otherwise, generate the auth URL and run the OAuth flow:++```bash+AUTH_URL="https://accounts.google.com/o/oauth2/auth?client_id=${GADS_CLIENT_ID}&redirect_uri=http://localhost:8080&response_type=code&scope=https://www.googleapis.com/auth/adwords&access_type=offline&prompt=consent"+open "$AUTH_URL" # macOS+```++Start a temporary localhost server to catch the redirect:+```bash+# One-liner node HTTP server to capture the auth code+node -e "require('http').createServer((req,res)=>{const code=new URL(req.url,'http://localhost').searchParams.get('code');if(code){res.end('Authorization code received. You can close this tab.');process.stdout.write(code);process.exit(0)}else{res.end('Waiting for auth...')}}).listen(8080)"+```++Run the server via Bash with `run_in_background: true`. Wait up to 120 seconds for the auth code.++If the localhost approach fails, fall back to asking the user to paste the code from the browser URL bar (the `code=` parameter).++Exchange code for refresh token:+```bash+TOKEN_RESP=$(curl -s -X POST https://oauth2.googleapis.com/token \+ --data "code=${AUTH_CODE}" \+ --data "client_id=${GADS_CLIENT_ID}" \+ --data "client_secret=${GADS_CLIENT_SECRET}" \+ --data "redirect_uri=http://localhost:8080" \+ --data "grant_type=authorization_code")+GADS_REFRESH_TOKEN=$(echo "$TOKEN_RESP" | jq -r '.refresh_token')+```++If `GADS_REFRESH_TOKEN` is null or empty, print error and offer retry.++Warning: If the user's Google Cloud project is in "testing" publishing status, the refresh token expires in 7 days. Warn: "Your OAuth app is in testing mode — tokens expire in 7 days. To get long-lived tokens, publish the app in Google Cloud Console → OAuth consent screen → Publish App."++**Step D — Customer ID:**+Use the refresh token to get an access token, then list accessible customers:+```bash+ACCESS_TOKEN=$(curl -s -X POST https://oauth2.googleapis.com/token \+ --data "client_id=${GADS_CLIENT_ID}&client_secret=${GADS_CLIENT_SECRET}&refresh_token=${GADS_REFRESH_TOKEN}&grant_type=refresh_token" | jq -r '.access_token')++CUSTOMERS=$(curl -s -X GET \+ "https://googleads.googleapis.com/v23/customers:listAccessibleCustomers" \+ -H "Authorization: Bearer ${ACCESS_TOKEN}" \+ -H "developer-token: ${GADS_DEV_TOKEN}")+```++If multiple accounts returned, present as `AskUserQuestion` options (max 4 per Rule 1 — paginate if more). If single account, auto-select. Store as `customer_id` (strip "customers/" prefix and dashes).++If any account is a manager (MCC) account, also store `login_customer_id`. Auto-detect by checking if `listAccessibleCustomers` returns both manager and client accounts.++**Step E — Smoke Test:**+```bash+curl -s -X GET "https://googleads.googleapis.com/v23/customers:listAccessibleCustomers" \+ -H "Authorization: Bearer ${ACCESS_TOKEN}" \+ -H "developer-token: ${GADS_DEV_TOKEN}"+```+Expect JSON with `resourceNames` array. If error, print the error and offer `[Retry]` / `[Skip]`.++**Step F — Save to preferences:**+```json+{+ "marketing": {+ "google_ads": {+ "developer_token": "<YOUR_DEVELOPER_TOKEN>",+ "client_id": "<YOUR_CLIENT_ID>.apps.googleusercontent.com",+ "client_secret": "GOCSPX-<YOUR_SECRET>",+ "refresh_token": "1//<YOUR_REFRESH_TOKEN>",+ "customer_id": "1234567890",+ "login_customer_id": "9876543210"+ }+ }+}+```++Same Doppler-reference pattern as Step 3i — prefer `doppler:KEY_NAME` over raw tokens when Doppler is configured.++Print: `[Google Ads] ✓ connected — customer ID: XXXXXXXXXX`+#### Google Analytics 4If `GA4_PROPERTY_ID` or `GA_MEASUREMENT_ID` was found in the auto-scan, present it. Only ask via free text if not found. Ask for the GA4 Property ID (explain: GA4 dashboard → Admin → Property Settings → Property ID, format: numeric, e.g. `123456789`).@@ -2695,7 +2801,7 @@ Re-run the detector and present a final status dashboard:✓ Core CLIs: jq, git, gh, aws, node✓ Channels: telegram, whatsapp, email✓ Ecommerce: shopify (<store_url>) ← omit line if not configured- ✓ Marketing: klaviyo, meta, ga4, gsc ← omit line if not configured+ ✓ Marketing: klaviyo, meta, google-ads, ga4, gsc ← omit line if not configured✓ Voice: bland, elevenlabs, groq ← omit line if not configured✓ Secrets: doppler → my-app/dev✓ MCPs: linear, sentry, vercel@@ -2754,6 +2860,7 @@ If `$ARGUMENTS` contains a specific section name, jump straight to that section:| `vault`, `password-manager`, `pm` | Step 3h || `ecom`, `shopify`, `store` | Step 3i || `marketing`, `klaviyo`, `ads`, `meta`, `ga4` | Step 3j |+| `google-ads`, `gads` | Step 3j (Google Ads) || `voice`, `bland`, `elevenlabs`, `tts` | Step 3k || `mcp` | Step 4 || `registry`, `projects` | Step 5 |