NL2SQL Finance Analytics & Read-Only Data Auditor

    1

    Across 80 test queries with multi-table joins, CTEs, and window functions, this self-correcting setup hit **92.5% execution accuracy** without allowing a single write operation.

    $9

    Secure checkout via Stripe

    Money-back guarantee

    Converts to your local currency at checkout

    Security scanned

    Works with the AI Agents you already use

    Claude CodeClaude CodeCursorCursorCodex CLICodex CLIDeepSeekDeepSeekMuseMuse+22 more

    NL2SQL Finance Analytics & Read-Only Data Auditor

    Example session with this skill installed

    Audit our ledger_charges and invoices tables in billing.db. Find any customers who were charged more than once for the same invoice where the charge succeeded, and show the total duplicate dollar impact.

    • Read your context and instructions
    • Compiled the nl2sql finance analytics
    1. Schema Check: Queries sqlite_master on billing.db and confirms ledger_charges(charge_id, customer_id, invoice_id, amount_cents, status, created_at) stores amounts in integer cents.
    2. Draft & SQLGlot AST Check: Runs python3 scripts/sqlglot_guardrail.py --dialect sqlite --max-limit 500 on the CTE query using COUNT(*) OVER and ROW_NUMBER() OVER partitioned by (customer_id, invoice_id, amount_cents). Output: {"valid": true, "dialect": "sqlite", "message": "Passed SQLGlot read-only AST check."}
    3. Verified Output: Identified 3 duplicate succeeded charges across 2 enterprise invoices (INV-9041, INV-8812), totaling $1,450.00 USD in overbilled revenue requiring refund credit notes, while blocking any DELETE statements.

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

    About this skill

    I built this skill out of my open-source project nl2sql-analytics-agent after dealing with two recurring headaches when letting coding agents query financial tables: hallucinated column names on multi-table joins, and brittle regex filters that miss destructive SQL inside subqueries or CTEs.

    This package gives your agent (Claude Code, Cursor, Codex, Gemini CLI) a reliable workflow to turn plain-English finance, billing, and revenue questions into verified SQL over PostgreSQL and SQLite. Across 80 test queries with multi-table joins, CTEs, and window functions, this self-correcting setup hit 92.5% execution accuracy without allowing a single write operation.

    How It Works

    1. Checks the Live Schema First: Before writing any SQL, the agent queries sqlite_master or information_schema.columns and samples 3 rows so it knows whether money is stored in cents or whole dollars, how dates are formatted, and what status values actually exist.
    2. Writes Clean Analytical SQL: Builds readable CTEs and window functions (LAG, LEAD, ROW_NUMBER() OVER) for MRR waterfalls, cohort retention, duplicate charge checks, and invoice-to-ledger reconciliation.
    3. Validates the AST with SQLGlot (scripts/sqlglot_guardrail.py):
      • Parses every query into an Abstract Syntax Tree using sqlglot before execution.
      • Blocks stacked queries and any statement containing DROP, DELETE, UPDATE, INSERT, ALTER, CREATE, TRUNCATE, GRANT, REVOKE, or PRAGMA.
      • Enforces a default LIMIT 500 on top-level SELECT queries so accidental full-table scans do not lock your database.
    4. Fixes Its Own Schema Errors (scripts/self_correcting_runner.py):
      • Opens SQLite files in strict read-only URI mode (?mode=ro).
      • If a query fails with an OperationalError (like a wrong column name or dialect function mismatch), it feeds the traceback and table DDL back to the agent to fix and re-validate the query (up to 3 retries).

    What Is Included in the ZIP

    • SKILL.md: Step-by-step instructions and guardrails for your agent.
    • scripts/sqlglot_guardrail.py: Standalone Python CLI validator for read-only AST checking and LIMIT enforcement across sqlite, postgres, duckdb, mysql, snowflake, and bigquery.
    • scripts/self_correcting_runner.py: Read-only SQLite runner that returns structured schema DDL hints when a query fails.
    • references/finance-sql-patterns.md: Ready-to-use SQL patterns for duplicate charge audits, monthly MRR waterfall (New, Expansion, Contraction), and invoice-to-ledger variance checks.
    • references/setup-and-compatibility.md: Quick local setup notes and link to the full nl2sql-analytics-agent repo.

    Limitations

    • Read-Only by Design: This skill only runs SELECT queries. It will refuse to write or run INSERT, UPDATE, DELETE, or schema migrations.
    • Local Python Dependency: Requires Python 3.10+ with sqlglot and pydantic installed locally (pip install sqlglot pydantic) plus access to your SQLite file or PostgreSQL read replica.

    Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse Claude Skills for Data & Databases.

    Strictly read-only SELECT execution (blocks INSERT, UPDATE, DELETE, DROP, ALTER). Requires local Python 3.10+ with sqlglot and pydantic installed.

    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 buying a skill.

    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

    Fresh listing

    Recently published to Agensi

    Money-back guarantee

    Doesn't do what its page promises? You get your money back.

    Trust & safety

    Security scan

    Security scan passed 5 days ago

    Software
    Python 3.10+sqlglot =23.0.0pydantic =2.0.0Git

    Permissions

    Terminal / Shell
    Read Files
    Network Access
    Listed5 days ago

    What's inside

    Frequently Asked Questions

    Never. Every query is parsed into an Abstract Syntax Tree by scripts/sqlglot_guardrail.py using SQLGlot, which blocks DROP, DELETE, UPDATE, INSERT, ALTER, TRUNCATE, and multi-statement queries before execution, and opens SQLite files in ?mode=ro read-only mode.

    The workflow and SQLGlot guardrail support sqlite and postgres out of the box, and the AST validator also accepts duckdb, mysql, snowflake, and bigquery.

    New in Data & Databases