spendguard

    1

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

    Free

    1 useSecurity scanned

    Works with the AI Agents you already use

    Claude CodeClaude CodeCursorCursorCodex CLICodex CLIMuseMuseDotsDots+21 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.

    Snowflake and Databricks use heuristic estimates rather than precise dry-runs. Reconciliation requires query completion to update the local ledger.

    How to use

    1. 1

      Connect your agent to the Agensi MCP

      Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup

    2. 2

      Sign in to Agensi

      Your agent shows a sign-in link. Sign in and click Allow.

    3. 3

      Ask for what you need

      Your agent loads this skill and uses it on your task. It always asks before any payment.

    Reviews

    No reviews yet

    Be one of the first to try it. Every listed skill goes through the trust checks below.

    Security scanned

    Checked by our 8-point scan before listing

    1 use

    Times used to date

    Free forever

    No account required to browse

    Trust & safety

    Security scan

    Security scan passed 1 month ago

    • Free with an Agensi account

    Requires

    Spendguard MCP
    uv (Python tool runner)

    Permissions

    Terminal / Shell
    Listed1 month ago

    What's inside

    Frequently Asked Questions

    spendguard acts as a financial firewall between your AI agents and your data warehouse, preventing runaway costs by estimating query prices and blocking executions that exceed your set USD budget before they hit the warehouse.

    The skill is delivered as an MCP server, making it natively compatible with popular AI development tools including Claude Code, Cursor, and GitHub Copilot.

    While it provides precise dry-run costs for BigQuery, it uses sophisticated upper-bound heuristics for Snowflake and Databricks to ensure your agents never exceed safe spending limits.

    Setup is streamlined via `uvx spendguard-mcp`; you simply need to provide your warehouse credentials and set your desired USD limits to begin governing your agent's SQL execution.

    Unlike static system prompts, spendguard uses real-time warehouse metadata and billing APIs to provide factual cost data, eliminating the "hallucinated" estimates common with LLMs.

    If a query is blocked for being too expensive, the `suggest_cheaper_query` function analyzes the SQL to inject limits, prune columns, or add filters to bring the cost within your budget.

    New in Data & Databases