sidequery/sidemantic/modeler
Claude Code and agent skill by sidequery/sidemantic
- community
Checking that the SKILL.md file is still in the repository.
Build, validate, and manage semantic models using Sidemantic. Use when asked to create a semantic layer, define metrics/dimensions, model a database schema, generate models from SQL queries, import from Cube/dbt/LookML, or set up analytics definitions. Prioritizes CLI-first workflows, with YAML and optional Python API usage for advanced automation.
Install
npx vskill@latest install sidequery/sidemantic/modelerSKILL.md
Sidemantic Modeler
Build semantic layers that map physical database tables to business-friendly dimensions and metrics. Sidemantic generates SQL from these definitions, handling joins, aggregations, granularity, and dialect differences automatically.
Quick Start
2-Minute First Success (CLI-first onboarding path)
Assumes an orders table already exists in data.duckdb with status and order_amount columns. Use --format json or --format jsonl when consuming CLI results in automation; use --plain for stable tab-separated text. Primary data is stdout and status is stderr, so do not merge the streams before parsing.
YAML (preferred for file-based models)
Load and query:
Python API (advanced, optional)
Generate Models from SQL Queries
The fastest path when existing queries are available. The Migrator reverse-engineers semantic models by analyzing SQL: it extracts tables, columns, aggregations, joins, time dimensions, derived metrics, and window functions automatically.
CLI (bootstrap from a folder of .sql files)
Python API (advanced/automation only)
What the Migrator auto-detects
| Pattern in SQL | What it generates | |
|---|---|---|
SUM(amount) / COUNT(*) / AVG(price) | Metric with matching agg | |
COUNT(DISTINCT user_id) | Metric with agg: count_distinct | |
SUM(amount) AS revenue | Metric named revenue (preserves aliases) | |
GROUP BY status | Dimension type: categorical | |
DATE_TRUNC('month', created_at) | Dimension type: time, granularity extracted from SQL (here: month) | |
JOIN customers ON o.customer_id = c.id | Relationship many_to_one, foreign_key: customer_id | |
SUM(a) / NULLIF(COUNT(b), 0) | Derived metric with formula | |
SUM(x) OVER (ORDER BY date ROWS ...) | Cumulative metric with window | |
SUM(x) OVER (PARTITION BY DATE_TRUNC(...)) | Cumulative metric with grain_to_date | |
| Cross-model expressions | Graph-level derived metrics |
Workflow: queries first, then refine
- Collect existing SQL queries (dashboards, reports, ad-hoc analyses)
- Run
migrator.analyze_queries(queries)to generate a first pass - Review generated models: rename metrics, add descriptions, fix types
- Run coverage check to verify queries can be rewritten through the semantic layer
- Iterate until coverage is high
For the full Migrator API (all methods, outputs, edge cases), load references/generation.md.
Core Workflow
Follow these steps when building a semantic model from a database schema.
Step 1: Analyze the database schema
Inspect tables, columns, data types, and foreign key relationships. Identify which tables hold transactional/event data (fact tables) and which hold descriptive attributes (dimension tables).
Step 2: Create Model definitions
For each table, create a Model with:
name: a short, snake_case identifiertable: schema-qualified table name (e.g.,public.orders)primary_key: the table's primary key column (default:id)
Use sql instead of table for derived/virtual tables built from a SQL expression.
Step 3: Define Dimensions
Add dimensions for columns used in GROUP BY or WHERE clauses. Choose the correct type:
| Type | When to use | Example | |
|---|---|---|---|
categorical | Strings, enums, IDs for grouping | status, region | |
time | Dates/timestamps (enables granularity) | created_at, order_date | |
boolean | Computed true/false from SQL expression | sql: "amount > 100" | |
numeric | Numbers used for grouping, not aggregation | quantity_bucket |
Time dimensions require granularity (one of: second, minute, hour, day, week, month, quarter, year). Queries use double-underscore syntax: orders.order_date__month.
Use sql when the dimension maps to a different column name or a computed expression. If omitted, defaults to a column matching name.
Set parent on dimensions to create drill-down hierarchies (e.g., country > state > city).
Step 4: Define Metrics
Add metrics for columns that should be aggregated.
Simple aggregations (model-level):
| agg | SQL generated | Notes | |
|---|---|---|---|
sum | SUM(col) | Revenue, quantities | |
count | COUNT(*) | Row counts (no sql needed) | |
count_distinct | COUNT(DISTINCT col) | Unique values | |
avg | AVG(col) | Averages | |
min / max | MIN(col) / MAX(col) | Extremes | |
median | MEDIAN(col) | Median |
Model-level simple metrics currently validate against: sum, count, count_distinct, avg, min, max, median.
Use filters on a metric to create filtered aggregations (e.g., filters: ["status = 'completed'"]). These become CASE WHEN expressions, not WHERE clauses.
Complex metrics (usually graph-level, in top-level metrics: section):
| type | Purpose | Required fields | |
|---|---|---|---|
ratio | Division of two measures | numerator, denominator | |
derived | Arbitrary SQL formula | sql (references other metrics) | |
cumulative | Rolling/running totals | sql, optional window or grain_to_date | |
time_comparison | Period-over-period | base_metric, comparison_type (yoy/mom/wow/dod/qoq) | |
conversion | Funnel analysis | entity, base_event, conversion_event |
Graph-level metrics sit in the top-level metrics: section (outside models:). They reference model-level measures using model.metric syntax.
Step 5: Define Relationships
Connect models with relationships so Sidemantic can auto-generate JOINs.
| Type | Direction | Example | |
|---|---|---|---|
many_to_one | This model has FK to other | orders -> customers | |
one_to_one | Unique FK | user -> user_profile | |
one_to_many | Other model has FK to this | customer -> orders | |
many_to_many | Through junction table | students <-> courses |
Declare relationships on the model that owns the foreign key. For many_to_one, foreign_key defaults to {related_model}_id.
For many_to_many, specify through (junction model), through_foreign_key, and related_foreign_key.
Step 6: Validate and inspect
Step 7: Test with queries
Python API (optional):
Segments
Reusable named WHERE filters applied at query time. Unlike metric filters, segments affect all metrics in the query.
Segments are model-scoped and used as model.segment references at query time:
Python API (optional):
Loading from Other Formats
CLI-first:
Python API (optional):
Auto-detects: Cube (.yml with cubes:), dbt MetricFlow (.yml with semantic_models:), LookML (.lkml), Malloy (.malloy), Rill, Hex, Snowflake Cortex, and more.
For detailed field mappings from each format, load references/migration.md.
Auto-Registration
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewNot runA model review is scheduled for the next rescan.
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingplugins/sidemantic/skills/modeler/SKILL.md
Popularity
- 7-day trend score
- 0
Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/sidequery/sidemantic/modeler)