jpskill.com
🛠️ 開発・MCP コミュニティ 🔴 エンジニア向け 👤 エンジニア・AI開発者

🛠️ Monte Carlo Prevent

monte-carlo-prevent

SQLやdbtでデータを編集する前に

⏱ RAG構築 1週間 → 1日

📺 まず動画で見る(YouTube)

▶ 【衝撃】最強のAIエージェント「Claude Code」の最新機能・使い方・プログラミングをAIで効率化する超実践術を解説! ↗

※ jpskill.com 編集部が参考用に選んだ動画です。動画の内容と Skill の挙動は厳密には一致しないことがあります。

📜 元の英語説明(参考)

Surfaces Monte Carlo data observability context (table health, alerts, lineage, blast radius) before SQL/dbt edits.

🇯🇵 日本人クリエイター向け解説

一言でいうと

SQLやdbtでデータを編集する前に

※ jpskill.com 編集部が日本のビジネス現場向けに補足した解説です。Skill本体の挙動とは独立した参考情報です。

⚡ おすすめ: コマンド1行でインストール(60秒)

下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。

🍎 Mac / 🐧 Linux
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o monte-carlo-prevent.zip https://jpskill.com/download/3177.zip && unzip -o monte-carlo-prevent.zip && rm monte-carlo-prevent.zip
🪟 Windows (PowerShell)
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/3177.zip -OutFile "$d\monte-carlo-prevent.zip"; Expand-Archive "$d\monte-carlo-prevent.zip" -DestinationPath $d -Force; ri "$d\monte-carlo-prevent.zip"

完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。

💾 手動でダウンロードしたい(コマンドが難しい人向け)
  1. 1. 下の青いボタンを押して monte-carlo-prevent.zip をダウンロード
  2. 2. ZIPファイルをダブルクリックで解凍 → monte-carlo-prevent フォルダができる
  3. 3. そのフォルダを C:\Users\あなたの名前\.claude\skills\(Win)または ~/.claude/skills/(Mac)へ移動
  4. 4. Claude Code を再起動

⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。

🎯 このSkillでできること

下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。

📦 インストール方法 (3ステップ)

  1. 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
  2. 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
  3. 3. 展開してできたフォルダを、ホームフォルダの .claude/skills/ に置く
    • · macOS / Linux: ~/.claude/skills/
    • · Windows: %USERPROFILE%\.claude\skills\

Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。

詳しい使い方ガイドを見る →
最終更新
2026-05-17
取得日時
2026-05-17
同梱ファイル
4

💬 こう話しかけるだけ — サンプルプロンプト

  • Monte Carlo Prevent を使って、最小構成のサンプルコードを示して
  • Monte Carlo Prevent の主な使い方と注意点を教えて
  • Monte Carlo Prevent を既存プロジェクトに組み込む方法を教えて

これをClaude Code に貼るだけで、このSkillが自動発動します。

📖 Skill本文(日本語訳)

※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。

[Skill 名] monte-carlo-prevent

Monte Carlo Prevent Skill

このスキルは、Monte Carlo のデータ可観測性コンテキストをエディターに直接もたらします。dbt モデルや SQL パイプラインを修正する際に、テーブルの健全性、リネージ、アクティブなアラートを表示したり、Claude Code を離れることなくモニター・アズ・コードを生成したりするために使用します。

参照ファイルはこのスキルファイルの隣にあります。それらにアクセスするには、Read ツールを使用してください(MCP リソースではありません)。

  • 完全なワークフローのステップバイステップ手順: references/workflows.md (このファイルからの相対パス)
  • MCP パラメーターの詳細: references/parameters.md (このファイルからの相対パス)
  • トラブルシューティング: references/TROUBLESHOOTING.md (このファイルからの相対パス)

このスキルをアクティブ化するタイミング

