cube
БесплатноБез исполняемых скриптовНе проверенCube is an open-source semantic layer that sits between a data warehouse and analytics applications and serves governed metrics over REST, GraphQL and SQL…
от TerminalSkills★ 221 звезда на GitHubОб этом скилле
Cube — Semantic Layer for Analytics
Overview
Cube (Cube Core is the self-hosted open-source part; Cube Cloud is the hosted platform) is a semantic layer: you define metrics once as code (cubes, measures, dimensions, joins, pre-aggregations), and Cube serves them to apps over a REST (JSON) API, GraphQL API and a Postgres-compatible SQL API, with caching and access control. Current release is 1.7.x (October 2026). Docs: https://docs.cube.dev.
Instructions
Data Modeling
Data model files live in model/cubes/ and model/views/ (inside the project folder mounted at /cube/conf). YAML is the format the docs recommend; JavaScript works too and is used below. Reference members of the same cube as CUBE.measure in pre_aggregations.
// model/cubes/Orders.js — Orders cube with measures and dimensions
cube(`Orders`, {
sql_table: `public.orders`,
// Pre-aggregation: materialized rollup kept in Cube Store
pre_aggregations: {
daily_revenue: {
measures: [CUBE.revenue, CUBE.count],
dimensions: [CUBE.status],
time_dimension: CUBE.created_at,
granularity: `day`,
refresh_key: { every: `1 hour` },
},
},
joins: {
Users: { relationship: `many_to_one`, sql: `${CUBE}.user_id = ${Users}.id` },
},
measures: {
count: { type: `count` },
revenue: { type: `sum`, sql: `amount`, format: `currency` },
revenue_per_user: { type: `number`, sql: `${revenue} / NULLIF(${Users.count}, 0)`, format: `currency` },
// Rolling window: trailing 7-day sum (used with a time dimension)
revenue_7d: { type: `sum`, sql: `amount`, rolling_window: { trailing: `7 day` } },
},
dimensions: {
id: { type: `number`, sql: `id`, primary_key: true },
status: { type: `string`, sql: `status` },
tenant_id: { type: `string`, sql: `tenant_id` },
created_at: { type: `time`, sql: `created_at` },
},
// Segments are named, reusable filters (queried as "Orders.completed")
segments: {
completed: { sql: `${CUBE}.status = 'completed'` },
},
});
// model/cubes/Users.js — Users cube (condensed)
cube(`Users`, {
sql_table: `public.users`,
measures: {
count: { type: `count` },
active_count: { type: `count`, filters: [{ sql: `${CUBE}.last_login_at > NOW() - INTERVAL '30 days'` }] },
},
dimensions: {
id: { type: `number`, sql: `id`, primary_key: true },
plan: { type: `string`, sql: `plan` },
country: { type: `string`, sql: `country` },
created_at: { type: `time`, sql: `created_at` },
},
});
REST API
Cube Core serves the REST API under /cubejs-api (configurable with base_path). Send a JWT signed with CUBEJS_API_SECRET in the Authorization header (the token carries the security context). Endpoints: /cubejs-api/v1/load (query), /v1/meta (model metadata), /v1/sql (generated SQL).
// src/analytics/cube-client.ts — Query the Cube REST API
const CUBE_API_URL = process.env.CUBE_API_URL!;
const CUBE_API_TOKEN = process.env.CUBE_API_TOKEN!;
type CubeQuery = Record<string, unknown>; // measures, dimensions, timeDimensions, filters, order, limit
async function cubeQuery(query: CubeQuery) {
const response = await fetch(`${CUBE_API_URL}/cubejs-api/v1/load`, { // CUBE_API_URL=http://localhost:4000
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: CUBE_API_TOKEN, // JWT; "Bearer <jwt>" is also accepted
},
body: JSON.stringify({ query }),
});
const result = await response.json();
// Long queries answer {"error": "Continue wait"}: repeat the request until data arrives
if (result.error === "Continue wait") return cubeQuery(query);
if (result.error) throw new Error(result.error);
return result.data;
}
// Example: Get monthly revenue by order status
const monthlyRevenue = await cubeQuery({
measures: ["Orders.revenue", "Orders.count"],
dimensions: ["Orders.status"],
timeDimensions: [{
dimension: "Orders.created_at",
granularity: "month",
dateRange: "Last 6 months",
}],
order: { "Orders.revenue": "desc" },
limit: 100,
});
// Example: active users by plan
const activeByPlan = await cubeQuery({
measures: ["Users.active_count"],
dimensions: ["Users.plan"],
filters: [{ member: "Users.plan", operator: "equals", values: ["pro", "enterprise"] }],
});
JavaScript SDK (React)
Build analytics UIs with @cubejs-client/core and @cubejs-client/react (both 1.7.x). Wrap the app in CubeProvider:
// src/main.tsx
import cube from "@cubejs-client/core";
import { CubeProvider } from "@cubejs-client/react";
const cubeApi = cube(process.env.CUBE_TOKEN!, { apiUrl: "http://localhost:4000/cubejs-api/v1" });
// <CubeProvider cubeApi={cubeApi}><App /></CubeProvider>
// src/components/RevenueChart.tsx — React component using Cube
import { useCubeQuery } from "@cubejs-client/react";
import { LineChart, Line, XAxis, YAxis, Tooltip, ResponsiveContainer } from "re
Установить cube в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл cube?
Cube is an open-source semantic layer that sits between a data warehouse and analytics applications and serves governed metrics over REST, GraphQL and SQL APIs. Use when a user asks to define cubes, measures and dimensions, add pre-aggregations, build a metrics API or embedded analytics, set up multi-tenant row-level security, or query Cube from React or the REST API.
Как установить скилл cube?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл cube запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
skill-creator
Create new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an…
от Anthropicdiscernment-nudge
After you give a substantive answer or draft that the user may act on — advice or recommendations, drafted artifacts such as goals, plans, pitches, proposals…
от Anthropicdata-consolidate
Joins the plant's scheduled exports and connector data into one working dataset — ERP items (NetSuite or Infor M3), sales orders, production work orders…
от Anthropicinspection-to-capa
Runs the quality chain end to end: writes the nonconformance against the requirement it violates, searches history at the moment of writing to say whether…
от Anthropic