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/detect_hardcoded_db.py

View on GitHub
#!/usr/bin/env python3
"""
Detect a hard-coded `database='...'` kwarg inside a dbt model's `{{ config(...) }}` block.

Usage:
    python3 detect_hardcoded_db.py <model.sql>

Prints JSON: {"database": "<value>"} or {"database": null}
Exits 1 if the file is missing.
"""

import argparse
import json
import re
import sys
from pathlib import Path


_CONFIG_RE = re.compile(r"\{\{\s*config\s*\((.*?)\)\s*\}\}", re.DOTALL)
_DB_KWARG_RE = re.compile(r"""\bdatabase\s*=\s*(['"])([^'"]+)\1""")


def detect(content: str) -> str | None:
    for config_match in _CONFIG_RE.finditer(content):
        kwargs = config_match.group(1)
        db_match = _DB_KWARG_RE.search(kwargs)
        if db_match:
            return db_match.group(2)
    return None


def main() -> int:
    p = argparse.ArgumentParser(
        description="Detect a hard-coded database='...' in a dbt model's config() block."
    )
    p.add_argument("path", type=Path, help="Path to the dbt model .sql file")
    args = p.parse_args()
    if not args.path.exists():
        print(f"error: file not found: {args.path}", file=sys.stderr)
        return 1
    result = detect(args.path.read_text())
    print(json.dumps({"database": result}))
    return 0


if __name__ == "__main__":
    sys.exit(main())
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