monte-carlo-data/mc-agent-toolkit / skills/prevent
monte-carlo-prevent
VerifiedShift-left safety net for dbt/SQL model edits. Runs change impact assessment before edits, generates SQL validation queries after, and executes them via `/mc-validate run`. Delegates health and monitor creation to peer skills.
| File | Kind | Size |
|---|---|---|
| README.md | markdown | 8.3 KB |
| SKILL.md | skill md | 19.0 KB |
| references/TROUBLESHOOTING.md | markdown | 1.5 KB |
| references/parameters.md | markdown | 1.0 KB |
| references/workflows.md | markdown | 36.6 KB |
| scripts/sandbox/classify_sandbox.py | script | 1.5 KB |
| scripts/sandbox/detect_hardcoded_db.py | script | 1.2 KB |
| scripts/sandbox/parse_profiles.py | script | 3.3 KB |
| scripts/sandbox/readonly_check.py | script | 2.3 KB |
| scripts/sandbox/substitute_placeholders.py | script | 3.7 KB |
| scripts/sandbox/tests/conftest.py | script | 256 B |
| scripts/sandbox/tests/test_classify_sandbox.py | script | 1.1 KB |
| scripts/sandbox/tests/test_detect_hardcoded_db.py | script | 1.6 KB |
| scripts/sandbox/tests/test_integration_smoke.py | script | 2.8 KB |
| scripts/sandbox/tests/test_parse_profiles.py | script | 3.1 KB |
| scripts/sandbox/tests/test_readonly_check.py | script | 3.9 KB |
| scripts/sandbox/tests/test_substitute_placeholders.py | script | 3.7 KB |
scripts/sandbox/tests/test_readonly_check.py
View on GitHub"""Tests for readonly_check.py."""
import json
import subprocess
import sys
from pathlib import Path
SCRIPT = Path(__file__).resolve().parents[1] / "readonly_check.py"
def _run(path: Path) -> tuple[int, dict]:
out = subprocess.run(
[sys.executable, str(SCRIPT), str(path)],
capture_output=True, text=True,
)
return out.returncode, json.loads(out.stdout or "{}")
OK_SINGLE_SELECT = "SELECT 1\n"
OK_WITH_CTE = "WITH a AS (SELECT 1) SELECT * FROM a;\n"
OK_SHOW = "SHOW TABLES IN SCHEMA prod;\n"
OK_COMMENT_THEN_SELECT = "-- comment\n/* block */\nSELECT 1;\n"
BAD_INSERT = "INSERT INTO t VALUES (1);\n"
BAD_UPDATE = "-- lead comment\nUPDATE t SET x = 1;\n"
BAD_MERGE = "merge into t using s on s.id = t.id when matched then update set x = 1;"
BAD_CREATE = "CREATE TABLE x (id INT);\n"
BAD_DROP = "DROP TABLE x;\n"
BAD_CALL = "CALL sp_do_thing();\n"
BAD_USE = "USE DATABASE raw;\nSELECT 1;\n"
OK_MULTI_SELECT = "SELECT 1;\nSELECT 2;\nSELECT 3;\n"
MIXED_WRITE_IN_MULTI = "SELECT 1;\nDROP TABLE x;\nSELECT 2;\n"
def test_ok_select(tmp_path):
f = tmp_path / "q.sql"
f.write_text(OK_SINGLE_SELECT)
code, data = _run(f)
assert code == 0
assert data == {"ok": True, "rejected": None}
def test_ok_with_cte(tmp_path):
f = tmp_path / "q.sql"
f.write_text(OK_WITH_CTE)
assert _run(f) == (0, {"ok": True, "rejected": None})
def test_ok_show(tmp_path):
f = tmp_path / "q.sql"
f.write_text(OK_SHOW)
assert _run(f) == (0, {"ok": True, "rejected": None})
def test_ok_comment_then_select(tmp_path):
f = tmp_path / "q.sql"
f.write_text(OK_COMMENT_THEN_SELECT)
assert _run(f) == (0, {"ok": True, "rejected": None})
def test_rejects_insert(tmp_path):
f = tmp_path / "q.sql"
f.write_text(BAD_INSERT)
code, data = _run(f)
assert code == 1
assert data["ok"] is False
assert data["rejected"] == "INSERT"
def test_rejects_update(tmp_path):
f = tmp_path / "q.sql"
f.write_text(BAD_UPDATE)
assert _run(f)[1]["rejected"] == "UPDATE"
def test_rejects_merge_lowercase(tmp_path):
f = tmp_path / "q.sql"
f.write_text(BAD_MERGE)
assert _run(f)[1]["rejected"] == "MERGE"
def test_rejects_create(tmp_path):
f = tmp_path / "q.sql"
f.write_text(BAD_CREATE)
assert _run(f)[1]["rejected"] == "CREATE"
def test_rejects_drop(tmp_path):
f = tmp_path / "q.sql"
f.write_text(BAD_DROP)
assert _run(f)[1]["rejected"] == "DROP"
def test_rejects_call(tmp_path):
f = tmp_path / "q.sql"
f.write_text(BAD_CALL)
assert _run(f)[1]["rejected"] == "CALL"
def test_rejects_use(tmp_path):
f = tmp_path / "q.sql"
f.write_text(BAD_USE)
assert _run(f)[1]["rejected"] == "USE"
def test_accepts_multi_select(tmp_path):
"""Multiple SELECT statements in one file are fine — Workflow 4.2 output shape."""
f = tmp_path / "q.sql"
f.write_text(OK_MULTI_SELECT)
code, data = _run(f)
assert code == 0
assert data == {"ok": True, "rejected": None}
def test_rejects_write_among_multi_statement(tmp_path):
"""A write statement anywhere in the file still gets rejected, even if
other statements are pure reads."""
f = tmp_path / "q.sql"
f.write_text(MIXED_WRITE_IN_MULTI)
code, data = _run(f)
assert code == 1
assert data["rejected"] == "DROP"
def test_rejects_get_stage(tmp_path):
f = tmp_path / "q.sql"
f.write_text("GET @stage FILE 'out.csv';\n")
assert _run(f)[1]["rejected"] == "GET"
def test_rejects_put(tmp_path):
f = tmp_path / "q.sql"
f.write_text("PUT file:///tmp/x.csv @stage;\n")
assert _run(f)[1]["rejected"] == "PUT"
def test_rejects_unload(tmp_path):
f = tmp_path / "q.sql"
f.write_text("UNLOAD ('SELECT 1') TO '@stage';\n")
assert _run(f)[1]["rejected"] == "UNLOAD"
def test_rejects_set_session_var(tmp_path):
f = tmp_path / "q.sql"
f.write_text("SET v = 1;\nSELECT 1;\n")
assert _run(f)[1]["rejected"] == "SET"
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| deprecation-and-migrationaddyosmani/agent-skillsManages deprecation and migration. Use when removing old systems, APIs, or features. Use when migrating users from one implementation to another. Use when migrating a database schema in production, such as renaming or dropping a column without downtime (expand/contract). Use when deciding whether to maintain or sunset existing code. | Stars: 119k | Updated | Claude CodeCodex | Verified | Install |
| performance-optimizationaddyosmani/agent-skillsOptimizes application performance across frontend, backend, queries, and databases. Use when performance requirements exist, when you suspect performance regressions, when Core Web Vitals or load times need improvement, when N+1 query patterns need fixing, or when profiling reveals bottlenecks. | Stars: 119k | Updated | Claude CodeCodex | Verified | Install |
| agent-cost-reportthedotmack/claude-memBelievable agent cost report for any period, default the last 7 full days PT, not counting today. Measured tokens from Claude Code transcripts priced at OpenRouter list prices (ESTIMATED), measured provider spend when a sanctioned source exists, note-taker cost separate, Timing-style HTML/PDF plus report.json, line-items.csv, evidence.json. | Stars: 118k | Updated | Claude CodeCodex | Verified | Install |
| agent-cost-reportthedotmack/claude-memBelievable agent cost report for any period, default the last 7 full days PT, not counting today. Measured tokens from Claude Code transcripts priced at OpenRouter list prices (ESTIMATED), measured provider spend when a sanctioned source exists, note-taker cost separate, Timing-style HTML/PDF plus report.json, line-items.csv, evidence.json. | Stars: 118k | Updated | Claude CodeCodex | Verified | Install |