# Native SQL

> Native SQL is an open-source agent skill for databases. Lets an agent write parameterized native SQL queries and filter widgets for Metabase. It is available on Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, Windsurf and Goose.

- **Kind:** Skill
- **Pricing:** Open source
- **Platforms:** Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, Windsurf, Goose
- **Website:** https://github.com/metabase/metabase-cli/tree/main/packages/cli/skill-data/native-sql
- **Repository:** https://github.com/metabase/metabase-cli
- **GitHub stars:** 20
- **License:** AGPL-3.0
- **Skill name:** native-sql
- **Collection:** https://github.com/metabase/metabase-cli
- **Categories:** [databases](https://ai-powered.com/categories/databases), [analytics and data](https://ai-powered.com/categories/analytics-and-data)
- **Listing updated:** 2026-12-03

## About

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".

## What it can access

From a static check of the files on GitHub; nothing was run.

- [Instructions only, no scripts](https://github.com/metabase/metabase-cli/tree/HEAD/packages/cli/skill-data/native-sql)
- [Asks for: Read, Write, Edit, Bash, AskUserQuestion](https://github.com/metabase/metabase-cli/blob/HEAD/packages/cli/skill-data/native-sql/SKILL.md)
- [License: AGPL-3.0](https://github.com/metabase/metabase-cli/tree/HEAD/packages/cli/skill-data/native-sql)

## Features

- **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

## Install

### Claude Code

Copy the skill folder to `~/.claude/skills/native-sql` to use it in all your projects:

```sh
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.

### Codex

Copy the skill folder to `~/.agents/skills/native-sql` to use it in every repository:

```sh
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.

### Cursor

Copy the skill folder to `~/.cursor/skills/native-sql` to use it in every project:

```sh
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.

### Gemini CLI

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

```sh
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.

### VS Code

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

```sh
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.

### Other agents

Get the folder:

```sh
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.

## 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.

## Alternatives

- [Mbql](https://ai-powered.com/skills/mbql): Mbql is an open-source agent skill for analytics and data.
- [Dashboard](https://ai-powered.com/skills/dashboard): Dashboard is an open-source agent skill for analytics and data.
- [Metabase CLI](https://ai-powered.com/skills/metabase-cli): Metabase CLI is an open-source agent skill for analytics and data.
- [Metadata](https://ai-powered.com/skills/metadata): Metadata is an open-source agent skill for analytics and data.
- [Core](https://ai-powered.com/skills/core-metabase): Core is an open-source agent skill for analytics and data.
- [Data workflow](https://ai-powered.com/skills/data-workflow): Data workflow is an open-source agent skill for analytics and data.
- [Bigquery basics](https://ai-powered.com/skills/bigquery-basics): Bigquery basics is an open-source agent skill for databases.
- [SQL optimization](https://ai-powered.com/skills/sql-optimization): SQL optimization is an open-source agent skill for databases.

---
Source: https://ai-powered.com/skills/native-sql