要求されるのを待たないでください。 ユーザーが以下のいずれかを行った場合、適切なワークフローを自動的に実行してください。

  • .sql ファイルまたは dbt モデル(models/ 内のファイル)を参照または開いた場合 → ワークフロー 1 を実行

  • テーブル名、データセット、または dbt モデル名をさりげなく言及した場合 → ワークフロー 1 を実行

  • モデルに対する計画された変更(新しい列、結合の更新、フィルターの変更、リファクタリング)を説明した場合 → 停止 — コードを記述する前にワークフロー 4 を実行

  • 既存のモデルに新しい列、メトリック、または出力式を追加した場合 → まずワークフロー 4 を実行し、その後、リスクティアに関係なく常にワークフロー 2 を提案します — モニターの提案をスキップしないでください

  • データ品質、鮮度、行数、または異常について尋ねた場合 → ワークフロー 1 を実行

  • データ品質アラートのトリアージまたは対応を希望した場合 → ワークフロー 3 を実行

結果は、エンジニアが作業を進める前に必要とするコンテキストとして提示してください — 質問への回答としてではありません。

このスキルをアクティブ化しないタイミング

Monte Carlo ツールを以下の目的で呼び出さないでください。

  • シードファイル(seeds/ ディレクトリ内のファイル)
  • 分析ファイル(analyses/ ディレクトリ内のファイル)
  • dbt プロジェクトの一部ではない、一時的またはアドホックな SQL スクリプト
  • 設定ファイル(dbt_project.yml、profiles.yml、packages.yml)
  • ユーザーがデータ品質について具体的に尋ねている場合を除くテストファイル

ファイルが dbt モデルであるかどうか不明な場合は、{{ ref() }} または {{ source() }} Jinja 参照を確認してください — 存在しない場合はアクティブ化しないでください。

マクロとスナップショット — 編集をゲートし、自動コンテキストをスキップ

マクロファイル(macros/)とスナップショットファイル(snapshots/)はモデルではありませんので、開かれたときに Monte Carlo コンテキスト(ワークフロー 1)を自動的にフェッチしないでください。ただし、マクロはコンパイル時にそれらを呼び出すすべてのモデルにインライン化されます — 1行のマクロ変更で数十のモデルがサイレントに変更される可能性があります。スナップショットは履歴追跡を制御し、同様にデリケートです。

編集前フックがこれらのファイルをゲートします。 フックがマクロまたはスナップショットに対して発火した場合、影響を受けるモデルを特定し、編集を進める前にそれらのモデルに対して変更影響評価(ワークフロー 4)を実行してください。


必須: SQL 編集前の変更影響評価

dbt モデルまたはパイプラインの SQL を編集または記述する前に、ワークフロー 4 を実行する必要があります。

これは、ユーザーがモデルの変更意図を表明するたびに適用されます — 以下のようなフレーズを含みます。

  • 「列を追加したいのですが…」
  • 「追加させてください / 追加しています…」
  • 「変更したい / 更新したい / 名前を変更したいのですが…」
  • 「追加 / 変更 / リファクタリングできますか…」
  • 「追加しましょう…」 / 「<column> 列を追加してください」
  • 計画されたスキーマまたはロジック変更のその他の説明
  • 「[レコード/顧客/行] を除外 / フィルターアウト / 削除する…」
  • 「[しきい値/パラメーター/値] を調整 / 増加 / 減少させる…」
  • 「[問題/バグ] を修正 / バグ修正 / パッチを適用する…」
  • 「[変更/以前の動作] を元に戻す / 復元 / 取り消す…」
  • 「[機能/ロジック/フラグ] を無効化 / 有効化する…」
  • 「[参照/列/コード] をクリーンアップ / 削除する…」
  • 「[バックエンド/機能] を実装する…」
  • 「[モデル/dbt モデル] を作成する…」(既存の参照テーブルを変更する場合)
  • 「[max_tokens/しきい値/日付定数/数値パラメーター] を増加 / 減少 / 変更する…」
  • SQL 内のハードコードされた値、定数、または設定パラメーターの変更
  • 「[列/フィールド/テーブル] をドロップ / 削除する」
  • 「[列/フィールド] の名前を [新しい名前] に変更する」
  • 「[列] を追加する」(短い命令形、例: 「created_at 列を追加する」)
  • 列、テーブル、またはモデルを対象とする単一動詞の命令形コマンド (例: 「X をドロップする」、「Y の名前を変更する」、「Z を追加する」、「W を削除する」)

