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]
A metric in the Metabase Representation Format, the open YAML spec for everything Remote Sync stores.

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.

How a change reaches production A coding agent builds in a development Metabase through the Metabase CLI. The change is pushed to a branch in your git repository as a pull request. Once your team reviews and merges it, the read-only production Metabase pulls it in, and everyone, people and agents alike, works from the same definitions. MB CLI PUSH MERGE SAME NUMBERS REVIEWED CODING AGENT CLAUDE CODE · CODEX DEV METABASE READ-WRITE GIT REPO BRANCH · PULL REQUEST PROD METABASE READ-ONLY YOUR TEAM PEOPLE · METABOT · AGENTS

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?
Managing analytics the way engineers manage software: as files in a git repository, changed on branches, reviewed in pull requests, and released when they're merged. In Metabase, Remote Sync keeps your transforms, semantic layer, content and data apps in your repo as YAML, and the Metabase CLI lets coding agents do the building.
What does Metabase put in our repo?
YAML files that describe your content: transforms and their tests, the Library (published tables, metrics, segments, measures, the glossary, snippets and data actions), data apps, and the questions, models, dashboards and Documents in collections you choose to sync. Your data never goes to git. Neither do people, groups and permissions, alerts and subscriptions, database connections, transform jobs or table metadata.
Which git providers does Remote Sync work with?
GitHub, GitLab and Bitbucket. For local development, Remote Sync can also point at a bare git repo on the same machine as your Metabase.
Do we need a separate development Metabase?
We recommend one. Build in a development Metabase in read-write mode, and keep production in read-only mode, so every change goes through git. If you use transforms, connect development and production to separate databases with identical schemas, so a transform run in development doesn't change production data.
Does this replace dbt?
No. If you use dbt to build your tables, keep it. Your semantic layer, content and data apps sit on top, versioned in your repo. Some teams also build transforms in Metabase, to own a smaller stack in one place.
Which coding agents work with it?
Any agent that can run commands can use the Metabase CLI, including Claude Code, Codex and Cursor. Metabase's agent skills are built for Claude Code, and may also work with other agents.
How do we set up the Metabase CLI?
Install it from npm with 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.
Should we use the Metabase CLI or the MCP server?
Use the CLI when a coding agent is building or changing content in bulk, running in a script or CI, or making changes that ship through git. Use the MCP server when people want to ask questions, explore and build as they chat, in Claude, ChatGPT, Cursor or VS Code. The same permissions apply to both. See MCP server.
Can an agent push straight to production?
Not if production is read-only and your main branch is protected. A read-only Metabase only changes when it pulls from git, so a change reaches production when someone merges it. Anyone who can push to that branch can change what production loads, so treat push access like admin access.
Which plans include it?
Remote Sync, and the agent-driven workflow built on it, are on Pro and Enterprise. The Metabase CLI and the MCP server work on every plan, though some CLI commands, like Git sync, need Pro or Enterprise.