Agent skill

Bruin Semantic Layer

by bruin-data in bruin-data/bruin

A skill your agent uses when creating, editing, reviewing, or troubleshooting Bruin semantic layer models, semantic query CLI usage, metric and dimension definitions, joins, segments, filters…

Apache-2.0Auto-check passedDatabases

Install Bruin Semantic Layer

skills CLI
$ npx skills add bruin-data/bruin --skill bruin-semantic-layer -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install bruin-data/bruin bruin-semantic-layer --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/bruin-data/bruin.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skills/bruin-semantic-layer .claude/skills/bruin-semantic-layer && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
bruin-semantic-layer
GitHub stars
1.8k
Token cost
~2.6k tokens
SKILL.md length
1,060 words
Files
1
Skills in repo
10
Repo updated
First seen
Licence
Apache-2.0

At a glance

A skill your agent uses when creating, editing, reviewing, or troubleshooting Bruin semantic layer models, semantic query CLI usage, metric and dimension definitions, joins, segments, filters…

  • Works in 5 steps: Find the repository root and inspect… → Use local source of truth before… → Keep model names unique across the… → …
  • Troubleshooting Bruin semantic layer models
  • SKILL.md covers Workflow, Model Pattern, Default Model Behavior and Metric Behavior, plus 6 more sections
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md

What it does

Bruin Semantic Layer is an agent skill from bruin-data/bruin. Use when creating, editing, reviewing, or troubleshooting Bruin semantic layer models, semantic query CLI usage, metric and dimension definitions, joins, segments, filters, windows, semantic quality checks, or semantic-layer tests and docs in a Bruin repository.

Its SKILL.md is about 2.6k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.

It sits in Databases. It works with SQL. The repository describes itself as: Build data pipelines with SQL and Python, ingest data from different sources, add quality checks, and build end-to-end flows. The licence is Apache-2.0.

When your agent uses it

  • Troubleshooting Bruin semantic layer models
  • Semantic query CLI usage
  • Metric and dimension definitions
  • Semantic quality checks

Example prompts

  • “/bruin-semantic-layer”

Workflow steps

5 steps, taken from the first numbered list in SKILL.md.

  1. Find the repository root and inspect semantic/ before editing. Bruin loads every .yml and .yaml model under the repository-level semantic/…
  2. Use local source of truth before guessing: docs/core-concepts/semantic-layer.md, docs/commands/query.md, docs/commands/semantic.md…
  3. Keep model names unique across the semantic catalog. New models should set schema: v1, although omitted schema defaults to v1.
  4. Prefer reusable, business-named metrics, dimensions, and segments. Avoid putting dashboard-specific logic into one large SQL query.
  5. Validate with bruin semantic validate, run bruin semantic check when a connection is available, then run the repository-required final…

What it can do on your machine

Read from SKILL.md and the folder at commit c2ab5b5. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md (its code samples are bash and yaml).

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Bruin Semantic Layer loads about 2.6k tokens when it runs. Until then it costs about 71 tokens; SKILL.md has 1,060 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~71
When it runs · the whole SKILL.md, loaded when a task matches
~2.6k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from bruin-data/bruin at commit c2ab5b5, republished under its Apache-2.0 licence (© bruin-data). 1,060 words, ~2,619 tokens.