パラメーターの変更(しきい値、日付定数、数値制限)は安全に見えますが、モデルの出力をサイレントに変更します。影響評価の目的では、ロジックの変更と同じように扱ってください。

変更影響評価(ワークフロー 4)がユーザーに提示されるまで、SQL を記述または編集しないでください。 評価は最初に提示される必要があります — 編集後ではなく、並行してでもありません。


編集前ゲート — ファイル変更前の確認

.sql または dbt モデルファイルに対して Edit、Write、または MultiEdit を呼び出す前に、以下を確認する必要があります。

  1. 現在のプロンプトで、この特定の変更に対して合成ステップが実行されましたか?
  2. はいの場合 → 編集に進みます
  3. いいえの場合 → 直ちに停止し、ワークフロー 4 を実行し、この特定の変更に接続された合成を含む完全なレポートを提示します。 リスクが「高」または「中」の場合: 「編集を進めてもよろしいですか?」と尋ね、明示的な確認を待ちます。 リスクが「低」の場合: 判断に任せます — 簡単で懸念がない場合は進めますが、そうでない場合は編集前に尋ねます。

重要: 「ワークフロー 4 はこのセッションで既に実行されました」だけでは、続行するのに十分ではありません。 各異なる変更プロンプトには、MC の発見事項をその特定の変更に接続する独自の合成ステップが必要です。

合成は、現在のプロンプトで変更されている特定の列、フィルター、またはロジックを参照する必要があります — 単なる一般的なテーブルの健全性ではありません。

例:

  • ✅ 「34 のダウンストリームモデルが is_paying_workspace に依存しているため、除外リストに 'MC Internal' を追加すると、これらのワークスペースはすべてのダウンストリームの健全性スコアとエクスポートから除外されます。確認しますか?」
  • ❌ 「ワークフロー 4 は既に実行されました。今から編集します。」

唯一の例外: ユーザーが明示的にリスクを認識し、スキップしたいと確認した場合(例: 「リスクは承知しています、変更してください」) — 進めますが、スキップされた評価を記録してください。

利用可能な MCP ツール

すべてのツールは monte-carlo MCP サーバー経由で利用できます。

| ツール | 目的 |

(原文がここで切り詰められています)

📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開

Monte Carlo Prevent Skill

This skill brings Monte Carlo's data observability context directly into your editor. When you're modifying a dbt model or SQL pipeline, use it to surface table health, lineage, active alerts, and to generate monitors-as-code without leaving Claude Code.

Reference files live next to this skill file. Use the Read tool (not MCP resources) to access them:

  • Full workflow step-by-step instructions: references/workflows.md (relative to this file)
  • MCP parameter details: references/parameters.md (relative to this file)
  • Troubleshooting: references/TROUBLESHOOTING.md (relative to this file)

When to activate this skill

Do not wait to be asked. Run the appropriate workflow automatically whenever the user:

  • References or opens a .sql file or dbt model (files in models/) → run Workflow 1

  • Mentions a table name, dataset, or dbt model name in passing → run Workflow 1

  • Describes a planned change to a model (new column, join update, filter change, refactor) → STOP — run Workflow 4 before writing any code

  • Adds a new column, metric, or output expression to an existing model → run Workflow 4 first, then ALWAYS offer Workflow 2 regardless of risk tier — do not skip the monitor offer

  • Asks about data quality, freshness, row counts, or anomalies → run Workflow 1

  • Wants to triage or respond to a data quality alert → run Workflow 3

Present the results as context the engineer needs before proceeding — not as a response to a question.

When NOT to activate this skill

Do not invoke Monte Carlo tools for:

  • Seed files (files in seeds/ directory)
  • Analysis files (files in analyses/ directory)
  • One-off or ad-hoc SQL scripts not part of a dbt project
  • Configuration files (dbt_project.yml, profiles.yml, packages.yml)
  • Test files unless the user is specifically asking about data quality

If uncertain whether a file is a dbt model, check for {{ ref() }} or {{ source() }} Jinja references — if absent, do not activate.

