spendguard

    1

    Cost estimation and budget governance for AI agents using BigQuery, Snowflake, and Databricks.

    Free

    Security scanned

    Works with the AI Agents you already use

    Claude CodeClaude CodeCursorCursorCodex CLICodex CLIMuseMuseDotsDots+22 more

    spendguard

    Example session with this skill installed

    Estimate the cost of running 'SELECT user_id, event_type FROM analytics.global_events WHERE date = CURRENT_DATE()' on BigQuery and run it if it is under $0.50.

    • Read your context and instructions
    • Compiled the spendguard

    I have estimated the cost for your BigQuery query. The estimate is within your specified $0.50 limit, so I proceeded with the execution. The actual cost has been recorded in the ledger.

    Query Governance Report

    MetricValue
    Warehouse EngineBigQuery
    Accuracy TierPRECISE
    Estimated Cost$0.0125 USD
    Execution StatusSuccess
    Actual Billed Cost$0.0122 USD
    Budget Remaining$0.4878 USD (for this call)

    Reconciled Execution Details

    -- Executed Query
    SELECT user_id, event_type 
    FROM analytics.global_events 
    WHERE date = CURRENT_DATE()
    

    Next steps

    • Run spend_report() to see your cumulative spend across all BigQuery tasks.
    • If you plan to run this frequently, I can suggest a partitioned schema rewrite to further reduce the cost.
    • Set a global daily cap in your config to prevent multiple small queries from stacking up.

    Connects securely to your tools. The creator never sees your data.

    About this skill

    Uncontrolled AI agents with SQL access can quickly drain cloud budgets by executing inefficient queries on massive datasets. spendguard acts as a governance layer between your agent and your data warehouse, preventing accidental overspend before it happens. It provides precise cost estimation for BigQuery and heuristic bounds for Snowflake and Databricks, ensuring agents stay within defined financial guardrails.

    What it does

    • Pre-flight estimation provides a dollar-cost preview of SQL queries without executing them.
    • Budget enforcement blocks query execution automatically if the estimated cost exceeds a per-call USD cap.
    • Cost reconciliation tracks actual billed costs in a local ledger to maintain a verifiable source of truth.
    • Query optimization generates cheaper SQL alternatives by injecting limits, pruning columns, and applying partition filters.
    • Spend reporting analyzes total engine spend and evaluates the accuracy of previous estimations.

    How it works

    1. Estimate calls estimate_query_cost to check the price and accuracy tier of a specific SQL statement.
    2. Gate executes queries via run_query_bounded to enforce strict USD limits before the warehouse is hit.
    3. Rewrite uses suggest_cheaper_query to fix queries that were blocked for being too expensive.
    4. Report pulls the spend_report to audit usage and calibrate future spending expectations.

    Frameworks & tools

    This skill is delivered as an MCP server compatible with Claude Code, Cursor, and GitHub Copilot. It supports Google BigQuery, Snowflake, and Databricks via uvx spendguard-mcp.

    Why this beats prompting it yourself

    LLMs cannot natively calculate cloud billing rates or scan table metadata to predict costs accurately. This skill uses the warehouse's own dry-run APIs and metadata to provide hard numbers that a system prompt alone would simply hallucinate.

    Use cases

    • Prevent agents from running SELECT * on multi-terabyte BigQuery tables.
    • Enforce daily or per-query spend limits for automated analytics agents.
    • Audit agent-driven warehouse spend across multi-cloud environments.
    • Automatically optimize expensive SQL generated by non-technical agents.

    Known limitations

    Estimates for Snowflake and Databricks use upper-bound heuristics rather than the precise dry-runs available in BigQuery. Actual billed costs are only available after query completion.

    How to use

    Skills on Agensi run inside your AI agent. Copy the prompt, paste it into your agent, and it connects to Agensi and installs this skill for you. If a payment is needed, your agent shows it to you first.

    Reviews

    No reviews yet

    Be one of the first to try it. Every listed skill passes our trust checks below.

    Security scanned

    Passed our 8-point scan before listing

    Fresh listing

    Recently published to Agensi

    Free forever

    No account required to browse

    Trust & safety

    Security scanned

    Verified clean 7 days ago

    • Free to download with an account

    Requires

    Spendguard MCP
    uv (Python tool runner)

    Listed7 days ago

    What's inside

    Frequently Asked Questions