Analytics as code
Agents build. People review. Everything's versioned.
Keep your transforms, semantic layer, dashboards and data apps as files in your git repo. Your coding agent builds them through the Metabase CLI, your team reviews every change in a pull request, and production only gets what's merged.
Remote Sync is on Pro and Enterprise. The CLI and MCP server work on every plan.
# collections/main/queries/total_revenue_metric.yaml
name: Total Revenue
type: metric
display: scalar
database_id: Sample Database
dataset_query:
"lib/type": mbql/query
database: Sample Database
stages:
- "lib/type": mbql.stage/mbql
source-table: [Sample Database, null, ORDERS]
aggregation:
- - sum
- {}
- - field
- base-type: type/Float
- [Sample Database, null, ORDERS, TOTAL] Nothing reaches production without a pull request
Agents and people build in a development Metabase. Remote Sync pushes each change to a branch as YAML, your team reviews the diff, and the read-only production Metabase pulls in what's merged.
The whole stack, end to end, in one repo
Remote Sync versions everything from transforms to the apps people use, so one pull request can carry a new transform, the metric built on it, and the dashboard that shows it.
- Transforms SQL and Python transforms, with their tests, tags, folders and Python libraries Transforms
- Semantic layer The Library: published tables with their segments and measures, metrics, the glossary, SQL snippets and data actions Data Studio
- Questions and dashboards Questions, models, dashboards and Documents in the collections you choose to sync
- Data apps Each app's manifest and bundle, with its source code committed alongside Data apps
- What stays out Your data never goes to git. Neither do people, groups and permissions, database connections, or table metadata.
Build with the Metabase CLI and the agent you already use
Install the CLI and its skill, and Claude Code, Codex or Cursor works on your development Metabase the way it works on your code: it runs commands, checks the result, and hands you something to review.
-
Nearly all of Metabase, as commands. Transforms and their tests, tables and metadata, metrics, dashboards, the Library, data apps and Git sync. See the Metabase CLI docs.
-
Skills that match the CLI. The metabase-cli skill loads the instructions bundled with your version of the CLI, so they always match the commands your agent runs. Skills for the file format, semantic checks and data apps are in Metabase's agent skills repo.
-
Output sized for agents. Compact JSON by default, and flags to return only the fields an agent asks for.
-
An open file format. The Metabase Representation Format is a published YAML spec, with schemas you can validate against in CI.
-
Or build in a chat. The MCP server gives Claude, ChatGPT or Cursor your real tables, fields and sample values while they write questions and dashboards.
npm install -g @metabase/cli
mb auth login --url https://dev-metabase.example.com
npx skills add metabase/agent-skills --skill metabase-cli -a claude-code
# Then, in Claude Code, against your development Metabase:
/metabase-cli Build a weekly revenue dashboard on our published metrics.
# Push the change to your branch, then open a pull request:
mb git-sync export -m "Add weekly revenue dashboard"
gh pr create --title "Add weekly revenue dashboard" Let agents move fast, without letting them ship alone
An agent working straight in production:
-
Changes go live as they're made, and nobody checks the query first.
-
There's no record of what changed, or why a number moved.
-
A renamed column breaks dashboards nobody thought to check.
-
Every agent defines revenue its own way.
Analytics as code in Metabase:
-
Production is read-only. It only changes when a pull request is merged.
-
Every change is a diff. Review the YAML in GitHub, GitLab or Bitbucket, or pull the branch into a development Metabase to see it live.
-
Git history and Monitor keep the record: who changed what and when, and every call the CLI made. See usage analytics and auditing.
-
Lineage shows the blast radius. Check everything that depends on a table or metric before you change it. See lineage and dependencies.
-
Defined once. Metrics live in your semantic layer, so people and agents reuse the same definition.
Production loads whatever merges to its branch, so treat push access to that branch like admin access.
Let an AI data engineer run the loop
Robot Data Engineer (beta) works in your coding agent. It profiles your raw data, builds tested transforms, then the semantic layer and the dashboards and data apps on top.
-
It learns your Metabase first. It reads your existing tables, metrics and naming before it builds, and asks when something is ambiguous.
-
Verified as it builds. It writes a test for every rule in a transform, and a table isn't built until its tests pass.
-
You decide what ships. It builds in a local Metabase, and its changes reach production only through git and review.
npm install -g @metabase/rde
rde init
# Then ask your agent:
Build a sales pipeline dashboard from our Stripe data. Frequently asked questions
What is analytics as code?
What does Metabase put in our repo?
Which git providers does Remote Sync work with?
Do we need a separate development Metabase?
Does this replace dbt?
Which coding agents work with it?
How do we set up the Metabase CLI?
npm install -g @metabase/cli (Node.js 20.6 or later), log in with mb auth login, and add the metabase-cli skill to your agent. The CLI works with Metabase 58 or later. See the Metabase CLI docs.