Macros and snapshots — gate edits, skip auto-context

Macro files (macros/) and snapshot files (snapshots/) are not models, so do not auto-fetch Monte Carlo context (Workflow 1) when they are opened. However, macros are inlined into every model that calls them at compile time — a one-line macro change can silently alter dozens of models. Snapshots control historical tracking and are similarly sensitive.

The pre-edit hook gates these files. If the hook fires for a macro or snapshot, identify which models are affected and run the change impact assessment (Workflow 4) for those models before proceeding with the edit.


REQUIRED: Change impact assessment before any SQL edit

Before editing or writing any SQL for a dbt model or pipeline, you MUST run Workflow 4.

This applies whenever the user expresses intent to modify a model — including phrases like:

  • "I want to add a column…"
  • "Let me add / I'm adding…"
  • "I'd like to change / update / rename…"
  • "Can you add / modify / refactor…"
  • "Let's add…" / "Add a <column> column"
  • Any other description of a planned schema or logic change
  • "Exclude / filter out / remove [records/customers/rows]…"
  • "Adjust / increase / decrease [threshold/parameter/value]…"
  • "Fix / bugfix / patch [issue/bug]…"
  • "Revert / restore / undo [change/previous behavior]…"
  • "Disable / enable [feature/logic/flag]…"
  • "Clean up / remove [references/columns/code]…"
  • "Implement [backend/feature] for…"
  • "Create [models/dbt models] for…" (when modifying existing referenced tables)
  • "Increase / decrease / change [max_tokens/threshold/date constant/numeric parameter]…"
  • Any change to a hardcoded value, constant, or configuration parameter within SQL
  • "Drop / remove / delete [column/field/table]"
  • "Rename [column/field] to [new name]"
  • "Add [column]" (short imperative form, e.g. "add a created_at column")
  • Any single-verb imperative command targeting a column, table, or model (e.g. "drop X", "rename Y", "add Z", "remove W")

Parameter changes (threshold values, date constants, numeric limits) appear safe but silently change model output. Treat them the same as logic changes for impact assessment purposes.

Do not write or edit any SQL until the change impact assessment (Workflow 4) has been presented to the user. The assessment must come first — not after the edit, not in parallel.


Pre-edit gate — check before modifying any file

Before calling Edit, Write, or MultiEdit on any .sql or dbt model file, you MUST check:

  1. Has the synthesis step been run for THIS SPECIFIC CHANGE in the current prompt?
  2. If YES → proceed with the edit
  3. If NO → stop immediately, run Workflow 4, present the full report with synthesis connected to this specific change. If risk is High or Medium: ask "Do you want me to proceed with the edit?" and wait for explicit confirmation. If risk is Low: use judgment — proceed if straightforward and no concerns found, otherwise ask before editing.

Important: "Workflow 4 already ran this session" is NOT sufficient to proceed. Each distinct change prompt requires its own synthesis step connecting the MC findings to that specific change.

The synthesis must reference the specific columns, filters, or logic being changed in the current prompt — not just general table health.

Example:

  • ✅ "Given 34 downstream models depend on is_paying_workspace, adding 'MC Internal' to the exclusion list will exclude these workspaces from all downstream health scores and exports. Confirm?"
  • ❌ "Workflow 4 already ran. Making the edit now."

The only exception: if the user explicitly acknowledges the risk and confirms they want to skip (e.g. "I know the risks, just make the change") — proceed but note the skipped assessment.

Available MCP tools

All tools are available via the monte-carlo MCP server.

Tool Purpose
testConnection Verify auth and connectivity
search Find tables/assets by name
getTable Schema, stats, metadata for a table
getAssetLineage Upstream/downstream dependencies (call with mcons array + direction)
getAlerts Active incidents and alerts
getMonitors Monitor configs — filter by table using mcons array
getQueriesForTable Recent query history
getQueryData Full SQL for a specific query
createValidationMonitorMac Generate validation monitors-as-code YAML
createMetricMonitorMac Generate metric monitors-as-code YAML
createComparisonMonitorMac Generate comparison monitors-as-code YAML
createCustomSqlMonitorMac Generate custom SQL monitors-as-code YAML
getValidationPredicates List available validation rule types
updateAlert Update alert status/severity
setAlertOwner Assign alert ownership
createOrUpdateAlertComment Add comments to alerts
getAudiences List notification audiences
getDomains List MC domains
getUser Current user info
getCurrentTime ISO timestamp for API calls

