Skip to content
Skill

Native SQL

Lets an agent write parameterized native SQL queries and filter widgets for Metabase

Native SQL is an open-source agent skill for databases. 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 Native SQL

This skill covers authoring native SQL questions in Metabase through the mb CLI. It explains the query envelope for a raw SQL stage, how template tags map to SQL placeholders, and how to choose between a plain variable and a field filter bound to a real column. It also covers optional clauses, snippets, references to saved questions, and wiring tags to dashboard filters.

The guidance steers the agent toward structured queries when they can express the logic, and toward native SQL when the user asks for it or the query needs engine-specific features. It describes a validation loop using schema checks and dry runs before execution, and notes that SQL syntax errors only surface when the warehouse runs the query.

Using the skill requires the mb CLI and access to a Metabase instance with a database connection. It refers to a bundled reference file for full template-tag field lists and to other skills for shared CLI conventions.

When your agent uses it

Author native SQL queries with parameters (filter widgets) for the `mb` CLI. Native SQL is a query whose single stage is raw SQL (`mbql.stage/native`) instead of structured MBQL — the same query envelope, so it is pre-flight-validated and round-trips. Covers the shape, the four template-tag kinds (raw variable, field filter, snippet, card reference), the variable / optional-block / snippet / card-reference syntax, the field-filter-vs-variable decision, the field ref in a field-filter dimension, wiring a tag to a dashboard filter, and running with values. Triggers — "write a SQL question", "add a filter widget to my SQL", "parameterize this query", "use a field filter", "reference a saved question in SQL", "why does my variable return no rows".

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 (18 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/native-sql 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/native-sql &&
cp -R "$tmp/packages/cli/skill-data/native-sql" ~/.claude/skills/native-sql &&
rm -rf "$tmp"

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

Claude Code docs on skills

Copy the skill folder to ~/.agents/skills/native-sql 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/native-sql &&
cp -R "$tmp/packages/cli/skill-data/native-sql" ~/.agents/skills/native-sql &&
rm -rf "$tmp"

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

Codex docs on skills

Copy the skill folder to ~/.cursor/skills/native-sql 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/native-sql &&
cp -R "$tmp/packages/cli/skill-data/native-sql" ~/.cursor/skills/native-sql &&
rm -rf "$tmp"

For one project only, put the folder in .cursor/skills/native-sql 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/native-sql

Or copy the folder to ~/.gemini/skills/native-sql yourself.

Gemini CLI docs on skills

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

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

For one project only, put the folder in .github/skills/native-sql 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/native-sql into your agent's skills folder as native-sql. Agents that support SKILL.md read one folder per skill.

The SKILL.md format

What it does

Native query envelope
Describes the single raw SQL stage format that Metabase accepts and validates before running.
Template tag kinds
Explains raw variables, field filters, snippets and card references and when each applies.
Field filter rules
Shows how to bind a bare placeholder to a physical column so Metabase generates the right condition.
Optional clauses
Covers wrapping clauses in optional blocks that drop out when a value is empty.
Dashboard filter wiring
Maps dashboard parameters to template tags and runs saved cards with parameter values.
Common pitfalls
Lists mistakes such as wrapping field filters in operators and using DDL or multiple statements.

Good for

  • Write a SQL question with a filter widget for a status column
  • Parameterize an existing SQL query with a minimum value input
  • Reference a saved question inside a new SQL query
  • Expose a SQL filter as a dashboard filter
  • Debug a SQL question that returns no rows when a variable is set

Native SQL FAQ

What does the skill need to run?

It uses the mb CLI and works through the usual schema, dry-run and run loop against a Metabase instance.

When should a field filter be used instead of a raw variable?

A field filter should be used when the tag filters a real table column, since it generates the correct condition and a dropdown or date picker. A raw variable is for literals or computed values that are not a column.

Can a referenced saved question take parameter values from the parent query?

No. A referenced card runs with its own saved defaults, and snippets are static text. Only raw variables and field filters accept user values.

Does the skill allow writing data or creating tables with native SQL?

No. It states that DDL, multiple statements and writes are unsupported in the native editor and points to transforms or data actions instead.

How do I install Native SQL in Claude Code?

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

Does Native SQL 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 Native SQL?

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 Native SQL?

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

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