[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7D6R6GF7J15QF9TZGA1D2MQ":3,"skill-same:01M7D6R6GF7J15QF9TZGA1D2MQ":65},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":17,"publishedAt":18,"linkOnly":19,"markdownContent":20,"markdownBody":21,"frontMatter":22,"refName":36,"commitSha":37,"skillDirectory":38,"forksCount":13,"repositoryHtmlUrl":39,"repositoryHomepageUrl":6,"ownerHtmlUrl":40,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":41,"install":42,"resources":54},"01M7D6R6GF7J15QF9TZGA1D2MQ","schedule-ads",null,"Manage paid ads on AdManage.ai from declarative config - default schedules launches across Meta\u002FTikTok\u002FSnapchat\u002FPinterest\u002FLinkedIn (always PAUSED); create provisions Meta campaigns and ad sets.","LiamVisionary\u002Faeon-template","LiamVisionary","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F102138294?v=4","01M73379NZZ99TT4ZS17XR3Q9D","01M7D6D62V1SGGMKGT08Q1D2R8",0,"MIT","https:\u002F\u002Fgithub.com\u002FLiamVisionary\u002Faeon-template\u002Fblob\u002Fmain\u002Fskills\u002Fschedule-ads\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: schedule-ads\ndescription: Manage paid ads on AdManage.ai from declarative config - default schedules launches across Meta\u002FTikTok\u002FSnapchat\u002FPinterest\u002FLinkedIn (always PAUSED); create provisions Meta campaigns and ad sets.\nmetadata:\n  title: Schedule Ads\n  category: productivity\n  var: |\n    Selects which flow runs (parse from ${var}):\n    - empty \u002F unset (default) → SCHEDULE branch: read config.yaml, pick schedule\n      entries matching today, and launch those ads in-run via AdManage.ai.\n      Launches PAUSED by default; dailySpendCap circuit-breaker; never auto-activates\n      live spend.\n    - \"create\" → CREATE branch: read config.create.yaml, diff against\n      .admanage-state\u002Fcampaigns.json, and create the missing Meta campaigns + ad sets\n      in-run. On-demand; creates entities PAUSED; returned IDs are written back into\n      state so the schedule branch can launch into them.\n  schedule: \"0 8 * * *\"\n  commits: true\n  permissions:\n    - contents:write\n  tags:\n    - growth\n    - ads\n  requires:\n    - ADMANAGE_API_KEY\n---\n\n> **${var}** selects the flow. Empty\u002Funset = **schedule** (launch ads into existing ad sets). `create` = **create-campaign** (provision Meta campaigns + ad sets). Both are config-driven, PAUSED-by-default, and make the AdManage API calls **in-run** via `.\u002Fsecretcurl` (the `{ADMANAGE_API_KEY}` placeholder keeps the key off the command line), behind fail-closed spend guardrails.\n\nReads a declarative config, computes what to do, and makes the AdManage.ai API calls **in-run** via `.\u002Fsecretcurl`. The calls are an irreversible outbound side-effect (real ad spend), so they are each branch's **final** actions and run only behind the guardrails below (PAUSED-by-default, `dailySpendCap` circuit-breaker, dry-run). `ADMANAGE_API_KEY` is injected in-run via this skill's `requires:` — always write it as the `{ADMANAGE_API_KEY}` placeholder, never a bare `$ADMANAGE_API_KEY` (the Bash permission layer refuses that).\n\n## Preamble (both branches)\n\n1. Read `memory\u002FMEMORY.md` for context. Read the last ~3 days of `memory\u002Flogs\u002F` for recent launch \u002F provisioning activity — don't re-report a signal already logged.\n2. Parse `${var}`:\n   - empty \u002F unset → run the **Schedule branch** below.\n   - `create` → run the **Create branch** below.\n   - anything else → log `SCHEDULE_ADS_UNKNOWN_SELECTOR: \u003Cvalue>` and exit cleanly (no notify).\n3. Both branches spend real money on ad platforms. The shared safety posture (see each branch) is: PAUSED by default, config-only (never invent campaigns\u002Fcreative\u002Ftargeting), dry-run available, and exit silently when there's nothing to do.\n\n---\n\n# Schedule branch (default — empty `${var}`)\n\nReads `skills\u002Fschedule-ads\u002Fconfig.yaml`, picks schedule entries matching today, and launches those ads **in-run** via AdManage.ai (`POST \u002Fv1\u002Flaunch` through `.\u002Fsecretcurl`), behind the spend guardrails below.\n\n## Safety defaults (schedule)\n\nThis branch **spends real money on ad platforms**. Guardrails, in priority order:\n\n1. **PAUSED by default.** Every launch request sets the entity to PAUSED. The operator has to resume manually in the AdManage dashboard before spend starts. `launchPaused: false` in config is the explicit opt-out.\n2. **Daily spend cap.** Before launching, the branch checks `GET \u002Fv1\u002Fspend\u002Fdaily` for today. If spend ≥ `dailySpendCap` in the config, all launches are skipped and a warning is notified. If the spend figure can't be verified (malformed \u002F empty response), **fail closed** — skip and notify, don't launch. This is a circuit breaker, not a budget enforcer — platform budgets still apply.\n3. **Dry-run mode.** If `DRY_RUN=true` in env or `dryRun: true` in config, the branch builds the payloads, writes them to `.pending-admanage\u002Fdryrun\u002F`, notifies what *would* launch, and exits without calling the API.\n4. **Config-only.** The branch does not invent campaigns, creative, or targeting. If there's no schedule for today, it exits cleanly with no API calls.\n5. **Single source of truth.** All ads\u002Fcampaigns\u002Ftargeting live in `config.yaml`. The branch never generates new creative on the fly.\n\n## Network note (schedule)\n\nLaunching ads is an irreversible outbound side-effect (real ad spend), so it is the branch's **final** action and runs only after the guardrails above pass:\n\n- Auth'd calls go through `.\u002Fsecretcurl` with the `{ADMANAGE_API_KEY}` placeholder — never a bare `$ADMANAGE_API_KEY` (the Bash permission layer refuses that). `ADMANAGE_API_KEY` is injected in-run via `requires:`.\n- The branch checks the daily spend cap (`GET \u002Fv1\u002Fspend\u002Fdaily`), then per batch calls `POST \u002Fv1\u002Flaunch`, polls `GET \u002Fv1\u002Fbatch-status\u002F{id}` to a terminal state, and reports via `.\u002Fnotify`.\n- If `ADMANAGE_API_KEY` is unset, or the launch\u002Fspend call fails, skip the launch and notify — do not retry blindly. There is no deferred postprocess fallback.\n\n## Steps (schedule)\n\n1. **Load config.** Read `skills\u002Fschedule-ads\u002Fconfig.yaml`. If the file doesn't exist, log `SCHEDULE_ADS_NOT_CONFIGURED` and exit cleanly (no notify, no error). The example template lives next to this file as `config.example.yaml`.\n\n2. **Validate config shape.** Required top-level keys: `defaults` (with `adAccountId`, `workspaceId`, `page`), and `schedules` (array). If either is missing, file an issue in `memory\u002Fissues\u002F` per the CLAUDE.md issue tracker convention, notify once, and exit.\n\n3. **Pick today's schedule entries.** For each entry in `schedules`, match against today's date:\n   - `when.everyDay: true` → always matches.\n   - `when.dayOfWeek: monday` (or any weekday name, lowercase) → matches if today is that weekday (UTC).\n   - `when.date: \"2026-04-25\"` → matches only on that exact date.\n   - `when.dates: [\"2026-04-25\", \"2026-05-02\"]` → matches if today is in the list.\n   - `when.cron: \"0 8 * * 1\"` → (advanced) matches if today satisfies the cron. Optional — skip if it's too much parsing effort.\n\n   If no entries match today, log `SCHEDULE_ADS_NOTHING_TODAY` and exit cleanly (no notify).\n\n4. **Build launch payloads.** For each matching schedule entry, construct the AdManage `POST \u002Fv1\u002Flaunch` body:\n   ```json\n   {\n     \"ads\": [\n       {\n         \"adName\": \"\u003Ctemplated from ad.adName, {date} replaced>\",\n         \"adAccountId\": \"\u003Cfrom defaults or entry override>\",\n         \"workspaceId\": \"\u003Cfrom defaults or entry override>\",\n         \"title\": \"\u003Cfrom ad>\",\n         \"description\": \"\u003Cfrom ad>\",\n         \"cta\": \"\u003Cfrom ad or defaults.cta>\",\n         \"link\": \"\u003Cfrom ad>\",\n         \"page\": \"\u003Cfrom defaults>\",\n         \"insta\": \"\u003Cfrom defaults, Meta only>\",\n         \"adSets\": [ { \"value\": \"\u003Cid>\", \"label\": \"\u003Cname>\" } ],\n         \"media\": [ { \"url\": \"\u003Cmedia url>\" } ],\n         \"status\": \"PAUSED\"\n       }\n     ]\n   }\n   ```\n   Enforce `status: PAUSED` on every ad unless `defaults.launchPaused` is explicitly `false`. Never strip it silently.\n\n   Template substitutions inside string fields:\n   - `{date}` → today's ISO date (YYYY-MM-DD)\n   - `{dateHuman}` → \"April 21, 2026\" style\n\n5. **Pre-flight validation.** For each payload:\n   - `media[*].url` must be an absolute `https:\u002F\u002F` URL. Reject entries with local paths or obviously broken URLs.\n   - `adSets[*].value` must be a non-empty string. If missing, skip the entry with a warning in the log.\n   - For Meta entries (`adAccountId` starts with `act_`): `page` and `insta` must be set. TikTok\u002FSnapchat\u002Fetc. have their own requirements — don't block on Meta-specific fields for other platforms.\n   - `title` and `description` must be non-empty.\n\n   Drop invalid entries, keep going. Log which ones were skipped and why.\n\n6. **Handle dry-run.** If `DRY_RUN=true` or `config.dryRun: true`:\n   - Write payloads to `.pending-admanage\u002Fdryrun\u002F{schedule-name}-{timestamp}.json`.\n   - Notify a preview (see step 9) but with `[DRY RUN]` prefix.\n   - Skip step 7.\n   - This mode exists for the operator to sanity-check before arming real launches.\n\n7. **Launch in-run.** This is the branch's final action — spends real money, so run the guardrails first. Only `.\u002Fsecretcurl`, `jq`, `date`, `echo`, `mkdir`, `grep`, `python3`, and the `Write` tool are available.\n\n   a. **Config check.** `[ -n \"${ADMANAGE_API_KEY:+x}\" ]` (the `${VAR:+x}` form — a bare `$ADMANAGE_API_KEY` trips the secret-expansion analyzer and reads as unset). If unset → notify \"ads computed but ADMANAGE_API_KEY missing — nothing launched\" and stop.\n\n   b. **Daily spend circuit-breaker (once).** Take the strictest `dailySpendCap` (`CAP`) across today's payloads. If set, read today's spend and **fail closed** unless it's a clean number *below* the cap:\n      ```bash\n      SPEND=$(.\u002Fsecretcurl -sS --max-time 30 -H \"Authorization: Bearer {ADMANAGE_API_KEY}\" \\\n        \"https:\u002F\u002Fapi.admanage.ai\u002Fv1\u002Fspend\u002Fdaily?startDate=$TODAY&endDate=$TODAY\" | jq -r '.metadata.totalSpend \u002F\u002F \"\"')\n      echo \"$SPEND\" | grep -qE '^[0-9]+(\\.[0-9]+)?$' || { echo \"spend unverifiable — fail closed\"; exit 0; }\n      echo \"$CAP\"   | grep -qE '^[0-9]+(\\.[0-9]+)?$' || { echo \"dailySpendCap not numeric — fail closed\"; exit 0; }\n      python3 -c \"import sys; sys.exit(0 if float(sys.argv[1])>=float(sys.argv[2]) else 1)\" \"$SPEND\" \"$CAP\" \\\n        && { echo \"daily spend cap tripped (today=$SPEND cap=$CAP) — launching nothing\"; exit 0; }\n      ```\n   c. **Per batch: launch, then poll.** For each payload `{ ads: [ ... ] }`:\n      ```bash\n      RESP=$(.\u002Fsecretcurl -sS --max-time 60 -w 'http=%{http_code}\\n' -X POST \"https:\u002F\u002Fapi.admanage.ai\u002Fv1\u002Flaunch\" \\\n        -H \"Authorization: Bearer {ADMANAGE_API_KEY}\" -H \"Content-Type: application\u002Fjson\" -d \"$PAYLOAD\")\n      # success => .success==true and .adBatchId set; else record FAILED (.message\u002F.error) and continue.\n      # Poll GET \u002Fv1\u002Fbatch-status\u002F$BATCH_ID (~90s, 5s interval) until .summaryStatus is success|error.\n      ```\n      Record each batch's outcome (ok \u002F error \u002F still-running-after-timeout) for the notify. Ads launch **PAUSED** (the payload sets it) unless `launchPaused: false`.\n\n8. **Write artifact to `output\u002F.chains\u002Fschedule-ads.md`** so downstream chain consumers can read what was queued. Format:\n   ```markdown\n   # Schedule Ads — ${today}\n\n   Queued: N launches across M schedules.\n   Dry-run: yes|no.\n\n   ## Entries\n   - \u003Cschedule name>: \u003Cad count> ads, platform=\u003Cmeta|tiktok|…>, paused=\u003Cbool>\n     - \u003CadName> — \u003Ctitle>\n   ```\n\n9. **Notify** via `.\u002Fnotify`. Keep it tight:\n   ```\n   *Ads queued — ${today}${dryRunSuffix}*\n\n   \u003CN> launches queued from \u003CM> schedules.\n\n   - \u003Cschedule name> → \u003Cad count> ads \u003Cplatform> \u003Cpaused|LIVE>\n     \"\u003Cfirst adName>\"\n   - ...\n\n   \u003Cif dry-run>\n   no API calls made — remove DRY_RUN to arm.\n   \u003Celse>\n   launched via AdManage (PAUSED) — resume in the dashboard to start delivery.\n   ```\n   If nothing matched today (no launches), don't notify at all.\n\n10. **Log** — see the shared **Log** section below (discriminator: `schedule`).\n\n## Config schema (schedule)\n\nSee `skills\u002Fschedule-ads\u002Fconfig.example.yaml` for a filled-in template. Minimum viable config:\n\n```yaml\ndefaults:\n  adAccountId: act_XXXXXXXXXX\n  workspaceId: XXXXXXXXXXXX\n  page: XXXXXXXXXXXX         # Meta Page ID\n  insta: XXXXXXXXXXXX        # Instagram user ID\n  cta: LEARN_MORE\n  launchPaused: true         # NEVER change this without thought\n  dailySpendCap: 50          # USD. Circuit breaker.\n  dryRun: false\n\nschedules:\n  - name: weekly-promo\n    platform: meta\n    when: { dayOfWeek: monday }\n    adSets:\n      - { value: \"120xxxxxxxxxxxxx\", label: \"US Broad 25-55\" }\n    ads:\n      - adName: \"Weekly promo — {date}\"\n        title: \"Headline copy here\"\n        description: \"Supporting copy in a sentence or two.\"\n        cta: LEARN_MORE\n        link: https:\u002F\u002Fexample.com\n        media:\n          - url: https:\u002F\u002Fmedia.admanage.ai\u002Fyour-account\u002Fhero.mp4\n```\n\n## What the schedule branch does NOT do\n\n- **Does not create campaigns or ad sets.** Those must pre-exist in AdManage — use the **`create` branch** (`${var}=create`), the dashboard, or `POST \u002Fv1\u002Fmanage\u002Fcreate-campaign` separately. This branch only launches *ads into existing ad sets*.\n- **Does not upload creative.** Media URLs must be hosted somewhere accessible (AdManage CDN, your own CDN, Supabase, wherever). If you need upload, add a separate `upload-ad-media` skill that calls `POST \u002Fv1\u002Fmedia\u002Fupload\u002Furl`.\n- **Does not generate copy.** Titles\u002Fdescriptions come from config. If the operator wants AI-written variants, a separate skill can write them into `config.yaml` and commit — keeps the launch path boring and auditable.\n- **Does not manage budgets, bids, or targeting.** Everything downstream of launch (scaling, pausing losers, budget shifts) lives in follow-up skills or the dashboard.\n- **Does not launch to Google Ads, Axon, or Taboola** in v1. Config schema is deliberately Meta\u002FTikTok\u002FSnapchat\u002FPinterest\u002FLinkedIn-shaped. Adding Google\u002FAxon later is straightforward but their launch shapes differ enough to need their own validation.\n\n---\n\n# Create branch (`${var}=create`)\n\nReads `skills\u002Fschedule-ads\u002Fconfig.create.yaml`, figures out which campaigns\u002Fad sets don't exist yet, and creates them **in-run** via AdManage.ai (`\u002Fv1\u002Fmanage\u002Fcreate-*` through `.\u002Fsecretcurl`) — campaigns first, then ad sets referencing the returned campaign IDs — writing the new IDs back to `.admanage-state\u002Fcampaigns.json`.\n\nThis branch is **on-demand** — invoke it manually when you want to provision new campaigns, then reference the returned IDs in `skills\u002Fschedule-ads\u002Fconfig.yaml` (schedule branch) to launch creatives into them.\n\nRead `.admanage-state\u002Fcampaigns.json` (if it exists) to see what's already created.\n\n## What this branch provisions\n\nTwo entity types only:\n1. **Meta campaigns** — name, objective, budget, bid strategy, promoted object.\n2. **Meta ad sets** — name, budget, optimization goal, targeting (geo\u002Fage\u002Fplatforms), destination.\n\nEverything else (TikTok\u002FSnapchat\u002FPinterest\u002FLinkedIn campaigns, advanced Meta fields like valueRuleSetId or Advantage+ catalog) is v2+. The shape below is intentionally minimal.\n\n## Safety defaults (create)\n\nSame posture as the schedule branch:\n\n1. **PAUSED by default.** Every campaign + ad set is created with `status: PAUSED`. No surprise spend.\n2. **Idempotent.** The branch tracks created entities in `.admanage-state\u002Fcampaigns.json`. If a campaign name already exists in state, it's skipped. Run it twice → no duplicates.\n3. **Dry-run mode.** `DRY_RUN=true` or `config.dryRun: true` → payloads written to `.pending-admanage\u002Fdryrun-create\u002F`, notified, no API calls.\n4. **Config-only.** No config file → exit silently. No invented campaigns, no autonomous provisioning.\n\n## Network note (create)\n\nProvisioning campaigns and ad sets is an irreversible outbound side-effect, so it is the branch's **final** action and runs in-run only after the diff + validation pass:\n\n- Auth'd calls go through `.\u002Fsecretcurl` with the `{ADMANAGE_API_KEY}` placeholder — never a bare `$ADMANAGE_API_KEY`. The key is injected in-run via `requires:`.\n- **Order matters:** create all campaigns first (`POST \u002Fv1\u002Fmanage\u002Fcreate-campaign`), keep a config-name → campaignId map, then create ad sets (`POST \u002Fv1\u002Fmanage\u002Fcreate-adset`) substituting each parent's real campaign ID. Write every new ID back to `.admanage-state\u002Fcampaigns.json` as you go (the workflow's Commit step persists it).\n- If `ADMANAGE_API_KEY` is unset, or a create call fails, record the failure and continue with the rest — never retry blindly, never invent IDs. An ad set whose parent campaign failed to create is skipped. There is no deferred postprocess fallback.\n\n## Steps (create)\n\n1. **Load config.** Read `skills\u002Fschedule-ads\u002Fconfig.create.yaml`. If it doesn't exist, log `CREATE_CAMPAIGN_NOT_CONFIGURED` and exit cleanly (no notify). The example template lives next to this file as `config.create.example.yaml`.\n\n2. **Load state.** Read `.admanage-state\u002Fcampaigns.json`. If it doesn't exist, treat as empty. Shape:\n   ```json\n   {\n     \"campaigns\": [\n       {\n         \"configName\": \"Prospecting — Q2 2026\",\n         \"campaignId\": \"120251616228380456\",\n         \"adAccountId\": \"act_xxx\",\n         \"createdAt\": \"2026-04-21T08:00:00Z\",\n         \"adSets\": [\n           {\n             \"configName\": \"US Broad 25-54\",\n             \"adSetId\": \"120251616242460456\",\n             \"createdAt\": \"2026-04-21T08:00:04Z\"\n           }\n         ]\n       }\n     ]\n   }\n   ```\n\n3. **Validate config shape.** Required: `defaults.adAccountId`, `defaults.workspaceId`, `campaigns[]`. Each campaign needs `name` and `objective`. Each ad set needs `name`, and either `optimizationGoal` (explicit) or a compatible parent objective. If validation fails, file an issue in `memory\u002Fissues\u002F` and exit.\n\n4. **Compute diff.** For each campaign in config:\n   - Match against state by exact `name`. If present, mark as `existing`.\n   - If missing, mark as `new` and queue a campaign create.\n   - For each ad set under the campaign, match against the parent's `adSets[]` in state by name. If missing, mark it for creation (carrying a `parentCampaignConfigName` reference you resolve to a real campaign ID in-run, once the parent campaign create returns).\n\n   If nothing is new, log `CREATE_CAMPAIGN_ALL_EXIST` and exit without notify.\n\n5. **Build campaign create payloads.** Per the AdManage `POST \u002Fv1\u002Fmanage\u002Fcreate-campaign` shape:\n   ```json\n   {\n     \"businessId\": \"\u003CadAccountId>\",\n     \"workspaceId\": \"\u003CworkspaceId>\",\n     \"name\": \"\u003Ccampaign.name>\",\n     \"objective\": \"\u003Ccampaign.objective>\",\n     \"status\": \"PAUSED\",\n     \"buyingType\": \"AUCTION\",\n     \"specialAdCategories\": [],\n     \"dailyBudget\": \u003Cnumber>,\n     \"bidStrategy\": \"\u003CLOWEST_COST_WITHOUT_CAP | LOWEST_COST_WITH_BID_CAP | COST_CAP | ...>\",\n     \"promotedObject\": { ... }\n   }\n   ```\n   Skip keys that are `null`\u002Fabsent in config — don't send empty strings. Always force `status: PAUSED` unless `defaults.launchPaused: false` is set explicitly.\n\n6. **Build ad-set create payloads.** Per `POST \u002Fv1\u002Fmanage\u002Fcreate-adset`:\n   ```json\n   {\n     \"businessId\": \"\u003CadAccountId>\",\n     \"workspaceId\": \"\u003CworkspaceId>\",\n     \"campaignId\": \"__RESOLVE_FROM_PARENT__\",\n     \"parentCampaignConfigName\": \"\u003Ccampaign.name>\",\n     \"name\": \"\u003CadSet.name>\",\n     \"status\": \"PAUSED\",\n     \"dailyBudget\": \u003Cnumber>,\n     \"billingEvent\": \"IMPRESSIONS\",\n     \"optimizationGoal\": \"\u003CLANDING_PAGE_VIEWS | OFFSITE_CONVERSIONS | ...>\",\n     \"destinationType\": \"\u003CWEBSITE | PHONE_CALL | MESSAGING_... | ...>\",\n     \"targeting\": { ... },\n     \"promotedObject\": { ... }\n   }\n   ```\n\n   The `__RESOLVE_FROM_PARENT__` sentinel + `parentCampaignConfigName` marks an ad set whose `campaignId` you fill in-run, from the map built as each campaign create returns (step 9b). If the parent campaign was *existing* (already in state), write the real campaign ID directly and drop the sentinel.\n\n7. **Pre-flight validation.**\n   - `adAccountId` must start with `act_` (this branch is Meta-only in v1).\n   - `dailyBudget` must be a positive number in dollars (not cents).\n   - `objective` must be one of the documented Meta objectives: `OUTCOME_TRAFFIC`, `OUTCOME_ENGAGEMENT`, `OUTCOME_LEADS`, `OUTCOME_AWARENESS`, `OUTCOME_SALES`, `OUTCOME_APP_PROMOTION`.\n   - Targeting `geo_locations.countries` must be a non-empty array.\n   Drop invalid entries, keep going, log what was skipped and why.\n\n8. **Handle dry-run.** If `DRY_RUN=true` or `config.dryRun: true`: write payloads to `.pending-admanage\u002Fdryrun-create\u002F` instead, notify with a `[DRY RUN]` prefix, skip step 9.\n\n9. **Create in-run.** This is the branch's final action — provisions real entities, so run only after the diff + pre-flight pass. Only `.\u002Fsecretcurl`, `jq`, `date`, `echo`, `python3`, and the `Write` tool are available (no `mv`). Seed `.admanage-state\u002Fcampaigns.json` to `{\"campaigns\":[]}` if missing.\n\n   a. **Config check.** `[ -n \"${ADMANAGE_API_KEY:+x}\" ]` (the `${VAR:+x}` form — a bare `$ADMANAGE_API_KEY` trips the secret-expansion analyzer and reads as unset). If unset, notify \"campaigns computed but ADMANAGE_API_KEY missing — nothing created\" and stop (state unchanged).\n\n   b. **Campaigns first.** For each *new* campaign, `POST \u002Fv1\u002Fmanage\u002Fcreate-campaign`:\n      ```bash\n      RESP=$(.\u002Fsecretcurl -sS --max-time 60 -w 'http=%{http_code}\\n' -X POST \\\n        \"https:\u002F\u002Fapi.admanage.ai\u002Fv1\u002Fmanage\u002Fcreate-campaign\" \\\n        -H \"Authorization: Bearer {ADMANAGE_API_KEY}\" -H \"Content-Type: application\u002Fjson\" -d \"$PAYLOAD\")\n      # success => .success==true and .campaignId set.\n      ```\n      On success: remember `configName → campaignId` (for step 9c) and append `{configName, campaignId, adAccountId, createdAt, adSets:[]}` to `.admanage-state\u002Fcampaigns.json`. On failure: record the error, skip this campaign's ad sets.\n\n   c. **Then ad sets.** For each new ad set, resolve `campaignId`: if it's `__RESOLVE_FROM_PARENT__`, look it up by `parentCampaignConfigName` in the map from 9b **or** existing state — if the parent isn't found (its create failed), skip the ad set with a warning. Then `POST \u002Fv1\u002Fmanage\u002Fcreate-adset` (same `.\u002Fsecretcurl` shape). On success: append `{configName, adSetId, createdAt}` under the parent campaign in `.admanage-state\u002Fcampaigns.json` (via `python3`\u002F`Write` — no `mv`).\n\n   Ordering is explicit here (campaigns loop fully before the ad-sets loop), so children always reference a resolved parent ID.\n\n10. **Write artifact to `output\u002F.chains\u002Fcreate-campaign.md`** so chain consumers can see what was queued:\n    ```markdown\n    # Create Campaign — ${today}\n\n    New campaigns: N.\n    New ad sets: M.\n    Dry-run: yes|no.\n\n    ## Campaigns\n    - \u003Cname> — \u003Cobjective>, $\u003CdailyBudget>\u002Fday\n      - ad set: \u003Cname> — \u003CoptimizationGoal>, $\u003CdailyBudget>\u002Fday, \u003Ccountries>\n\n    ## Skipped (already exist)\n    - \u003Cname>\n    ```\n\n11. **Notify via `.\u002Fnotify`.** Tight format:\n    ```\n    *Campaigns queued — ${today}${dryRunSuffix}*\n\n    \u003CN> campaigns, \u003CM> ad sets queued for creation.\n\n    - \u003Ccampaign name>\n      - adset: \u003Cadset name> — \u003Ccountry>, $\u003Cbudget>\u002Fday\n\n    \u003Cif dry-run>\n    no API calls made — remove DRY_RUN to arm.\n    \u003Celse>\n    created via AdManage (PAUSED); new IDs written to .admanage-state\u002Fcampaigns.json.\n    ```\n    If nothing is new, don't notify at all.\n\n12. **Log** — see the shared **Log** section below (discriminator: `create`).\n\n## Config schema (create)\n\nSee `skills\u002Fschedule-ads\u002Fconfig.create.example.yaml` for a filled-in template. Minimum viable config:\n\n```yaml\ndefaults:\n  adAccountId: act_XXXXXXXXXX\n  workspaceId: XXXXXXXXXXXX\n  launchPaused: true               # never flip without a reason\n  dryRun: false                    # true = build, don't call\n\ncampaigns:\n  - name: \"Prospecting — Q2 2026\"\n    objective: OUTCOME_TRAFFIC\n    dailyBudget: 50\n    bidStrategy: LOWEST_COST_WITHOUT_CAP\n    promotedObject:\n      pixel_id: \"123456789012345\"\n    adSets:\n      - name: \"US Broad 25-54\"\n        dailyBudget: 15\n        optimizationGoal: LANDING_PAGE_VIEWS\n        destinationType: WEBSITE\n        targeting:\n          geo_locations: { countries: [\"US\"] }\n          age_min: 25\n          age_max: 54\n          publisher_platforms: [facebook, instagram]\n```\n\n## Interaction with the schedule branch\n\nThe create branch writes new IDs to `.admanage-state\u002Fcampaigns.json` **within the same run**; from there they're yours to reference in `skills\u002Fschedule-ads\u002Fconfig.yaml` (schedule branch) under `adSets[].value`. The two flows are intentionally decoupled:\n\n- **create branch** provisions structure (container).\n- **schedule branch** launches creative into that structure (contents).\n\nThey still don't auto-chain — the schedule branch reads `config.yaml`, which you edit by hand. Pattern is: run `${var}=create` (provisions + writes IDs in-run) → read the new IDs from `.admanage-state\u002Fcampaigns.json` \u002F the create-run notify → copy them into `config.yaml` → next default (schedule) run launches into them.\n\n## What the create branch does NOT do\n\n- **Doesn't touch existing campaigns.** Once a campaign is in state, this branch leaves it alone. Budget changes, bid changes, status flips, renames — all handled elsewhere (dashboard or a separate skill).\n- **Doesn't delete or archive.** No destructive paths.\n- **Doesn't provision media, pages, or pixels.** Pixel IDs must already exist in AdManage. Use `GET \u002Fv1\u002Fconversions\u002Fpixels` to discover them.\n- **Doesn't create TikTok \u002F Snapchat \u002F Pinterest \u002F LinkedIn** structures. Those have different payload shapes and live in v2.\n- **Doesn't resume paused campaigns.** PAUSED is the end state; the operator unpauses manually when ready.\n\n---\n\n## Log (both branches)\n\nAppend to `memory\u002Flogs\u002F${today}.md` under ONE `### schedule-ads` heading. First bullet is a discriminator naming which branch ran.\n\n**Schedule branch:**\n```\n### schedule-ads\n- Branch: schedule\n- Schedules matching today: \u003Cnames>\n- Launches: \u003Ccount> (dry-run: \u003Cbool>)\n- Batch results: \u003Cok\u002Ferror\u002Ftimeout summary> (live) | dry-run preview in .pending-admanage\u002Fdryrun\u002F\n```\n\n**Create branch:**\n```\n### schedule-ads\n- Branch: create\n- New campaigns created: \u003Ccount> (ok\u002Ffail)\n- New ad sets created: \u003Ccount> (ok\u002Ffail)\n- State: new IDs written to .admanage-state\u002Fcampaigns.json (live) | dry-run preview in .pending-admanage\u002Fdryrun-create\u002F\n```\n\n## Environment Variables\n\n- `ADMANAGE_API_KEY` — the AdManage.ai API key, injected in-run via this skill's `requires:` and used by both branches for the `\u002Fv1\u002F*` calls. Always pass it as the `{ADMANAGE_API_KEY}` placeholder to `.\u002Fsecretcurl`, never a bare `$ADMANAGE_API_KEY` on the command line.\n- `DRY_RUN` — optional. If `true`, forces dry-run mode regardless of config, in whichever branch runs.\n- Notification channels configured via repo secrets (see CLAUDE.md).\n\n## Output\n\nEnd with a `## Summary` block naming the branch that ran:\n- **schedule:** schedules matched today, payload count, dry-run yes\u002Fno, files written.\n- **create:** new campaigns queued, new ad sets queued, skipped (already-exist) count, dry-run yes\u002Fno, files written.\n","> **${var}** selects the flow. Empty\u002Funset = **schedule** (launch ads into existing ad sets). `create` = **create-campaign** (provision Meta campaigns + ad sets). Both are config-driven, PAUSED-by-default, and make the AdManage API calls **in-run** via `.\u002Fsecretcurl` (the `{ADMANAGE_API_KEY}` placeholder keeps the key off the command line), behind fail-closed spend guardrails.\n\nReads a declarative config, computes what to do, and makes the AdManage.ai API calls **in-run** via `.\u002Fsecretcurl`. The calls are an irreversible outbound side-effect (real ad spend), so they are each branch's **final** actions and run only behind the guardrails below (PAUSED-by-default, `dailySpendCap` circuit-breaker, dry-run). `ADMANAGE_API_KEY` is injected in-run via this skill's `requires:` — always write it as the `{ADMANAGE_API_KEY}` placeholder, never a bare `$ADMANAGE_API_KEY` (the Bash permission layer refuses that).\n\n## Preamble (both branches)\n\n1. Read `memory\u002FMEMORY.md` for context. Read the last ~3 days of `memory\u002Flogs\u002F` for recent launch \u002F provisioning activity — don't re-report a signal already logged.\n2. Parse `${var}`:\n   - empty \u002F unset → run the **Schedule branch** below.\n   - `create` → run the **Create branch** below.\n   - anything else → log `SCHEDULE_ADS_UNKNOWN_SELECTOR: \u003Cvalue>` and exit cleanly (no notify).\n3. Both branches spend real money on ad platforms. The shared safety posture (see each branch) is: PAUSED by default, config-only (never invent campaigns\u002Fcreative\u002Ftargeting), dry-run available, and exit silently when there's nothing to do.\n\n---\n\n# Schedule branch (default — empty `${var}`)\n\nReads `skills\u002Fschedule-ads\u002Fconfig.yaml`, picks schedule entries matching today, and launches those ads **in-run** via AdManage.ai (`POST \u002Fv1\u002Flaunch` through `.\u002Fsecretcurl`), behind the spend guardrails below.\n\n## Safety defaults (schedule)\n\nThis branch **spends real money on ad platforms**. Guardrails, in priority order:\n\n1. **PAUSED by default.** Every launch request sets the entity to PAUSED. The operator has to resume manually in the AdManage dashboard before spend starts. `launchPaused: false` in config is the explicit opt-out.\n2. **Daily spend cap.** Before launching, the branch checks `GET \u002Fv1\u002Fspend\u002Fdaily` for today. If spend ≥ `dailySpendCap` in the config, all launches are skipped and a warning is notified. If the spend figure can't be verified (malformed \u002F empty response), **fail closed** — skip and notify, don't launch. This is a circuit breaker, not a budget enforcer — platform budgets still apply.\n3. **Dry-run mode.** If `DRY_RUN=true` in env or `dryRun: true` in config, the branch builds the payloads, writes them to `.pending-admanage\u002Fdryrun\u002F`, notifies what *would* launch, and exits without calling the API.\n4. **Config-only.** The branch does not invent campaigns, creative, or targeting. If there's no schedule for today, it exits cleanly with no API calls.\n5. **Single source of truth.** All ads\u002Fcampaigns\u002Ftargeting live in `config.yaml`. The branch never generates new creative on the fly.\n\n## Network note (schedule)\n\nLaunching ads is an irreversible outbound side-effect (real ad spend), so it is the branch's **final** action and runs only after the guardrails above pass:\n\n- Auth'd calls go through `.\u002Fsecretcurl` with the `{ADMANAGE_API_KEY}` placeholder — never a bare `$ADMANAGE_API_KEY` (the Bash permission layer refuses that). `ADMANAGE_API_KEY` is injected in-run via `requires:`.\n- The branch checks the daily spend cap (`GET \u002Fv1\u002Fspend\u002Fdaily`), then per batch calls `POST \u002Fv1\u002Flaunch`, polls `GET \u002Fv1\u002Fbatch-status\u002F{id}` to a terminal state, and reports via `.\u002Fnotify`.\n- If `ADMANAGE_API_KEY` is unset, or the launch\u002Fspend call fails, skip the launch and notify — do not retry blindly. There is no deferred postprocess fallback.\n\n## Steps (schedule)\n\n1. **Load config.** Read `skills\u002Fschedule-ads\u002Fconfig.yaml`. If the file doesn't exist, log `SCHEDULE_ADS_NOT_CONFIGURED` and exit cleanly (no notify, no error). The example template lives next to this file as `config.example.yaml`.\n\n2. **Validate config shape.** Required top-level keys: `defaults` (with `adAccountId`, `workspaceId`, `page`), and `schedules` (array). If either is missing, file an issue in `memory\u002Fissues\u002F` per the CLAUDE.md issue tracker convention, notify once, and exit.\n\n3. **Pick today's schedule entries.** For each entry in `schedules`, match against today's date:\n   - `when.everyDay: true` → always matches.\n   - `when.dayOfWeek: monday` (or any weekday name, lowercase) → matches if today is that weekday (UTC).\n   - `when.date: \"2026-04-25\"` → matches only on that exact date.\n   - `when.dates: [\"2026-04-25\", \"2026-05-02\"]` → matches if today is in the list.\n   - `when.cron: \"0 8 * * 1\"` → (advanced) matches if today satisfies the cron. Optional — skip if it's too much parsing effort.\n\n   If no entries match today, log `SCHEDULE_ADS_NOTHING_TODAY` and exit cleanly (no notify).\n\n4. **Build launch payloads.** For each matching schedule entry, construct the AdManage `POST \u002Fv1\u002Flaunch` body:\n   ```json\n   {\n     \"ads\": [\n       {\n         \"adName\": \"\u003Ctemplated from ad.adName, {date} replaced>\",\n         \"adAccountId\": \"\u003Cfrom defaults or entry override>\",\n         \"workspaceId\": \"\u003Cfrom defaults or entry override>\",\n         \"title\": \"\u003Cfrom ad>\",\n         \"description\": \"\u003Cfrom ad>\",\n         \"cta\": \"\u003Cfrom ad or defaults.cta>\",\n         \"link\": \"\u003Cfrom ad>\",\n         \"page\": \"\u003Cfrom defaults>\",\n         \"insta\": \"\u003Cfrom defaults, Meta only>\",\n         \"adSets\": [ { \"value\": \"\u003Cid>\", \"label\": \"\u003Cname>\" } ],\n         \"media\": [ { \"url\": \"\u003Cmedia url>\" } ],\n         \"status\": \"PAUSED\"\n       }\n     ]\n   }\n   ```\n   Enforce `status: PAUSED` on every ad unless `defaults.launchPaused` is explicitly `false`. Never strip it silently.\n\n   Template substitutions inside string fields:\n   - `{date}` → today's ISO date (YYYY-MM-DD)\n   - `{dateHuman}` → \"April 21, 2026\" style\n\n5. **Pre-flight validation.** For each payload:\n   - `media[*].url` must be an absolute `https:\u002F\u002F` URL. Reject entries with local paths or obviously broken URLs.\n   - `adSets[*].value` must be a non-empty string. If missing, skip the entry with a warning in the log.\n   - For Meta entries (`adAccountId` starts with `act_`): `page` and `insta` must be set. TikTok\u002FSnapchat\u002Fetc. have their own requirements — don't block on Meta-specific fields for other platforms.\n   - `title` and `description` must be non-empty.\n\n   Drop invalid entries, keep going. Log which ones were skipped and why.\n\n6. **Handle dry-run.** If `DRY_RUN=true` or `config.dryRun: true`:\n   - Write payloads to `.pending-admanage\u002Fdryrun\u002F{schedule-name}-{timestamp}.json`.\n   - Notify a preview (see step 9) but with `[DRY RUN]` prefix.\n   - Skip step 7.\n   - This mode exists for the operator to sanity-check before arming real launches.\n\n7. **Launch in-run.** This is the branch's final action — spends real money, so run the guardrails first. Only `.\u002Fsecretcurl`, `jq`, `date`, `echo`, `mkdir`, `grep`, `python3`, and the `Write` tool are available.\n\n   a. **Config check.** `[ -n \"${ADMANAGE_API_KEY:+x}\" ]` (the `${VAR:+x}` form — a bare `$ADMANAGE_API_KEY` trips the secret-expansion analyzer and reads as unset). If unset → notify \"ads computed but ADMANAGE_API_KEY missing — nothing launched\" and stop.\n\n   b. **Daily spend circuit-breaker (once).** Take the strictest `dailySpendCap` (`CAP`) across today's payloads. If set, read today's spend and **fail closed** unless it's a clean number *below* the cap:\n      ```bash\n      SPEND=$(.\u002Fsecretcurl -sS --max-time 30 -H \"Authorization: Bearer {ADMANAGE_API_KEY}\" \\\n        \"https:\u002F\u002Fapi.admanage.ai\u002Fv1\u002Fspend\u002Fdaily?startDate=$TODAY&endDate=$TODAY\" | jq -r '.metadata.totalSpend \u002F\u002F \"\"')\n      echo \"$SPEND\" | grep -qE '^[0-9]+(\\.[0-9]+)?$' || { echo \"spend unverifiable — fail closed\"; exit 0; }\n      echo \"$CAP\"   | grep -qE '^[0-9]+(\\.[0-9]+)?$' || { echo \"dailySpendCap not numeric — fail closed\"; exit 0; }\n      python3 -c \"import sys; sys.exit(0 if float(sys.argv[1])>=float(sys.argv[2]) else 1)\" \"$SPEND\" \"$CAP\" \\\n        && { echo \"daily spend cap tripped (today=$SPEND cap=$CAP) — launching nothing\"; exit 0; }\n      ```\n   c. **Per batch: launch, then poll.** For each payload `{ ads: [ ... ] }`:\n      ```bash\n      RESP=$(.\u002Fsecretcurl -sS --max-time 60 -w 'http=%{http_code}\\n' -X POST \"https:\u002F\u002Fapi.admanage.ai\u002Fv1\u002Flaunch\" \\\n        -H \"Authorization: Bearer {ADMANAGE_API_KEY}\" -H \"Content-Type: application\u002Fjson\" -d \"$PAYLOAD\")\n      # success => .success==true and .adBatchId set; else record FAILED (.message\u002F.error) and continue.\n      # Poll GET \u002Fv1\u002Fbatch-status\u002F$BATCH_ID (~90s, 5s interval) until .summaryStatus is success|error.\n      ```\n      Record each batch's outcome (ok \u002F error \u002F still-running-after-timeout) for the notify. Ads launch **PAUSED** (the payload sets it) unless `launchPaused: false`.\n\n8. **Write artifact to `output\u002F.chains\u002Fschedule-ads.md`** so downstream chain consumers can read what was queued. Format:\n   ```markdown\n   # Schedule Ads — ${today}\n\n   Queued: N launches across M schedules.\n   Dry-run: yes|no.\n\n   ## Entries\n   - \u003Cschedule name>: \u003Cad count> ads, platform=\u003Cmeta|tiktok|…>, paused=\u003Cbool>\n     - \u003CadName> — \u003Ctitle>\n   ```\n\n9. **Notify** via `.\u002Fnotify`. Keep it tight:\n   ```\n   *Ads queued — ${today}${dryRunSuffix}*\n\n   \u003CN> launches queued from \u003CM> schedules.\n\n   - \u003Cschedule name> → \u003Cad count> ads \u003Cplatform> \u003Cpaused|LIVE>\n     \"\u003Cfirst adName>\"\n   - ...\n\n   \u003Cif dry-run>\n   no API calls made — remove DRY_RUN to arm.\n   \u003Celse>\n   launched via AdManage (PAUSED) — resume in the dashboard to start delivery.\n   ```\n   If nothing matched today (no launches), don't notify at all.\n\n10. **Log** — see the shared **Log** section below (discriminator: `schedule`).\n\n## Config schema (schedule)\n\nSee `skills\u002Fschedule-ads\u002Fconfig.example.yaml` for a filled-in template. Minimum viable config:\n\n```yaml\ndefaults:\n  adAccountId: act_XXXXXXXXXX\n  workspaceId: XXXXXXXXXXXX\n  page: XXXXXXXXXXXX         # Meta Page ID\n  insta: XXXXXXXXXXXX        # Instagram user ID\n  cta: LEARN_MORE\n  launchPaused: true         # NEVER change this without thought\n  dailySpendCap: 50          # USD. Circuit breaker.\n  dryRun: false\n\nschedules:\n  - name: weekly-promo\n    platform: meta\n    when: { dayOfWeek: monday }\n    adSets:\n      - { value: \"120xxxxxxxxxxxxx\", label: \"US Broad 25-55\" }\n    ads:\n      - adName: \"Weekly promo — {date}\"\n        title: \"Headline copy here\"\n        description: \"Supporting copy in a sentence or two.\"\n        cta: LEARN_MORE\n        link: https:\u002F\u002Fexample.com\n        media:\n          - url: https:\u002F\u002Fmedia.admanage.ai\u002Fyour-account\u002Fhero.mp4\n```\n\n## What the schedule branch does NOT do\n\n- **Does not create campaigns or ad sets.** Those must pre-exist in AdManage — use the **`create` branch** (`${var}=create`), the dashboard, or `POST \u002Fv1\u002Fmanage\u002Fcreate-campaign` separately. This branch only launches *ads into existing ad sets*.\n- **Does not upload creative.** Media URLs must be hosted somewhere accessible (AdManage CDN, your own CDN, Supabase, wherever). If you need upload, add a separate `upload-ad-media` skill that calls `POST \u002Fv1\u002Fmedia\u002Fupload\u002Furl`.\n- **Does not generate copy.** Titles\u002Fdescriptions come from config. If the operator wants AI-written variants, a separate skill can write them into `config.yaml` and commit — keeps the launch path boring and auditable.\n- **Does not manage budgets, bids, or targeting.** Everything downstream of launch (scaling, pausing losers, budget shifts) lives in follow-up skills or the dashboard.\n- **Does not launch to Google Ads, Axon, or Taboola** in v1. Config schema is deliberately Meta\u002FTikTok\u002FSnapchat\u002FPinterest\u002FLinkedIn-shaped. Adding Google\u002FAxon later is straightforward but their launch shapes differ enough to need their own validation.\n\n---\n\n# Create branch (`${var}=create`)\n\nReads `skills\u002Fschedule-ads\u002Fconfig.create.yaml`, figures out which campaigns\u002Fad sets don't exist yet, and creates them **in-run** via AdManage.ai (`\u002Fv1\u002Fmanage\u002Fcreate-*` through `.\u002Fsecretcurl`) — campaigns first, then ad sets referencing the returned campaign IDs — writing the new IDs back to `.admanage-state\u002Fcampaigns.json`.\n\nThis branch is **on-demand** — invoke it manually when you want to provision new campaigns, then reference the returned IDs in `skills\u002Fschedule-ads\u002Fconfig.yaml` (schedule branch) to launch creatives into them.\n\nRead `.admanage-state\u002Fcampaigns.json` (if it exists) to see what's already created.\n\n## What this branch provisions\n\nTwo entity types only:\n1. **Meta campaigns** — name, objective, budget, bid strategy, promoted object.\n2. **Meta ad sets** — name, budget, optimization goal, targeting (geo\u002Fage\u002Fplatforms), destination.\n\nEverything else (TikTok\u002FSnapchat\u002FPinterest\u002FLinkedIn campaigns, advanced Meta fields like valueRuleSetId or Advantage+ catalog) is v2+. The shape below is intentionally minimal.\n\n## Safety defaults (create)\n\nSame posture as the schedule branch:\n\n1. **PAUSED by default.** Every campaign + ad set is created with `status: PAUSED`. No surprise spend.\n2. **Idempotent.** The branch tracks created entities in `.admanage-state\u002Fcampaigns.json`. If a campaign name already exists in state, it's skipped. Run it twice → no duplicates.\n3. **Dry-run mode.** `DRY_RUN=true` or `config.dryRun: true` → payloads written to `.pending-admanage\u002Fdryrun-create\u002F`, notified, no API calls.\n4. **Config-only.** No config file → exit silently. No invented campaigns, no autonomous provisioning.\n\n## Network note (create)\n\nProvisioning campaigns and ad sets is an irreversible outbound side-effect, so it is the branch's **final** action and runs in-run only after the diff + validation pass:\n\n- Auth'd calls go through `.\u002Fsecretcurl` with the `{ADMANAGE_API_KEY}` placeholder — never a bare `$ADMANAGE_API_KEY`. The key is injected in-run via `requires:`.\n- **Order matters:** create all campaigns first (`POST \u002Fv1\u002Fmanage\u002Fcreate-campaign`), keep a config-name → campaignId map, then create ad sets (`POST \u002Fv1\u002Fmanage\u002Fcreate-adset`) substituting each parent's real campaign ID. Write every new ID back to `.admanage-state\u002Fcampaigns.json` as you go (the workflow's Commit step persists it).\n- If `ADMANAGE_API_KEY` is unset, or a create call fails, record the failure and continue with the rest — never retry blindly, never invent IDs. An ad set whose parent campaign failed to create is skipped. There is no deferred postprocess fallback.\n\n## Steps (create)\n\n1. **Load config.** Read `skills\u002Fschedule-ads\u002Fconfig.create.yaml`. If it doesn't exist, log `CREATE_CAMPAIGN_NOT_CONFIGURED` and exit cleanly (no notify). The example template lives next to this file as `config.create.example.yaml`.\n\n2. **Load state.** Read `.admanage-state\u002Fcampaigns.json`. If it doesn't exist, treat as empty. Shape:\n   ```json\n   {\n     \"campaigns\": [\n       {\n         \"configName\": \"Prospecting — Q2 2026\",\n         \"campaignId\": \"120251616228380456\",\n         \"adAccountId\": \"act_xxx\",\n         \"createdAt\": \"2026-04-21T08:00:00Z\",\n         \"adSets\": [\n           {\n             \"configName\": \"US Broad 25-54\",\n             \"adSetId\": \"120251616242460456\",\n             \"createdAt\": \"2026-04-21T08:00:04Z\"\n           }\n         ]\n       }\n     ]\n   }\n   ```\n\n3. **Validate config shape.** Required: `defaults.adAccountId`, `defaults.workspaceId`, `campaigns[]`. Each campaign needs `name` and `objective`. Each ad set needs `name`, and either `optimizationGoal` (explicit) or a compatible parent objective. If validation fails, file an issue in `memory\u002Fissues\u002F` and exit.\n\n4. **Compute diff.** For each campaign in config:\n   - Match against state by exact `name`. If present, mark as `existing`.\n   - If missing, mark as `new` and queue a campaign create.\n   - For each ad set under the campaign, match against the parent's `adSets[]` in state by name. If missing, mark it for creation (carrying a `parentCampaignConfigName` reference you resolve to a real campaign ID in-run, once the parent campaign create returns).\n\n   If nothing is new, log `CREATE_CAMPAIGN_ALL_EXIST` and exit without notify.\n\n5. **Build campaign create payloads.** Per the AdManage `POST \u002Fv1\u002Fmanage\u002Fcreate-campaign` shape:\n   ```json\n   {\n     \"businessId\": \"\u003CadAccountId>\",\n     \"workspaceId\": \"\u003CworkspaceId>\",\n     \"name\": \"\u003Ccampaign.name>\",\n     \"objective\": \"\u003Ccampaign.objective>\",\n     \"status\": \"PAUSED\",\n     \"buyingType\": \"AUCTION\",\n     \"specialAdCategories\": [],\n     \"dailyBudget\": \u003Cnumber>,\n     \"bidStrategy\": \"\u003CLOWEST_COST_WITHOUT_CAP | LOWEST_COST_WITH_BID_CAP | COST_CAP | ...>\",\n     \"promotedObject\": { ... }\n   }\n   ```\n   Skip keys that are `null`\u002Fabsent in config — don't send empty strings. Always force `status: PAUSED` unless `defaults.launchPaused: false` is set explicitly.\n\n6. **Build ad-set create payloads.** Per `POST \u002Fv1\u002Fmanage\u002Fcreate-adset`:\n   ```json\n   {\n     \"businessId\": \"\u003CadAccountId>\",\n     \"workspaceId\": \"\u003CworkspaceId>\",\n     \"campaignId\": \"__RESOLVE_FROM_PARENT__\",\n     \"parentCampaignConfigName\": \"\u003Ccampaign.name>\",\n     \"name\": \"\u003CadSet.name>\",\n     \"status\": \"PAUSED\",\n     \"dailyBudget\": \u003Cnumber>,\n     \"billingEvent\": \"IMPRESSIONS\",\n     \"optimizationGoal\": \"\u003CLANDING_PAGE_VIEWS | OFFSITE_CONVERSIONS | ...>\",\n     \"destinationType\": \"\u003CWEBSITE | PHONE_CALL | MESSAGING_... | ...>\",\n     \"targeting\": { ... },\n     \"promotedObject\": { ... }\n   }\n   ```\n\n   The `__RESOLVE_FROM_PARENT__` sentinel + `parentCampaignConfigName` marks an ad set whose `campaignId` you fill in-run, from the map built as each campaign create returns (step 9b). If the parent campaign was *existing* (already in state), write the real campaign ID directly and drop the sentinel.\n\n7. **Pre-flight validation.**\n   - `adAccountId` must start with `act_` (this branch is Meta-only in v1).\n   - `dailyBudget` must be a positive number in dollars (not cents).\n   - `objective` must be one of the documented Meta objectives: `OUTCOME_TRAFFIC`, `OUTCOME_ENGAGEMENT`, `OUTCOME_LEADS`, `OUTCOME_AWARENESS`, `OUTCOME_SALES`, `OUTCOME_APP_PROMOTION`.\n   - Targeting `geo_locations.countries` must be a non-empty array.\n   Drop invalid entries, keep going, log what was skipped and why.\n\n8. **Handle dry-run.** If `DRY_RUN=true` or `config.dryRun: true`: write payloads to `.pending-admanage\u002Fdryrun-create\u002F` instead, notify with a `[DRY RUN]` prefix, skip step 9.\n\n9. **Create in-run.** This is the branch's final action — provisions real entities, so run only after the diff + pre-flight pass. Only `.\u002Fsecretcurl`, `jq`, `date`, `echo`, `python3`, and the `Write` tool are available (no `mv`). Seed `.admanage-state\u002Fcampaigns.json` to `{\"campaigns\":[]}` if missing.\n\n   a. **Config check.** `[ -n \"${ADMANAGE_API_KEY:+x}\" ]` (the `${VAR:+x}` form — a bare `$ADMANAGE_API_KEY` trips the secret-expansion analyzer and reads as unset). If unset, notify \"campaigns computed but ADMANAGE_API_KEY missing — nothing created\" and stop (state unchanged).\n\n   b. **Campaigns first.** For each *new* campaign, `POST \u002Fv1\u002Fmanage\u002Fcreate-campaign`:\n      ```bash\n      RESP=$(.\u002Fsecretcurl -sS --max-time 60 -w 'http=%{http_code}\\n' -X POST \\\n        \"https:\u002F\u002Fapi.admanage.ai\u002Fv1\u002Fmanage\u002Fcreate-campaign\" \\\n        -H \"Authorization: Bearer {ADMANAGE_API_KEY}\" -H \"Content-Type: application\u002Fjson\" -d \"$PAYLOAD\")\n      # success => .success==true and .campaignId set.\n      ```\n      On success: remember `configName → campaignId` (for step 9c) and append `{configName, campaignId, adAccountId, createdAt, adSets:[]}` to `.admanage-state\u002Fcampaigns.json`. On failure: record the error, skip this campaign's ad sets.\n\n   c. **Then ad sets.** For each new ad set, resolve `campaignId`: if it's `__RESOLVE_FROM_PARENT__`, look it up by `parentCampaignConfigName` in the map from 9b **or** existing state — if the parent isn't found (its create failed), skip the ad set with a warning. Then `POST \u002Fv1\u002Fmanage\u002Fcreate-adset` (same `.\u002Fsecretcurl` shape). On success: append `{configName, adSetId, createdAt}` under the parent campaign in `.admanage-state\u002Fcampaigns.json` (via `python3`\u002F`Write` — no `mv`).\n\n   Ordering is explicit here (campaigns loop fully before the ad-sets loop), so children always reference a resolved parent ID.\n\n10. **Write artifact to `output\u002F.chains\u002Fcreate-campaign.md`** so chain consumers can see what was queued:\n    ```markdown\n    # Create Campaign — ${today}\n\n    New campaigns: N.\n    New ad sets: M.\n    Dry-run: yes|no.\n\n    ## Campaigns\n    - \u003Cname> — \u003Cobjective>, $\u003CdailyBudget>\u002Fday\n      - ad set: \u003Cname> — \u003CoptimizationGoal>, $\u003CdailyBudget>\u002Fday, \u003Ccountries>\n\n    ## Skipped (already exist)\n    - \u003Cname>\n    ```\n\n11. **Notify via `.\u002Fnotify`.** Tight format:\n    ```\n    *Campaigns queued — ${today}${dryRunSuffix}*\n\n    \u003CN> campaigns, \u003CM> ad sets queued for creation.\n\n    - \u003Ccampaign name>\n      - adset: \u003Cadset name> — \u003Ccountry>, $\u003Cbudget>\u002Fday\n\n    \u003Cif dry-run>\n    no API calls made — remove DRY_RUN to arm.\n    \u003Celse>\n    created via AdManage (PAUSED); new IDs written to .admanage-state\u002Fcampaigns.json.\n    ```\n    If nothing is new, don't notify at all.\n\n12. **Log** — see the shared **Log** section below (discriminator: `create`).\n\n## Config schema (create)\n\nSee `skills\u002Fschedule-ads\u002Fconfig.create.example.yaml` for a filled-in template. Minimum viable config:\n\n```yaml\ndefaults:\n  adAccountId: act_XXXXXXXXXX\n  workspaceId: XXXXXXXXXXXX\n  launchPaused: true               # never flip without a reason\n  dryRun: false                    # true = build, don't call\n\ncampaigns:\n  - name: \"Prospecting — Q2 2026\"\n    objective: OUTCOME_TRAFFIC\n    dailyBudget: 50\n    bidStrategy: LOWEST_COST_WITHOUT_CAP\n    promotedObject:\n      pixel_id: \"123456789012345\"\n    adSets:\n      - name: \"US Broad 25-54\"\n        dailyBudget: 15\n        optimizationGoal: LANDING_PAGE_VIEWS\n        destinationType: WEBSITE\n        targeting:\n          geo_locations: { countries: [\"US\"] }\n          age_min: 25\n          age_max: 54\n          publisher_platforms: [facebook, instagram]\n```\n\n## Interaction with the schedule branch\n\nThe create branch writes new IDs to `.admanage-state\u002Fcampaigns.json` **within the same run**; from there they're yours to reference in `skills\u002Fschedule-ads\u002Fconfig.yaml` (schedule branch) under `adSets[].value`. The two flows are intentionally decoupled:\n\n- **create branch** provisions structure (container).\n- **schedule branch** launches creative into that structure (contents).\n\nThey still don't auto-chain — the schedule branch reads `config.yaml`, which you edit by hand. Pattern is: run `${var}=create` (provisions + writes IDs in-run) → read the new IDs from `.admanage-state\u002Fcampaigns.json` \u002F the create-run notify → copy them into `config.yaml` → next default (schedule) run launches into them.\n\n## What the create branch does NOT do\n\n- **Doesn't touch existing campaigns.** Once a campaign is in state, this branch leaves it alone. Budget changes, bid changes, status flips, renames — all handled elsewhere (dashboard or a separate skill).\n- **Doesn't delete or archive.** No destructive paths.\n- **Doesn't provision media, pages, or pixels.** Pixel IDs must already exist in AdManage. Use `GET \u002Fv1\u002Fconversions\u002Fpixels` to discover them.\n- **Doesn't create TikTok \u002F Snapchat \u002F Pinterest \u002F LinkedIn** structures. Those have different payload shapes and live in v2.\n- **Doesn't resume paused campaigns.** PAUSED is the end state; the operator unpauses manually when ready.\n\n---\n\n## Log (both branches)\n\nAppend to `memory\u002Flogs\u002F${today}.md` under ONE `### schedule-ads` heading. First bullet is a discriminator naming which branch ran.\n\n**Schedule branch:**\n```\n### schedule-ads\n- Branch: schedule\n- Schedules matching today: \u003Cnames>\n- Launches: \u003Ccount> (dry-run: \u003Cbool>)\n- Batch results: \u003Cok\u002Ferror\u002Ftimeout summary> (live) | dry-run preview in .pending-admanage\u002Fdryrun\u002F\n```\n\n**Create branch:**\n```\n### schedule-ads\n- Branch: create\n- New campaigns created: \u003Ccount> (ok\u002Ffail)\n- New ad sets created: \u003Ccount> (ok\u002Ffail)\n- State: new IDs written to .admanage-state\u002Fcampaigns.json (live) | dry-run preview in .pending-admanage\u002Fdryrun-create\u002F\n```\n\n## Environment Variables\n\n- `ADMANAGE_API_KEY` — the AdManage.ai API key, injected in-run via this skill's `requires:` and used by both branches for the `\u002Fv1\u002F*` calls. Always pass it as the `{ADMANAGE_API_KEY}` placeholder to `.\u002Fsecretcurl`, never a bare `$ADMANAGE_API_KEY` on the command line.\n- `DRY_RUN` — optional. If `true`, forces dry-run mode regardless of config, in whichever branch runs.\n- Notification channels configured via repo secrets (see CLAUDE.md).\n\n## Output\n\nEnd with a `## Summary` block naming the branch that ran:\n- **schedule:** schedules matched today, payload count, dry-run yes\u002Fno, files written.\n- **create:** new campaigns queued, new ad sets queued, skipped (already-exist) count, dry-run yes\u002Fno, files written.\n",{"name":5,"metadata":23,"description":7},{"var":24,"tags":25,"title":28,"commits":29,"category":30,"requires":31,"schedule":33,"permissions":34},"Selects which flow runs (parse from ${var}):\n- empty \u002F unset (default) → SCHEDULE branch: read config.yaml, pick schedule\n  entries matching today, and launch those ads in-run via AdManage.ai.\n  Launches PAUSED by default; dailySpendCap circuit-breaker; never auto-activates\n  live spend.\n- \"create\" → CREATE branch: read config.create.yaml, diff against\n  .admanage-state\u002Fcampaigns.json, and create the missing Meta campaigns + ad sets\n  in-run. On-demand; creates entities PAUSED; returned IDs are written back into\n  state so the schedule branch can launch into them.\n",[26,27],"growth","ads","Schedule Ads",true,"productivity",[32],"ADMANAGE_API_KEY","0 8 * * *",[35],"contents:write","main","fa8f75cd49adcad9214508fdb5d1ead8fab420be","skills\u002Fschedule-ads","https:\u002F\u002Fgithub.com\u002FLiamVisionary\u002Faeon-template","https:\u002F\u002Fgithub.com\u002FLiamVisionary","2026-11-15 04:34:04",{"source":8,"skillName":5,"commands":43,"prompt":53,"zipAvailable":29},[44,47,50],{"tool":45,"command":46},"npx","npx skills add LiamVisionary\u002Faeon-template --skill schedule-ads",{"tool":48,"command":49},"bunx","bunx skills add LiamVisionary\u002Faeon-template --skill schedule-ads",{"tool":51,"command":52},"pnpm","pnpm dlx skills add LiamVisionary\u002Faeon-template --skill schedule-ads","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FLiamVisionary\u002Faeon-template\u002Fblob\u002Fmain\u002Fskills\u002Fschedule-ads\u002FSKILL.md",[55,61],{"path":56,"resourceType":57,"resourceTypeDesc":58,"sizeBytes":59,"sourceHtmlUrl":60},"config.create.example.yaml","REFERENCE","参考文档",3618,"https:\u002F\u002Fgithub.com\u002FLiamVisionary\u002Faeon-template\u002Fblob\u002Fmain\u002Fskills\u002Fschedule-ads\u002Fconfig.create.example.yaml",{"path":62,"resourceType":57,"resourceTypeDesc":58,"sizeBytes":63,"sourceHtmlUrl":64},"config.example.yaml",4063,"https:\u002F\u002Fgithub.com\u002FLiamVisionary\u002Faeon-template\u002Fblob\u002Fmain\u002Fskills\u002Fschedule-ads\u002Fconfig.example.yaml",[66,73,80,87,94,101],{"skillNo":67,"name":68,"nameZh":6,"description":69,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":70,"categories":71,"keywords":72,"publishedAt":18},"01M7D6W8WRJH3JVJ2JQ674AD77","you-web-search","Web search using You.com Search API with high-quality, cited results and optional real-time web crawling","https:\u002F\u002Fgithub.com\u002FLiamVisionary\u002Faeon-template\u002Fblob\u002Fmain\u002Fskills\u002Fyou-web-search\u002FSKILL.md",[],[],{"skillNo":74,"name":75,"nameZh":6,"description":76,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":77,"categories":78,"keywords":79,"publishedAt":18},"01M7D6W2XPBZZPPXPX76WMPSDA","write-tweet","Multi-format tweet studio - standalone drafts (10 across 5 size tiers), a 5-10 tweet thread, or 10 remixes of past tweets, selected via ${var}","https:\u002F\u002Fgithub.com\u002FLiamVisionary\u002Faeon-template\u002Fblob\u002Fmain\u002Fskills\u002Fwrite-tweet\u002FSKILL.md",[],[],{"skillNo":81,"name":82,"nameZh":6,"description":83,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":84,"categories":85,"keywords":86,"publishedAt":18},"01M7D6VZVWK4RATPHM90N71QZD","weekly-aeoncard","Build a weekly token-consumption recap image from memory\u002Ftoken-usage.csv - this week + all-time totals, top skills, rendered as a shareable SVG card.","https:\u002F\u002Fgithub.com\u002FLiamVisionary\u002Faeon-template\u002Fblob\u002Fmain\u002Fskills\u002Fweekly-aeoncard\u002FSKILL.md",[],[],{"skillNo":88,"name":89,"nameZh":6,"description":90,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":91,"categories":92,"keywords":93,"publishedAt":18},"01M7D6VQ7H3DHAAP0BEWTC3HK4","vuln-tracker","One lifecycle poll over everything vuln-scanner produces - PR and advisory status, PVR triage transitions, and pending-disclosure aging, with a stars-secured impact headline and one action queue.","https:\u002F\u002Fgithub.com\u002FLiamVisionary\u002Faeon-template\u002Fblob\u002Fmain\u002Fskills\u002Fvuln-tracker\u002FSKILL.md",[],[],{"skillNo":95,"name":96,"nameZh":6,"description":97,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":98,"categories":99,"keywords":100,"publishedAt":18},"01M7D6VDRA94RJKDPKJ65S47KT","vuln-scanner","Audit trending repos for real security vulnerabilities and disclose responsibly - scan and route findings (PVR \u002F dependency PR), re-submit queued advisories, and send armed email disclosures","https:\u002F\u002Fgithub.com\u002FLiamVisionary\u002Faeon-template\u002Fblob\u002Fmain\u002Fskills\u002Fvuln-scanner\u002FSKILL.md",[],[],{"skillNo":102,"name":103,"nameZh":6,"description":104,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":105,"categories":106,"keywords":107,"publishedAt":18},"01M7D6V8BNPHCTPJBJD89H8DZF","video-script","Turn a repo, product page, or update into a recording-ready video script in a receipts-first format - verifies every claim against live sources, then writes timestamped VO + on-screen direction with a plain-language glossary, assets checklist, anti-tells, and a verify-before-recording list","https:\u002F\u002Fgithub.com\u002FLiamVisionary\u002Faeon-template\u002Fblob\u002Fmain\u002Fskills\u002Fvideo-script\u002FSKILL.md",[],[]]