Skip to content

monte-carlo-data/mc-agent-toolkit / skills/prevent

monte-carlo-prevent

Verified

Shift-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.

scripts/sandbox/tests/test_detect_hardcoded_db.py

View on GitHub
"""Tests for detect_hardcoded_db.py."""
import json
import subprocess
import sys
from pathlib import Path


SCRIPT = Path(__file__).resolve().parents[1] / "detect_hardcoded_db.py"


def _run(path: Path) -> dict:
    out = subprocess.run(
        [sys.executable, str(SCRIPT), str(path)],
        capture_output=True, text=True, check=True,
    )
    return json.loads(out.stdout)


def test_no_hardcoded_db(tmp_path):
    f = tmp_path / "m.sql"
    f.write_text("{{ config(materialized='table', schema='prod') }}\nSELECT 1\n")
    assert _run(f) == {"database": None}


def test_hardcoded_db_single_quotes(tmp_path):
    f = tmp_path / "m.sql"
    f.write_text("{{ config(materialized='table', database='MONTECARLODATA_SHARED', schema='exports') }}\nSELECT 1\n")
    assert _run(f) == {"database": "MONTECARLODATA_SHARED"}


def test_hardcoded_db_double_quotes(tmp_path):
    f = tmp_path / "m.sql"
    f.write_text('{{ config(database="shared") }}\n')
    assert _run(f) == {"database": "shared"}


def test_no_config_block(tmp_path):
    f = tmp_path / "m.sql"
    f.write_text("SELECT 1\n")
    assert _run(f) == {"database": None}


def test_config_spread_across_lines(tmp_path):
    f = tmp_path / "m.sql"
    f.write_text(
        "{{ config(\n"
        "    materialized='incremental',\n"
        "    database='EXPORTS_DB',\n"
        "    unique_key='id'\n"
        ") }}\n"
        "SELECT 1\n"
    )
    assert _run(f) == {"database": "EXPORTS_DB"}


def test_missing_file(tmp_path):
    result = subprocess.run(
        [sys.executable, str(SCRIPT), str(tmp_path / "nope.sql")],
        capture_output=True, text=True,
    )
    assert result.returncode == 1
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: 119kUpdated Claude CodeCodexVerifiedInstall
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: 119kUpdated Claude CodeCodexVerifiedInstall
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: 118kUpdated Claude CodeCodexVerifiedInstall
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: 118kUpdated Claude CodeCodexVerifiedInstall