Works with the AI Agents you already use

    Claude CodeClaude CodeCursorCursorCodex CLICodex CLIMuseMuseDotsDots+21 more

    sql query architect

    2

    Translates natural language business questions into optimized, schema-verified SQL for major data warehouses.

    $19.99

    Secure checkout via Stripe

    Money-back guarantee

    Converts to your local currency at checkout

    3 usesSecurity scanned
    sql query architect

    sql query architect

    Example session with this skill installed

    Write a Snowflake query for monthly logo churn in 2024. Use the subscriptions table. I need to see the SQL and an explanation of the logic.

    • Read your context and instructions
    • Compiled the sql query architect

    I will generate a Snowflake-optimized query for monthly logo churn.

    Assumptions & Logic:
    *

    Logo Churn: Defined as the count of unique customers whose subscription ended (end_date) within a given month.

    • Timeframe: Limited to the calendar year 2024.

    Schema: Based on the subscriptions table. I am assuming columns customer_id, start_date, and end_date exist based on standard patterns.

    Monthly Logo Churn Query (Snowflake)

    WITH monthly_spine AS (
      -- Generate a spine of months for 2024 to ensure we see months with zero churn
      SELECT 
        DATE_TRUNC('MONTH', DATEADD('MONTH', SEQ4(), '2024-01-01')) AS report_month
      FROM TABLE(GENERATOR(ROWCOUNT => 12))
    ),
    churned_customers AS (
      SELECT 
        DATE_TRUNC('MONTH', end_date) AS churn_month,
        COUNT(DISTINCT customer_id) AS churned_count
      FROM subscriptions
      WHERE end_date >= '2024-01-01' 
        AND end_date <= '2024-12-31'
      GROUP BY 1
    )
    SELECT 
      s.report_month,
      COALESCE(c.churned_count, 0) AS logo_churn
    FROM monthly_spine s
    LEFT JOIN churned_customers c ON s.report_month = c.churn_month
    ORDER BY 1 ASC;
    

    Explanation:
    1.

    monthly_spine: Creates a list of all 12 months in 2024. This ensures that if a month has zero churn, it still appears in your report.
    2.

    churned_customers: Filters the subscriptions table for rows where the end_date falls in 2024, then groups them by month to count unique customers.
    3.

    Final Join: Combines the month list with the churn counts. I used a LEFT JOIN and COALESCE to turn missing data into a 0 for cleaner reporting.

    Next steps

    • Verify if end_date is the correct column for churn (vs. a status column).
    • Run this in your Snowflake worksheet to confirm results.
    • Provide your DDL if you want me to adjust for specific column names like sub_id or termination_dt.

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

    About this skill

    The problem

    Translating business questions into SQL often leads to broken queries due to guessed column names or misunderstood metric definitions like "churn" and "active user." Non-technical stakeholders struggle to verify if the logic matches their intent, while developers waste time fixing syntax for specific warehouse dialects.

    What it does

    • Introspects real database schemas to ensure table and column names are 100% accurate before writing a single line of code.
    • Resolves business ambiguity by defining metrics (e.g., logo vs. revenue churn) and time grains before generating SQL.
    • Generates optimized, read-only SQL queries using CTEs, defensive aggregation, and dialect-specific functions for Snowflake, BigQuery, Postgres, and more.
    • Explains technical query logic in plain English for non-technical stakeholders to review and approve.
    • Optionally executes queries against connected warehouses to return cited, verifiable results.

    Frameworks & tools

    Supports Snowflake, BigQuery, Databricks, PostgreSQL, MySQL, and standard ANSI SQL. Integrates with database connectors and semantic layers for schema discovery.

    Why this beats prompting it yourself

    Generic LLMs often hallucinate schema details or use incorrect date functions for your specific warehouse. This skill enforces a "schema-first" workflow, running discovery queries on string values and using defensive math like NULLIF to prevent runtime errors that manual prompts frequently overlook.

    Use cases

    • Generating complex MRR movement and cohort retention queries for finance teams.
    • Building funnel conversion reports from raw event logs without manual schema mapping.
    • Converting legacy SQL queries from one dialect to another, such as Postgres to BigQuery.
    • Providing a self-service data interface for PMs that outputs both the answer and the verifiable code.

    Known limitations

    Strictly read-only; will not perform DDL, DML, or data migrations. Requires an active connector or provided DDL to function without hallucinations.

    Read-only only. No DDL/DML/DCL operations. Requires either a live database connection or a manually provided schema (DDL) to avoid hallucinating table/column names.

    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

    3 uses

    Times used to date

    Money-back guarantee

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

    Trust & safety

    Security scan

    Security scan passed 2 months ago

    Permissions

    No special permissions declared or detected

    Listed2 months ago

    What's inside

    Frequently Asked Questions

    The architect performs real-time schema introspection to verify table and column names, using defensive SQL techniques like CTEs and NULLIF to prevent the common runtime errors and hallucinations typical of generic LLM prompts.

    This skill is fully compatible with Snowflake, BigQuery, Databricks, PostgreSQL, and MySQL, and it can even translate complex queries between these different dialects.

    No, this skill is strictly read-only; it is architected to generate and execute SELECT statements for data analysis while being intentionally blocked from performing DDL or DML actions like dropping tables or deleting data.

    Setup is straightforward: you provide either a direct database connector or a DDL schema export, allowing the agent to map your specific data environment before it begins generating queries.

    When you purchase this skill, you receive the full agent configuration optimized for schema-first SQL generation, pre-built logic for common business metrics like churn and MRR, and lifetime access to version updates.

    New in Data & Databases