Skip to content
Skill

Mbql

Writes and debugs MBQL query bodies for the mb CLI, with dry-run checks

Mbql is an open-source agent skill for analytics and data. It is available on Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, Windsurf and Goose.

Scripts
None
Platforms
Claude Code, Codex, Cursor
GitHub stars
20
Last commit
License
AGPL-3.0
Listing updated

Similar skills

About Mbql

This skill teaches an agent the structured MBQL query format used by the mb command-line tool for Metabase. It covers the query shape, the clause syntax for filters, aggregations, breakouts, ordering, limits, expressions and joins, plus multi-stage pipelines that read saved questions, models, metrics and segments as sources.

The workflow centers on a check loop: the agent validates a body with a dry run that compiles it on the server without executing, inspects the generated SQL or the tables and fields a body touches, and then runs it. The guidance explains how to read validation errors and which failures only surface when the warehouse runs the query.

The skill expects the mb CLI to be installed and configured with a profile, and it refers to the command-line schema and a bundled operator reference for the full list of operators. It also notes where a query body lives in cards, transforms, measures and segments.

When your agent uses it

Author and debug MBQL query bodies for the `mb` CLI — the query shape, clauses, filters, aggregation and breakout, order and limit, expressions, joins and FK columns, multi-stage pipelines, saved questions and definitions as sources, output column names, and the schema → dry-run → run loop. Use when writing or fixing any query body — `mb query`, a card's `dataset_query`, a transform's `source.query`, or a segment/measure `definition` — or when `--dry-run` or a run reports errors. Triggers — "write an MBQL query", "the dataset_query is wrong", "aggregate and group by", "join two tables", "month-over-month".

From the skill's SKILL.md. Your agent reads this description to decide when to load the skill.

What it can access

From a static check of its 2 files (20 KB) on GitHub on 4 December 2026. Nothing was run. Read the files before you install a skill: it can tell your agent to run anything its tools allow.

Check another skill before you install it.

Install

Copy the skill folder to ~/.claude/skills/mbql to use it in all your projects:

tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/metabase/metabase-cli.git "$tmp" &&
mkdir -p ~/.claude/skills &&
rm -rf ~/.claude/skills/mbql &&
cp -R "$tmp/packages/cli/skill-data/mbql" ~/.claude/skills/mbql &&
rm -rf "$tmp"

For one project only, put the folder in .claude/skills/mbql inside it instead.

Claude Code docs on skills

Copy the skill folder to ~/.agents/skills/mbql to use it in every repository:

tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/metabase/metabase-cli.git "$tmp" &&
mkdir -p ~/.agents/skills &&
rm -rf ~/.agents/skills/mbql &&
cp -R "$tmp/packages/cli/skill-data/mbql" ~/.agents/skills/mbql &&
rm -rf "$tmp"

For one repository only, put the folder in .agents/skills/mbql inside it instead.

Codex docs on skills

Copy the skill folder to ~/.cursor/skills/mbql to use it in every project:

tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/metabase/metabase-cli.git "$tmp" &&
mkdir -p ~/.cursor/skills &&
rm -rf ~/.cursor/skills/mbql &&
cp -R "$tmp/packages/cli/skill-data/mbql" ~/.cursor/skills/mbql &&
rm -rf "$tmp"

For one project only, put the folder in .cursor/skills/mbql inside it instead.

Cursor docs on skills

Run in a terminal (add --scope workspace to install it for the current workspace only):

gemini skills install https://github.com/metabase/metabase-cli.git --path packages/cli/skill-data/mbql

Or copy the folder to ~/.gemini/skills/mbql yourself.

Gemini CLI docs on skills

For GitHub Copilot in VS Code, copy the skill folder to ~/.copilot/skills/mbql:

tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/metabase/metabase-cli.git "$tmp" &&
mkdir -p ~/.copilot/skills &&
rm -rf ~/.copilot/skills/mbql &&
cp -R "$tmp/packages/cli/skill-data/mbql" ~/.copilot/skills/mbql &&
rm -rf "$tmp"

For one project only, put the folder in .github/skills/mbql inside it instead.

VS Code docs on skills

Get the folder:

git clone --depth 1 https://github.com/metabase/metabase-cli.git

Then copy metabase-cli/packages/cli/skill-data/mbql into your agent's skills folder as mbql. Agents that support SKILL.md read one folder per skill.

The SKILL.md format

What it does

Query shape and clauses
Explains the stage structure and the bracketed clause syntax with options, field references and ids.
Filters and aggregations
Covers AND and OR filters, relative and absolute date ranges, breakouts and named aggregations.
Joins and foreign keys
Shows how to reach columns of related tables through foreign keys or explicit joins.
Multi-stage pipelines
Describes filtering on aggregates and month-over-month comparisons using window offsets.
Dry-run authoring loop
Walks through schema lookup, dry-run validation, compiling to SQL and running queries.
Saved sources and definitions
Covers saved questions, models, metrics, segments and measures as query sources.

Good for

  • Write an MBQL query that counts orders by month
  • Fix a card's dataset_query that returns the wrong results
  • Join two tables through a foreign key and group the results
  • Compute month-over-month revenue change with a window offset
  • Debug a query that fails a dry run in the mb CLI

Mbql FAQ

What does Mbql need to work?

It relies on the mb CLI with a configured profile, and on the ids of databases, tables, fields and cards copied from the mb list commands.

When does the skill trigger?

When writing or fixing a query body for mb query, a card's dataset_query, a transform's source query, or a segment or measure definition, or when a dry run or run reports errors.

Does Mbql run queries for me?

The guidance uses dry-run to check and compile a body on the server, and a run executes it. Exit codes distinguish invalid bodies from server or warehouse failures.

When should native SQL be used instead?

The skill says to write native SQL for window functions beyond offset, CTEs, set operations, engine-specific functions, or when SQL is requested.

How do I install Mbql in Claude Code?

Copy the skill folder from GitHub to ~/.claude/skills/mbql to use it in all your projects, or to .claude/skills/mbql in one project.

Does Mbql run scripts?

No. It is instructions only, with no scripts. This comes from a static check of the files on GitHub; nothing was run. Read the files before you install it.

Which AI agents can use Mbql?

Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, Windsurf and Goose. Each reads skills in the SKILL.md format from its own folder; the install steps on this page list them.

What are the best alternatives to Mbql?

The closest alternatives to Mbql are Native SQL, Metabase CLI, Core, Dashboard and Data workflow.

Where this comes from

  • Description: from the skill's own SKILL.md.

More from metabase/metabase-cli

  1. Guides an agent to write end-to-end tests that run the built CLI against real Metabase

    • Open source
    • 20 GitHub stars
    • Developer tools
  2. Writes unit and Playwright tests for a Metabase data app with mocked queries and actions

    • Open source
    • 20 GitHub stars
    • Developer tools
  3. Plans fixtures, expectations and coverage for testing a transform's logic on known rows

    • Open source
    • 20 GitHub stars
    • Analytics and data
  4. Guides an agent to add a Metabase API resource across client, CLI and e2e tests

    • Open source
    • 20 GitHub stars
    • Analytics and data
  5. Sweeps a whole repository for architectural drift using parallel read-only review passes

    • Open source
    • 20 GitHub stars
    • Developer tools
  6. Runs a strict end-of-task review that flags architectural drift before work is marked done

    • Open source
    • 20 GitHub stars
    • Developer tools