/workmagic:attribution-data-queryfrom WorkMagic
Translates explicit data requests into Cube.dev SQL queries and returns results. Handles metrics, dimensions, time ranges, and filters for attribution analytics.
Ships in WorkMagic. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Translate the user's explicit data request into a precise Cube.dev SQL query and return results. No estimation, no fabrication, no proactive dashboard creation. This is the default skill for all query-type requests in the Attribution domain.
Trigger condition: the user's request explicitly states (or strongly implies) most of:
Examples that should NOT trigger — route to another skill instead:
| Input pattern | Route to |
|---|---|
| Ambiguous request ("Show me my numbers" / "How is Meta doing") | attribution-intent-clarification |
| "Why" question ("Why did sales drop?") | attribution-anomaly-diagnosis |
| Comparing 2+ attribution models ("Compare iDDA vs last_click") | attribution-model-comparison |
| Business-label dimension ("by region" / "by audience" / "by brand") | attribution-custom-dimension |
| "Create / build a dashboard" | build a live-data dashboard artifact — the dashboard skill (an html/react live view), not a native platform dashboard. For a recurring business review ("weekly overview", "monthly review"), build the same live view with the prior period alongside for comparison |
| "Send me a weekly/daily report" | Build the live view, then explain that scheduled delivery isn't available in this plugin yet; the user can set it up in the WorkMagic app |
Fields to parse from user input:
| Field | Required? | Description / default |
|---|---|---|
| dataset | Required | One of: channel_attribution (by channel) / ads_attribution (by campaign/ad) / creative_attribution (by creative) / order_sales (raw orders, no attribution split). Infer from user phrasing; never ask user to pick a DataSet name. |
| metric | Required | Extract from user input. Always call dashboard-metrics-list to validate the field name before using it. Never guess. |
| dimension | Required | Validate against dashboard-metrics-list. For ads_attribution / creative_attribution with NC dimensions (Product Group, Asset Type, Creator name, etc.), pass tenantId to fan out tenant-specific propertyNames. |
| time_range | Has default | Default: past 7 days. When user doesn't specify, use the default and inform them in one sentence ("Defaulting to the past 7 days — let me know if you want a different window"). Do not ask back. |
| attribution_model | Has default | Resolved per §3.2. Filter via WHERE attr_model_name = ''. |
| sales_platform_scope | Has default | Default: all sales platforms — use attr_all_sales / attr_all_orders, NOT Shopify-only. Use attr_shopify_sales only when the user explicitly asks for Shopify / DTC alone. Per-platform breakdown via the dedicated measures → references/sales-platform-scope.md. |
| filters | Optional | Extract from input ("only Meta", "ROAS > 2", "exclude test"). |
| order_by / limit | Optional | "top 10" / "most" implies sorting — order descending by the implied key. |
Default resolution rules (see references for details):
references/time-range-resolution.mdreferences/granularity-default.mdStep 1: Parse the request
Map natural language into the input fields. Resolve silently: today's date (re-fetch — never hard-code) → time window → attribution model → sales-platform scope (default all platforms, attr_all_*) → DataSet → dimensions → metrics.
Step 2: Pick the DataSet (by dimension)
channel_attributionads_attributioncreative_attributionorder_salesads_attributionlift_test_result exists but belongs to lift-test domain — route there if user asks about lift test resultsStep 3: database-query-ask first (MANDATORY)
Ask database-query-ask about the warehouse's Cube.dev schema patterns. database-query-run requires the ctx timestamp it produces. Skipping fails execution.
Step 4: Validate fields via dashboard-metrics-list
ads_attribution / creative_attribution: pass tenantId to fan out tenant-specific propertyNames (e.g., Product Group, Asset Type). Use propertyName exactly as returned (case-sensitive).Step 5: Construct & execute SQL via database-query-run
🛑 HARD RULE — copy a template first, then fill placeholders
BEFORE writing any SQL, you MUST match the user's query pattern to one of the 5 templates in
templates/:
templates/01-channel-roas.txt— single-platform channel-level ROAStemplates/02-top-n-campaigns.txt— Top-N campaigns by metrictemplates/03-period-over-period.txt— WoW / MoM comparison (2 separate queries)templates/04-creative-headlines.txt— creative-level (JSON-array headlines)templates/05-actual-store-sales.txt— actual store sales (NOT attribution)Copy the template, then fill placeholders (
<tenant_id>/<attr_model>/<platform>/<start_date>/<end_date>). Do NOT write SQL from scratch — past agents have produced wrong queries (case-sensitive platform names, missingHAVING SUM(ad_spend) > 0, average-of-ratios ROAS, window functions Cube rejects).If none of the 5 templates fit — pause and tell the user what's requested is outside the verified set, ask CSM, do NOT improvise. Pitfalls + when-to-use guidance for each template →
references/sql-examples.md. Full worked walkthrough →examples/example-A-meta-roas-last-week.md.
💡 Don't take the bait — never average ROAS across rows
Tempting design: when comparing campaigns / days, compute ROAS per row first, then average. Don't. That's "average of ratios" and is mathematically wrong — a $64-spend campaign with one lucky order produces 122.76x ROAS that buries real top performers (vs the correct ratio-of-sums 3.44x).
Always
SUM(sales) / NULLIF(SUM(spend), 0)at the final aggregation level. Same applies to CAC, ROAS, conversion rate — any ratio metric.
ctx timestamp from Step 3 (ISO 8601)NOT LIKE / NOT IN)attr_model_name dimensionreferences/sql-examples.md. Required reading before writing SQL.Step 6: Return results
| Tool | Required? | Purpose |
|---|---|---|
| database-query-ask | Required (first) | Consult Cube.dev schema patterns before SQL. |
| dashboard-metrics-list | Required | Validate metric / dimension field names exist on the chosen DataSet. |
| database-query-run | Required | Execute the Cube.dev SQL query. |
| tenant-list | Optional | Look up tenantId when needed to fan out NC dimensions on dashboard-metrics-list. |
dashboard skill: an html/react view wired to the data), not a wall
of table dumped in chat. Carry the same measurement identity (sales-platform scope +
model) onto the artifact. When in doubt between the two, a clean chat table is fine —
don't force an artifact for a genuinely simple ask.references/sales-platform-scope.md. Never print the raw DataSet technical name (channel_attribution / ads_attribution / creative_attribution / order_sales) — see rule 8 below; those are internal identifiers, not customer-facing labelsattribution-anomaly-diagnosisreferences/sql-examples.md BEFORE writing SQL — do not write SQL from scratch. The 5 templates cover channel ROAS / Top-N campaigns / WoW comparison / creative headlines / actual store sales. If none fit, pause and ask CSM; do not improvise.database-query-ask before SQL — database-query-run requires the ctx it produces; will fail at executiondashboard-metrics-list — guessing field names causes SQL errors / wrong datachannel_attribution / ads_attribution etc.) to userFull edge case & routing catalog → references/edge-cases.md
| Skill | Relationship |
|---|---|
| attribution-intent-clarification | Upstream: handles ambiguous requests, then routes back to data-query once clarified |
| attribution-anomaly-diagnosis | Downstream: handles "why" questions |
| attribution-model-comparison | Downstream: handles multi-model comparisons |
| attribution-custom-dimension | Downstream: handles business-label dimensions that require Naming Convention config |
| attribution-edge-routing | Downstream: handles requests outside the Attribution domain's capability |
examples/example-A-meta-roas-last-week.md (opens in a new tab)references/attribution-model.md (opens in a new tab)references/edge-cases.md (opens in a new tab)references/failure-modes.md (opens in a new tab)references/granularity-default.md (opens in a new tab)references/sales-platform-scope.md (opens in a new tab)references/sql-examples.md (opens in a new tab)references/time-range-resolution.md (opens in a new tab)templates/01-channel-roas.txt (opens in a new tab)templates/02-top-n-campaigns.txt (opens in a new tab)templates/03-period-over-period.txt (opens in a new tab)templates/04-creative-headlines.txt (opens in a new tab)templates/05-actual-store-sales.txt (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
9 skills in this plugin
/attribution-anomaly-diagnosisDiagnose "why" questions about attribution anomalies — attribution=0 (no attributed orders), and sudden drops, spikes or retroactive changes in attributed numbers. Do NOT use for "show me numbers" — that's attribution-data-query./attribution-custom-dimensionHandle attribution queries sliced by a business label ("by audience" / "by region" / "by brand") that is not a native field — it lives in campaign names and only becomes queryable once a Naming Convention (NC) rule is configured./attribution-edge-routingRecognize when a user request falls outside attribution's capability boundary and route it gracefully — to another WM product (MBO / Lift Test / Creative Magic / Ads Magic / Audience Magic), to a human (CSM / DS / Eng), or to a clean decline that bridges back to what attribution can answer.npx claudepluginhub workmagicio/workmagic-agent-plugin --plugin workmagicOther plugins' skills for the same job