Download SKILL.mdSave it as .claude/skills/bruin-semantic-layer/SKILL.md (or your agent's skills folder).
name
bruin-semantic-layer
description
Use when creating, editing, reviewing, or troubleshooting Bruin semantic layer models, semantic query CLI usage, metric and dimension definitions, joins, segments, filters, windows, semantic quality checks, or semantic-layer tests and docs in a Bruin repository.

Bruin Semantic Layer

Workflow

  1. Find the repository root and inspect semantic/ before editing. Bruin loads every .yml and .yaml model under the repository-level semantic/ directory next to .bruin.yml.
  2. Use local source of truth before guessing: docs/core-concepts/semantic-layer.md, docs/commands/query.md, docs/commands/semantic.md, semantic-engine/model.go, semantic-engine/engine.go, semantic-engine/graph.go, and semantic-engine/checks.go.
  3. Keep model names unique across the semantic catalog. New models should set schema: v1, although omitted schema defaults to v1.
  4. Prefer reusable, business-named metrics, dimensions, and segments. Avoid putting dashboard-specific logic into one large SQL query.
  5. Validate with bruin semantic validate, run bruin semantic check when a connection is available, then run the repository-required final checks before finishing.

Model Pattern

Create or edit files under semantic/:

yaml
schema: v1
name: orders
label: Orders
description: Revenue and order metrics

source:
  table: analytics.orders
  connection: warehouse

primary_key: order_id

joins:
  - name: customers
    relationship: many_to_one
    foreign_key: customer_id

dimensions:
  - name: order_id
    type: string
    checks:
      - name: not_null
      - name: unique
  - name: amount
    type: number
  - name: order_date
    type: time
    expression: created_at
    granularities:
      day: date_trunc('day', created_at)
      month: date_trunc('month', created_at)
  - name: country
    type: string
    checks:
      - name: not_null
      - name: accepted_values
        value: [US, DE]
  - name: is_first_order
    type: boolean
    expression: customer_order_number = 1

metrics:
  - name: revenue
    expression: sum(amount)
    format:
      type: currency
      currency: USD
      decimals: 2
    checks:
      - name: positive
  - name: order_count
    expression: count(distinct order_id)
  - name: avg_order_value
    expression: "{revenue} / {order_count}"
  - name: completed_revenue
    expression: sum(amount)
    filter: "status = 'completed'"
  - name: running_revenue
    expression: "{revenue}"
    window:
      type: running_total
      order_by: order_date
      partition_by:
        - country

segments:
  - name: completed
    filter: "status = 'completed'"

checks:
  - name: completed_revenue_matches_finance
    query:
      metrics: [revenue]
      segments: [completed]
    value: 730
  - name: no_negative_amounts
    query:
      dimensions: [order_id]
      filters:
        - dimension: amount
          operator: lt
          value: 0
    count: 0

Default Model Behavior

  • source.table is required and can be a relation name or a parenthesized SQL subquery with an alias.
  • source.connection is optional. bruin semantic validate, bruin semantic check, and bruin query --pipeline use it when --connection is not passed.
  • label, description, group, hidden, and format metadata help consumers but do not change SQL generation.
  • Dimension expression defaults to the dimension name.
  • Dimension type can be string, number, boolean, or time; only time dimensions can use granularities.
  • Query time dimensions as name:granularity, for example order_date:month.
  • hidden: true hides a dimension from UI-style consumers but does not make it unqueryable.
  • Metrics, dimensions, and segments share a model-level namespace; duplicate names are invalid.
  • Metric, dimension, and segment names should be stable API names, not display labels.

Metric Behavior

  • Base metrics are SQL aggregate expressions such as sum(amount) or count(distinct order_id).
  • Derived metrics use {metric_name} references. References must resolve and cannot form cycles.
  • Division by a referenced metric is guarded with NULLIF(..., 0) during SQL generation.
  • Metric filter wraps the metric aggregation. For example, sum(amount) with a filter becomes a conditional aggregate.
  • A metric can mix raw aggregation and {refs} for simple queries, but do not put that mixed metric in a window metric dependency chain.
  • Supported format metadata types are number, currency, percentage, and decimal.

Window Metrics

Window metrics calculate after an inner grouped query and must use expression: "{base_metric}".

  • Supported window.type values: running_total, lag, lead, rank, and percent_of_total.
  • running_total, lag, lead, and rank require window.order_by referencing a dimension.
  • lag and lead default offset to 1 when omitted or set to zero.
  • partition_by entries must reference dimensions.
  • percent_of_total does not require order_by; it can use partition_by.
  • Filters and segments are applied inside the inner query before the window expression runs.
  • Window metrics cannot have checks, because they return one row per order_by group. Use a model check instead.

Filters And Segments

  • Segments are named SQL filters and are applied with --segment.
  • Structured filters use JSON with dimension, operator, and optional value.
  • Supported operators: equals, not_equals, gt, gte, lt, lte, in, not_in, between, is_null, is_not_null.
  • between accepts a two-item array or an object with start and end.
  • Filters can also use raw expression; use this sparingly because it bypasses structured validation.
  • Filters or segments that reference metrics or aggregates compile into HAVING; dimension-only filters compile into WHERE.
  • Filter values are SQL-formatted by type; strings are single-quoted and escaped.

Joins

  • Join name is the relation prefix used in queries, such as customers.country.
  • If model is omitted, Bruin uses the join name as the target model name.
  • Valid relationships are one_to_one, many_to_one, one_to_many, and many_to_many.
  • Only one_to_one and many_to_one are automatically traversed in semantic queries because they avoid fanout.
  • A join needs either foreign_key or custom sql.
  • For foreign_key joins, Bruin joins the current model's foreign_key to the target model's target_key; if target_key is omitted, the target model must define primary_key.
  • Custom join SQL can reference aliases such as {orders}, {customers}, or the join name placeholder.
Show full SKILL.md (455 more words)Show less

Quality Checks

  • Dimension checks (dimensions[].checks) work like column checks: not_null, unique, positive, non_negative, negative, min, max, accepted_values, and pattern. They test every row of the model source, and all of them except not_null ignore nulls.
  • Metric checks (metrics[].checks) test the metric computed over the whole model: not_null, positive, non_negative, negative, min, max, and equals. A null metric fails every metric check.
  • Model checks (top-level checks) need a unique name and a query. The query is a semantic query with dimensions, metrics, filters, segments, sort, and limit, and accepts the name:granularity and name:direction shorthands. There is no raw SQL option.
  • To assert that rows should not exist, select a dimension, filter down to the bad rows, and set count: 0. To find unmatched join rows, filter on a null joined dimension.
  • A model check sets either value or count, never both. count wraps the query in SELECT count(*). value can be:
    • a scalar, for a single-column, single-row result;
    • a mapping, for exactly one row;
    • a list, for the full result set, with one mapping per row keyed by dimension or metric name. Single-column queries can use bare values.
  • Only the listed columns are compared, and rows are compared in order only when the query has a sort. Without value or count, the check expects 0.
  • min, max, and equals require a value, accepted_values requires a non-empty list, and pattern requires a string. Other checks reject a value. A check name can appear only once per dimension or metric.
  • bruin semantic validate validates definitions, and dry-runs the compiled SQL when it finds a connection (--connection, then source.connection). A model without a usable connection only gets structural validation and a warning.
  • bruin semantic check runs the checks and exits non-zero on any failure. Use --model to limit it to specific models and --output json for machine-readable results.

Query Pattern

Use an anchor SQL asset when Bruin should infer the pipeline, connection, and dialect:

bash
bruin query \
  --asset ./pipelines/daily-orders/assets/orders.sql \
  --semantic-model orders \
  --dimension order_date:month \
  --metric revenue \
  --filter '{"dimension":"country","operator":"equals","value":"US"}' \
  --segment completed \
  --sort revenue:desc \
  --output json

Use a pipeline path when there is no anchor asset. Pass the connection explicitly, or leave out --connection if the model sets source.connection:

bash
bruin query \
  --pipeline ./pipelines/daily-orders \
  --connection warehouse \
  --semantic-model orders \
  --dimension customers.country \
  --metric revenue \
  --sort customers.country:asc

Semantic query mode requires at least one dimension or metric and cannot be combined with --query. Sort direction defaults to asc; --limit applies only when greater than zero.

Validation Notes

  • Required model fields: name and source.table.
  • Required item fields: dimension name, metric name and expression, segment name and filter.
  • Window metrics must reference exactly one metric, for example expression: "{revenue}".
  • Window order_by and partition_by values must reference dimensions on the model.
  • Joined dimensions must resolve through a safe join path.
  • Unknown metrics, dimensions, segments, filter operators, sort fields, and granularities fail semantic query compilation.

For behavior changes, update the implementation, tests, and user-facing docs together: semantic-engine/, pkg/semanticcheck/, cmd/semantic.go, docs/core-concepts/semantic-layer.md, docs/commands/query.md, and docs/commands/semantic.md.

© bruin-data, Apache-2.0. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in skills/bruin-semantic-layer of bruin-data/bruin.

Open the folder on GitHubat commit c2ab5b5

Compare with similar skills

Bruin Semantic Layer next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Bruin Semantic Layer compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Bruin Semantic Layer this skillbruin-data/bruin1.8k—~2.6kAutomated safety check: PassApache-2.0
Code Implementationapache/shardingsphere21k—~1.2kAutomated safety check: PassApache-2.0
Analyzing Dataastronomer/agents451—~1.3kAutomated safety check: PassApache-2.0
Basincloudflare/skills3k1 repos~684Automated safety check: PassApache-2.0
VisualizationFrankChen021/datastoria327—~1.2kAutomated safety check: PassCustom licence
Databricks Dbsqldatabricks/databricks-agent-skills3451 repos~2.8kAutomated safety check: PassCustom licence

Similar skills

  • Code Implementation

    apache/shardingsphere

    Implement, fix, refactor, or remove repository code under required scope, non-regression, verification, and review gates.

    21k GitHub stars~1.2k tokensUpdated yesterday
    DatabasesAuto-check passed
  • Analyzing Data

    astronomer/agents

    Queries the data warehouse with SQL and answers business questions about data.

    451 GitHub stars~1.3k tokensUpdated yesterday
    DatabasesAuto-check passed
  • Basin

    cloudflare/skills

    Official

    Build and troubleshoot Cloudflare Basin analytics workflows with Basin Pipelines, Basin Catalog, and Basin SQL.

    3k GitHub starsUsed in 1 repo~684 tokens
    DatabasesAuto-check passed
  • Visualization

    FrankChen021/datastoria

    Rules for charts and visualization. An agent skill from FrankChen021/datastoria.

    327 GitHub stars~1.2k tokensUpdated 2 mo ago
    DatabasesAuto-check passed
  • Databricks Dbsql

    databricks/databricks-agent-skills

    Official

    Databricks SQL (DBSQL) advanced features and SQL warehouse capabilities.

    345 GitHub starsUsed in 1 repo~2.8k tokens
    DatabasesAuto-check passed
  • Rocky Dsl Change

    rocky-data/rocky

    Rocky DSL (.rocky file) cross-subproject cascade. An agent skill from rocky-data/rocky.

    304 GitHub stars~1.3k tokensUpdated today
    DatabasesAuto-check passed

More from bruin-data/bruin

All 10 skills in this repo
  • Record Vhs Demo

    bruin-data/bruin

    Create, update, render, and visually verify polished Bruin CLI terminal demos with VHS.

    1.8k GitHub stars~1.3k tokensUpdated yesterday
    Auto-check passed
  • Add Ingestr Source

    bruin-data/bruin

    Add Bruin CLI support for a new ingestr source. An agent skill from bruin-data/bruin.

    1.8k GitHub stars~1.6k tokensUpdated yesterday
    Auto-check passed
  • Create Dashboard

    bruin-data/bruin

    Create DAC dashboards by writing YAML or TSX dashboard definition files.

    1.8k GitHub stars~4.3k tokensUpdated yesterday
    Auto-check passed
  • Duplicate Investigate

    bruin-data/bruin

    A skill your agent uses when duplicate rows, unstable primary keys, repeated ingestion, or failed uniqueness checks appear in a Bruin asset.

    1.8k GitHub stars~1.1k tokensUpdated yesterday
    Auto-check passed
  • Pipeline Diagnose

    bruin-data/bruin

    A skill your agent uses when a Bruin pipeline, asset, or command fails and the cause is not yet clear.

    1.8k GitHub stars~1k tokensUpdated yesterday
    Auto-check passed
  • Schema Drift Check

    bruin-data/bruin

    A skill your agent uses when a pipeline fails because source, destination, or declared asset columns may have changed.

    1.8k GitHub stars~1.1k tokensUpdated yesterday
    Auto-check passed

Works with

Questions about Bruin Semantic Layer

What does Bruin Semantic Layer do?

A skill your agent uses when creating, editing, reviewing, or troubleshooting Bruin semantic layer models, semantic query CLI usage, metric and dimension definitions, joins, segments, filters…. Bruin Semantic Layer is an agent skill from bruin-data/bruin. Use when creating, editing, reviewing, or troubleshooting Bruin semantic layer models, semantic query CLI usage, metric and dimension definitions, joins, segments, filters, windows, semantic quality checks, or semantic-layer tests and docs in a Bruin repository.

When should I use Bruin Semantic Layer?

Bruin Semantic Layer fits situations like: troubleshooting Bruin semantic layer models; semantic query CLI usage; metric and dimension definitions; semantic quality checks.

How do I install Bruin Semantic Layer in Claude Code?

Run `npx skills add bruin-data/bruin --skill bruin-semantic-layer -a claude-code`. Or copy the skill folder (skills/bruin-semantic-layer in bruin-data/bruin) into .claude/skills/bruin-semantic-layer in your project. Claude Code loads it when a task matches its description.

How do I install Bruin Semantic Layer in Codex?

Run `npx skills add bruin-data/bruin --skill bruin-semantic-layer -a codex`. Or copy the skill folder (skills/bruin-semantic-layer in bruin-data/bruin) into .agents/skills/bruin-semantic-layer in your project. Codex loads it when a task matches its description.

Can I use Bruin Semantic Layer in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add bruin-data/bruin --skill bruin-semantic-layer -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/bruin-semantic-layer, .gemini/skills/bruin-semantic-layer, .github/skills/bruin-semantic-layer and .opencode/skills/bruin-semantic-layer in your project.

What does Bruin Semantic Layer need to run?

SKILL.md names no scripts, command-line tools or credentials: Bruin Semantic Layer is instructions for the agent only.

Does Bruin Semantic Layer access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Bruin Semantic Layer safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Bruin Semantic Layer use?

Bruin Semantic Layer is published under the Apache-2.0 licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Bruin Semantic Layer use?

About 2.6k tokens (SKILL.md is roughly 10k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Bruin Semantic Layer?

Skills that share tags, products or a category with Bruin Semantic Layer: Code Implementation (apache/shardingsphere, 21k stars), Analyzing Data (astronomer/agents, 451 stars), Basin (cloudflare/skills, 3k stars) and Visualization (FrankChen021/datastoria, 327 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Bruin Semantic Layer?

bruin-data (a GitHub organization) maintains it in bruin-data/bruin, which has 1,771 GitHub stars. The repository holds 10 skills in this directory. The repository was last updated on October 7, 2026.

Source: bruin-data/bruin on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.