---
updatedAt: 2026-09-29T21:00:15.000Z
agentTools:
  projectIndex: https://docs.getmontecarlo.com/llms.txt
---

# MC Prevent

MC Prevent is Monte Carlo's suite of agents for preventing bad data changes before they reach production. This doc covers the **Code Change** skill, which runs inside your AI editor during development. The suite also includes PR Agent (code review) and CI Agent (pipeline gating).  MC Prevent: Code Change surfaces data observability context before you write a single line of code and keeps it there through every step of your change.

## What it does

When you open a dbt model or reference a table, the plugin automatically pulls Monte Carlo context into your editor: table health, active alerts, downstream blast radius, and monitor coverage. Your AI editor uses that context to shape its recommendations — not just surface it as a sidebar.

Before any edit, it assesses risk. After an edit, it generates targeted validation queries. When you add new logic, it generates and deploys the right monitor.

**No commands required.** It activates automatically based on what you're working on.

***

## Core workflows

### 1. Table health check

Fires when you open a `.sql` file, dbt model, or reference a table name. Surfaces freshness, row counts, importance score, lineage, and active alerts.

### 2. Change impact assessment

Fires automatically before any SQL edit — not just schema changes, but filter tweaks, bugfixes, parameter changes, and reverts. Returns:

* Downstream blast radius (tables, models, BI reports)
* Active incidents on affected tables
* Column exposure in recent queries
* Monitor coverage gaps
* A risk tier: **High / Medium / Low**
* A plain-English recommendation tied to the specific change

If risk is High or Medium, the plugin stops and asks for confirmation before editing.

### 3. Monitor generation

After you add a new column, metric, filter, or business rule, the plugin suggests and generates the right monitor type — validation, metric, comparison, or custom SQL — as a YAML file ready to deploy.

### 4. Alert triage

When you're investigating a data quality issue: lists open alerts, checks table state, traces lineage to find the root cause or blast radius.

### 5. Change validation queries

After you've made a change and are ready to test, ask: *"generate validation queries"* or *"validate this change."* The plugin generates 3–5 targeted SQL queries — null checks, before/after row counts, distribution checks — based on the exact columns, filters, and business logic you modified. Saved to `validation/<table_name>_<timestamp>.sql`.

***

## Compatibility

### Editors

Works with any AI editor that supports MCP and the Agent Skills format: Claude Code, Cursor, VS Code.

### Data stacks

| Stack                            | Support                                                                |
| -------------------------------- | ---------------------------------------------------------------------- |
| dbt + any MC-supported warehouse | Full                                                                   |
| SQL-first, no dbt                | Partial — core workflows available via explicit prompting              |
| Databricks notebooks             | Partial — health check, impact assessment, and alert triage work       |
| SQLMesh                          | Partial — core workflows work; native project structure support coming |
| PySpark / non-SQL pipelines      | Limited — manual prompting only                                        |

***

## Prerequisites

* Claude Code, Cursor, VS Code, or any editor with MCP support
* Monte Carlo account with Editor role or above
* [MC CLI](https://pypi.org/project/montecarlodata/) for monitor deployment: `pip install montecarlodata`

***

## Installation

### Recommended: Install via plugin

MC Prevent ships as part of the [mc-agent-toolkit](https://docs.getmontecarlo.com/docs/agent-toolkit) plugin, which bundles the skill with hooks, commands, and pre-configured tool permissions for the best experience.

**Step 1** — Add the Monte Carlo plugin marketplace:

```
/plugin marketplace add monte-carlo-data/mc-agent-toolkit
```

**Step 2** — Install the plugin:

```
/plugin install mc-agent-toolkit@mc-marketplace
```

**Step 3** — Authenticate. In Claude Code, run `/mcp`, select `monte-carlo-mcp`, and complete the OAuth flow in your browser.

**Step 4** — Verify: paste `"Test my Monte Carlo connection"` into Claude. It will confirm your credentials.

> **Note:** The plugin bundles its own MCP server, so no separate MCP configuration is needed. Updates are available via `claude plugin update`.

***

<br />

### Advanced: Install the skill directly

For use with non-Claude-Code agents or skill registries.

**Via Vercel CLI:**

```
npx skills add monte-carlo-data/mc-agent-toolkit --skill prevent
```

**Manual:**

```
cp -r skills/prevent ~/.claude/skills/prevent
```

You'll also need to configure the Monte Carlo MCP server and set tool permissions manually. See the [full setup guide](https://github.com/monte-carlo-data/mc-agent-toolkit).

***

## Deploying generated monitors

When the plugin generates a monitor, it saves YAML to `monitors/<table>.yml`. Deploy with the MC CLI:

```bash
montecarlo monitors apply --dry-run    # preview changes
montecarlo monitors apply --auto-yes   # apply
```

Your project needs a `montecarlo.yml` in the working directory:

```yaml
version: 1
namespace: <your-namespace>
default_resource: <your-warehouse-name>
```

***

## What it won't activate on

The plugin only fires on dbt models. It does not activate on seed files, analysis files, config files (`dbt_project.yml`, etc.), or one-off SQL scripts outside a dbt project. For macros and snapshots, auto-context is skipped on open, but the pre-edit gate still applies.

***

## Troubleshooting

See [TROUBLESHOOTING.md](https://github.com/monte-carlo-data/mc-agent-toolkit/blob/main/skills/prevent/references/TROUBLESHOOTING.md) in the repository.