Sync state

From logly/mureo · View interactive version

Sync state is an AI agent skill from the GitHub repository logly/mureo. Sync STATE.json with current campaign data from all platforms. Use when the user asks to refresh state, sync campaigns, update STATE.json from live data, or pull latest campaign snapshots. Also use when the user asks in Japanese (STATE.jsonを更新 / 最新データに同期して / キャンペーン情報を取り込み直して).

How to use this skill

Skill file

Sync State

PREREQUISITE: Read ../_mureo-shared/SKILL.md for auth, security rules, output format, and Tool Selection (Read/Write on Code, mureo_strategy_* / mureo_state_* MCP on Desktop / Cowork), and ../_mureo-state-schema/SKILL.md for the STATE.json schema and the status vocabulary contract.

Tool names below refer to the built-in platforms; a namespaced variant (see _mureo-shared → Namespaced built-in variants) is used with its prefix substituted.

Synchronize STATE.json with the current state of all marketing platforms.

Mixed operation

Manual operation in the platform UI and mureo-driven operation coexist — most accounts run that way for a while after onboarding, and it applies to every platform. Treat any change you find that mureo did not make as a first-class fact, not an anomaly: the action_log records what mureo did, never the full history of the account, so never infer current state from it. When a diff surfaces a change made outside mureo, say so in the report rather than silently absorbing it into the new state.

Prerequisites

Steps

Note: the Diagnostic preamble (learning insights + advisor consult) from ../_mureo-shared/SKILL.md is intentionally not required here — sync-state is mechanical data synchronization with no judgement calls.

  1. Establish today: call mureo_state_get first, on every host (including Claude Code, where you would otherwise Read the file) and take server_now from its response — ISO 8601 with UTC offset, e.g. 2026-07-28T10:12:33+09:00. Its date is the only source of the current date for this sync (no shelling out — this skill must run in Bash-less headless hosts). The dates inside the document — last_synced_at, reports.*.period, action_log timestamps — are history: use them to describe what changed, never to decide what "now" is or whether a sync is still needed. Never write server_now into STATE.json; it is a response field, and a persisted copy becomes tomorrow's stale "today".
  1. Read current STATE.json (if exists) to track changes — the same mureo_state_get response from step 0 on MCP hosts.
  1. Discover platforms: Identify all platforms registered in STATE.json platforms — built-in AND plugin/bridge platforms. Per ../_mureo-shared/SKILL.md → Plugin platforms, also enumerate any installed entry-point plugin that exposes mcp__mureo__<plugin>_* tools; its STATE.json platform key is plugin:<dist>:<provider> (the same convention mureo uses when promoting plugin mutations into action_log; the older plugin:<dist> is still read, and an entry already stored under it must be kept, not rewritten). Also enumerate any hosted official-MCP connector present in the session (e.g. TikTok's tt-ads-* tools) — its key is a first-class ad-platform key such as tiktok_ads; see ../_mureo-shared/SKILL.md → Hosted-connector platforms.
  1. Fetch platform data: For each registered platform:
  1. Check data sources: If Search Console is configured, verify site access is still valid. If GA4 is available, verify connectivity.
  1. Detect new platforms: If new platform credentials exist but have no entry in platforms, prompt the user to run /onboard to add them.
  1. Verify STRATEGY.md Data Sources: If STRATEGY.md is missing a ## Data Sources section (older setup), prompt the user to add it listing all configured platforms.
  1. Update STATE.json with all campaign snapshots. On the Code Write path, use the canonical STATE.json field names — campaign_name (NOT the tool-output name), campaign_id (NOT id), and each platform's account_id; a snapshot/platform missing a required field is dropped by the reporting dashboard. See ../_mureo-state-schema/SKILL.md → STATE.json Schema. Copy each campaign's type from the campaign list verbatim into campaign_type — Google Ads channel_type (e.g. SEARCH, PERFORMANCE_MAX), Meta objective (e.g. OUTCOME_LEADS); omit it where the list carries no such field. For each campaign, also write the metrics you fetched in step 3 onto the snapshot: spend, impressions, clicks, conversions, cpa, ctr, the Meta result_indicator (when present), period (e.g. LAST_30_DAYS), and fetched_at (ISO 8601). On Code use Write; on Desktop / Cowork call mureo_state_upsert_campaign with the metrics object. Record the per-platform rollup on each platforms[<platform>] entry too — totals (summed spend / clicks / conversions / etc.), metrics_period (the period the totals cover, LAST_30_DAYS here), and the same totals under periods["LAST_30_DAYS"] (the per-window map the reporting dashboard's period toggle reads) — so the dashboard can render KPIs from STATE.json without re-querying. On Code write the rollup via Write; on Desktop / Cowork call mureo_state_platform_metrics_set (pass platform, account_id, totals, metrics_period="LAST_30_DAYS", and periods={"LAST_30_DAYS": {…}}) — mureo_state_upsert_campaign writes per-campaign metrics only, never the platform rollup. periods merges per window key, so writing LAST_30_DAYS never clobbers a YESTERDAY bucket daily-check wrote. On the mureo_state_platform_metrics_set path you may omit fetched_at from the rollups — the server stamps the write time onto every rollup that call supplies without one, and never re-stamps a window it only preserves; on the Write path set it yourself, or the dashboard has no age to show. Give the LAST_30_DAYS rollup a period_end — the last calendar date those figures cover, YYYY-MM-DD, in the ad account's own timezone (the server stamps fetched_at but does not know the account's timezone and will not guess this date; without it the card is judged on when it was last written, not on what it covers). All metric fields are optional: omit any a platform doesn't provide rather than writing nulls. Persist the ad-level statuses from step 3 too, as the campaign's ads array (ad_id, name, status, effective_status) — omitting effective_status for a platform that reports no serving status (Amazon Ads; see step 3): on Desktop / Cowork pass ads to mureo_state_upsert_campaign (the server stamps each ad's as_of, so do not compute it); on Code write the same array on the campaign snapshot with an as_of of server_now. Omit ads entirely for campaigns whose ads you did not fetch — an empty array means “fetched, this campaign has no ads”. Plugin / bridge platforms use the SAME shape: persist their campaigns + best-effort metrics (canonical vocabulary, minus result_indicator) under platform key plugin:<dist>:<provider> via mureo_state_upsert_campaign (pass platform="plugin:<dist>:<provider>" — or the key that platform is already stored under, which may be the older plugin:<dist>; never write a second key for a platform that already has one), plus the per-platform totals / metrics_period / periods["LAST_30_DAYS"] via mureo_state_platform_metrics_set — so a bridge's KPIs land in the same platforms shape the dashboard reads. A plugin with no reporting tool keeps an entry with empty metrics/totals (advisory, no synced metrics).
  1. Show diff: Compare old vs new state and highlight changes:
  1. Update last_synced_at timestamp — use server_now from step 0 (the mureo_state_* write tools stamp it for you; on the Code Write path write that value yourself).

If STATE.json doesn't exist yet, suggest running /onboard first.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.