/wire:cubefrom wire
Models and queries Cube.dev semantic layers: cubes, views, dimensions, measures, joins, segments, and pre-aggregations via YAML or JavaScript. Includes conventions for dbt upstream and Cube MCP server integration.
Ships in wire. 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.
None: SKILL.md is the whole skill.
Cube is a semantic layer sitting between the warehouse and every downstream consumer — a BI tool, an embedded app, or an AI agent querying through Cube's MCP server. Used by semantic_layer-generate when the engagement's semantic layer is Cube rather than LookML, and by any work that reads, builds, or migrates a Cube data model.
This skill assumes dbt is doing the transformation work upstream (staging → intermediate → marts) and Cube reads from marts-layer tables or views. Cube is not a transformation tool. If a calculation needs a window function or a multi-step aggregation before it reaches Cube, it belongs in dbt, not in a sql parameter — this is the first thing to check when a cube's sql is doing more than a light per-row expression.
Two object types matter: cubes and views.
sql_table) or a query result, and defines dimensions, measures, joins, and segments on it. Cubes are the normalised, building-block layer.Within a cube: dimensions are the categorical/groupable columns (cities, statuses, timestamps); measures are the aggregates (counts, sums, calculated ratios); segments are named, reusable filters; joins connect cubes to each other; pre-aggregations are materialized rollups that keep interactive queries fast. Cube supports both YAML and JavaScript for schema definition — they produce identical behaviour, and the choice is organisational (Wire's convention below defaults to YAML).
Full official reference: docs.cube.dev/docs/data-modeling/overview.
Cube's MCP server (Premium/Enterprise plans, Viewer role or higher) lets an MCP-compatible agent query a Cube deployment directly, over HTTPS with OAuth 2.0 (Authorization Code + PKCE). The endpoint is https://<cube-mcp-server-host>/api/mcp; OAuth discovery is at /.well-known/oauth with client_id = cube-mcp-client and scope mcp-agent-access. An admin configures access under Admin → MCP Server — a default deployment (or "Automatic" routing to the user's first accessible one), optionally restricted to specific deployments, always intersected with the user's role-based permissions.
Three tools are exposed: listDeployments (discover reachable deployments and their agents), chat (send a query, optionally targeting a specific deploymentId/agentId — omit both for the session default and Auto agent), and loadQueryResults (page through prior results on the same deployment). A request against an excluded deployment returns 403 Forbidden.
To register with Claude Code:
claude mcp add --transport http cube-mcp-server https://<host>/api/mcp
Authenticate via browser, select the server with /mcp, then query. Full reference: docs.cube.dev/docs/integrations/mcp-server.
Owner: Rittman Analytics. Applies to: all Cube.dev data model development on client and internal engagements. The point of a semantic layer is that "revenue" means the same thing everywhere it's asked — that only holds if every consultant builds cubes the same way. This section is that shared way. It replaces personal judgement calls on naming, folder structure, and join direction with a fixed set of decisions, so a project can move between consultants without a rebuild.
cube_project
└── model
├── cubes
│ ├── finance
│ │ ├── stripe_invoices.yml
│ │ └── stripe_payments.yml
│ ├── sales
│ │ ├── orders.yml
│ │ └── order_line_items.yml
│ └── customers
│ └── customers.yml
└── views
├── finance
│ └── finance_view.yml
└── sales
└── orders_view.yml
cubes/ and views/. If there's a sales/ cube folder there should be a sales/ view folder.COMPILE_CONTEXT-driven visibility) — and document why in a comment at the top of the file when you do.snake_case throughout, in both YAML and JavaScript syntax. No camelCase, no kebab-case.fct_orders, the cube is orders._view suffix: orders_view, finance_view. This makes it unambiguous in the API explorer which objects are the public product and which are internal building blocks.total_revenue, not revenue_sum. order_count, not count_of_orders.is_cancelled, is_first_order. Never cancelled_flag or flag_first_order.created_at is fine alone; if a truncated version is also exposed, created_month is clearer than a second created_at.public: false.Machine-checkable rules — run the linter, don't re-derive it by eye. The naming and required-field rules in this section (and in Cube/Dimension/ Measure/View standards below) also exist as a machine-readable convention file, checked by a script instead of your own read of this document. Resolve which one applies (client override wins):
.wire/conventions/cube.yml in the client project, if present.wire/conventions/cube.yml next to this skill's framework installation
(synced from the private wire-process-registry — see
wire/schemas/convention-schema.md).Run it against the cube/view YAML file(s) you're about to validate or have just written:
python3 wire/scripts/lint_conventions.py --domain cube \
--convention <resolved cube.yml path> --path <cube model dir or file> \
--format json
On Claude Code the Wire mod runs this checker on every write to a Cube file under model/ or schema/ (wire#270) and hands the findings back in the same turn. Keep the call above for files written another way and for whole-folder runs.
Treat its findings as ground truth for what it covers — snake_case naming,
the _view suffix, boolean-dimension phrasing, the deprecated
belongsTo/hasMany join vocabulary, and required fields on every cube
(name, sql_table, description, a primary_key dimension), dimension
(name, sql, type), and measure (name, type). Additive-measure
correctness, join direction, and pre-aggregation judgment calls stay yours —
see Measure standards and Pre-aggregations below. If the linter isn't
available in the environment, fall back to a manual read of this section and
say so in your output.
Point every cube at a single dbt mart with sql_table, using the fully-qualified table reference:
cubes:
- name: orders
sql_table: analytics.marts.fct_orders
data_source: default
description: >
One row per order, at order-header grain. Joins to order_line_items
for product-level detail.
sql_table in preference to a raw sql query. Reach for sql only for a genuine one-off transformation that doesn't warrant a new dbt model — and treat that as a temporary state, with a ticket raised to move the logic into dbt.primary_key dimension explicitly. Cube can't reliably de-duplicate join results without one, and a missing primary key is the single most common cause of silently inflated numbers in a semantic layer.description on every cube: what the row represents, and anything a consumer needs to know before joining to it (grain, known caveats, filters already baked in).sql_alias when the auto-generated table alias would be truncated by the target warehouse — this bites on Postgres and Redshift more than BigQuery or Snowflake, but check regardless.data_source explicitly whenever a project blends more than one warehouse or database. Don't rely on the default silently applying.extends for genuine specialisation (a cancelled_orders cube extending orders with a baked-in filter), not as a shortcut to avoid writing a join.dimensions:
- name: id
sql: id
type: number
primary_key: true
- name: status
sql: status
type: string
- name: is_cancelled
sql: "{CUBE}.status = 'cancelled'"
type: boolean
- name: created_at
sql: created_at
type: time
{CUBE} (or the cube name) rather than leaving them bare, even though Cube will resolve unqualified references. It removes ambiguity the moment a join is added later, and it's what the Cube style guide itself recommends.type. Don't let Cube infer it.meta or description on dimensions that a non-technical consumer will encounter through a view and that aren't self-explanatory from the name alone.WHERE filters) go on the cube, not duplicated as a filter in every measure that needs them.measures:
- name: count
type: count
- name: total_revenue
sql: amount
type: sum
format: currency
- name: average_order_value
sql: "{total_revenue} / NULLIF({count}, 0)"
type: number
format: currency
- name: paying_customer_count
sql: id
type: count_distinct
filters:
- sql: "{CUBE}.is_paying = true"
type, matched to the correct SQL aggregate: count for row counts, sum for additive totals, count_distinct (or count_distinct_approx at genuine scale) for unique counts, min/max for extremes, number for anything calculated from other measures.count, count_distinct_approx, min, max, and sum are additive — this determines whether pre-aggregations can serve a query at a different grain than the one they were built for. If a measure isn't additive (a ratio, a percentage, an average), it must be built as a calculated measure referencing additive components, never pre-aggregated directly.NULLIF guarding the denominator. Never divide two raw columns inline inside a single measure's sql.format (currency, percent) wherever the value will be surfaced directly to a business user. Don't leave formatting to the BI tool to guess.paying_customer_count above) are preferred over exposing a boolean dimension and asking every consumer to remember to filter on it correctly.description where the name alone doesn't make the definition obvious — particularly anything involving a filter, a NULLIF guard, or a business rule around what counts as "cancelled" or "active".joins:
- name: customers
sql: "{CUBE}.customer_id = {customers.id}"
relationship: many_to_one
one_to_many, many_to_one, one_to_one — not the older belongsTo/hasMany terms, which are deprecated.join_path, rather than leaving Cube to pick and hoping it picks correctly. An ambiguous join silently answered the wrong way is worse than a build error.public: false if they have no analytical value beyond the join itself.Views are entity-oriented and denormalised by design. Build them around what a business user thinks of as one thing — "orders", not "orders joined to everything we might ever need."
views:
- name: orders_view
description: >
Order-level reporting view. Includes customer geography and product
category via joins from the orders cube.
cubes:
- join_path: orders
includes:
- status
- created_at
- count
- total_revenue
- average_order_value
- join_path: orders.line_items.products
includes:
- name
prefix: true
- join_path: orders.customers
includes:
- city
- country
prefix: true
cubes/join_path/includes structure rather than hand-listing every member with full qualification. It's shorter, and the join path is explicit rather than inferred.prefix: true when pulling dimensions from a joined cube, so customers.city surfaces as customers_city rather than colliding with a same-named field elsewhere in the view.includes: ["*"] sparingly — only for a genuinely small, stable cube (a lookup or dimension table) where exposing everything is the intended behaviour. For fact-grain cubes, list members explicitly, so a new column added upstream doesn't appear in a client-facing view unreviewed.includes as: dimensions first, then measures, matching the pattern a consumer will actually browse in when building a report.public: false on any view still under active development, and don't flip it to public until it's been checked against the Definition of Done below.Pre-aggregations exist to keep interactive queries fast, not to work around a badly modelled cube. Model correctly first.
pre_aggregations:
- name: orders_by_day
measures:
- orders.count
- orders.total_revenue
dimensions:
- orders.status
time_dimension: orders.created_at
granularity: day
partition_granularity: month
refresh_key:
every: 1 hour
refresh_key rather than accepting the default. For OLTP-sourced marts, MAX(updated_at) on the source table is usually the right check; for append-only event data, a time-based every clause is simpler and cheaper.orders_by_day, orders_by_customer_month), not pre_agg_1.security_context in COMPILE_CONTEXT for row-level, multi-tenant filtering — never bake a client-specific WHERE tenant_id = '...' into a cube's sql. The whole point of the semantic layer is that one model serves every tenant safely.public: false at cube, view, dimension, or measure level for anything that shouldn't be reachable through the API — internal join keys, deprecated fields kept temporarily for backward compatibility, anything containing data a given role shouldn't see.queryRewrite in the Cube configuration file rather than trying to encode role logic inside the data model itself.SELECT, SUM, CASE WHEN.!= rather than <>.AS when aliasing a column, expression, or table — never rely on positional aliasing.wire/cube/ or the project's established convention — never as a standalone repo disconnected from the dbt project it reads from.cube validate or the CI equivalent) before merge. A YAML syntax error caught in CI costs a minute; caught in production it costs a client-facing outage.Every cube and view needs, at minimum: a description at the cube/view level covering grain and any caveats, and a description on any measure whose definition isn't obvious from its name alone — anything involving a filter, an exclusion, or a business rule that isn't universal (what counts as "active", what's excluded from "revenue"). No requirement to document self-evident dimensions (status, created_at) beyond a type.
Before a cube or view is marked ready for client-facing use:
sql_table, not a raw sql query, unless a ticket exists to migrate itprimary_key declared explicitly{CUBE} or the cube nametype, matched correctly to the underlying aggregateNULLIF guarding any divisionone_to_many / many_to_one / one_to_one) and ambiguous paths are resolved explicitly in viewscubes/join_path/includes, not hand-listed memberspublic: false set on internal join keys and anything not intended for API exposurerefresh_keyWhat SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub rittmananalytics/wire-plugin --plugin wire74 skills in this plugin
/add-analytics-instrumentationEnd-to-end analytics instrumentation workflow for a PR, branch, file, directory, or feature. Reads the code, discovers what events should be tracked, and produces a concrete instrumentation plan — all in one shot. Use this skill whenever a user wants to add analytics to a PR, asks "instrument this PR", "add tracking to this branch", "what analytics does this file need", "instrument the checkout flow", "run the full instrumentation workflow", or any request that implies going from code changes to a tracking plan. Also trigger when the user gives you a PR link, branch name, file path, or feature description and mentions analytics, events, or instrumentation. This is the main entry point for the analytics workflow — prefer it over calling the individual steps (diff-intake, discover-event-surfaces, instrument-events) separately.
/agents-schemaPublish and read warehouse metadata through dbt Labs' Agents Schema (the AGENTS schema inside Snowflake, Databricks or BigQuery, written by the agents-schema CLI from a dbt manifest, LookML, Omni, OSI, Sigma and markdown skills). Activates when the user mentions Agents Schema, agents_schema, AGENTS.ROOT, the agents-schema CLI or its GitHub workflows, warehouse-delivered skills, or asks how an AI agent should find governed context for a warehouse. Used by /wire:agents_schema-generate, -validate and -review, and for ad-hoc work against an AGENTS schema.Other plugins' skills for the same job