Core workflows

Each workflow has detailed step-by-step instructions in references/workflows.md (Read tool).

1. Table health check

When: User opens a dbt model or mentions a table. What: Surfaces health, lineage, alerts, and risk signals. Auto-escalates to Workflow 4 if change intent is detected and risk signals are present.

2. Add a monitor

When: New column, filter, or business rule is added to a model. What: Suggests and generates monitors-as-code YAML using the appropriate create*MonitorMac tool. Saves to monitors/<table_name>.yml.

3. Alert triage

When: User is investigating an active data quality incident. What: Lists open alerts, checks table state, traces lineage for root cause, reviews recent queries.

4. Change impact assessment — REQUIRED before modifying a model

When: Any intent to modify a dbt model's logic, columns, joins, or filters. What: Surfaces blast radius, downstream dependencies, active incidents, monitor coverage, and query exposure. Produces a risk-tiered report with synthesis connecting findings to specific code recommendations. See references/workflows.md for the full assessment sequence, report format, and synthesis rules.

5. Change validation queries

When: Explicit engineer request only (e.g. "validate this change", "ready to commit"). What: Generates 3-5 targeted SQL queries to verify the change behaved as intended. Uses Workflow 4 context — requires both impact assessment and file edit in session.


Post-synthesis confirmation rules

Always end the synthesis with one clear, specific recommendation in plain English: "Given the above, I recommend: [specific action]"

If the risk is High or Medium: STOP and wait for confirmation before editing any file. You must ask the engineer and receive an explicit "yes", "go ahead", "proceed", or similar confirmation before making code changes. Say: "Do you want me to proceed with the edit?" Do NOT say: "Proceeding with the edit." — that skips the engineer's decision.

If the risk is Low: Use your judgment based on the synthesis findings. If the change is straightforward and the synthesis found no concerns, you may proceed. If anything is surprising or worth flagging, ask before editing.


Session markers

These markers coordinate between the skill and the plugin's hooks. Output each on its own line when the condition is met.

Impact check complete

After the engineer confirms (High/Medium) or after presenting the synthesis (Low), output one marker per assessed table. IMPORTANT: use only the table/model name, not the full MCON:

<!-- MC_IMPACT_CHECK_COMPLETE: <table_name> -->

(Use the model filename without .sql extension — NOT "acme.analytics.orders" or "prod.public.client_hub")

How many markers to emit depends on how the assessment was triggered:

Hook-triggered (the pre-edit hook blocked an edit and instructed you to run the assessment): Be strict — only emit markers for tables whose lineage and monitor coverage were fetched directly via Monte Carlo tools in this session. If the engineer describes changes to multiple tables but only one was formally assessed, emit only one marker. The pre-edit hook will gate the other tables and prompt for their own Workflow 4 runs.

Voluntarily invoked (the engineer proactively asked for an impact assessment): Be looser — emit markers for all tables the assessment meaningfully covered, even if some were assessed via lineage context rather than direct MC tool calls. The engineer is already safety-conscious; don't force redundant assessments for tables they clearly considered.

Monitor coverage gap

When Workflow 4 finds zero custom monitors on a table's affected columns, output:

<!-- MC_MONITOR_GAP: <table_name> -->

Use only the table/model name (NOT the full MCON). This allows the plugin's hooks to remind the engineer about monitor coverage at commit time. Only output this marker when the gap is specifically about the columns or logic being changed — not for general table-level monitor absence.

Limitations

  • Use this skill only when the task clearly matches the scope described above.
  • Do not treat the output as a substitute for environment-specific validation, testing, or expert review.
  • Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.

同梱ファイル

※ ZIPに含まれるファイル一覧。`SKILL.md` 本体に加え、参考資料・サンプル・スクリプトが入っている場合があります。