Production AI Firewall & Diagnostic Doctor·PostgreSQL 14 - 17

The AI Firewall for Production PostgreSQL.

Safely query, diagnose, and optimize your database with AI. QueryCraft intercepts expensive sequential scans, auto-heals SQLSTATE errors, and grounds LLMs strictly in your live schema.

$npm install -g querycraft && querycraft auth login
querycraft check — postgres://rds.production.internal:5432
$querycraft check "SELECT * FROM orders o JOIN line_items l ON TRUE WHERE l.status = 'pending';"
Dry-running EXPLAIN (FORMAT JSON, COSTS TRUE) on PostgreSQL 16.2 RDS...
[HIGH RISK] Compute Cost: 14,289.40 (Budget: < 300.0)Execution Blocked By Firewall

🚨 Unconstrained Cartesian Join: Table line_items joined without foreign key predicate (1.2M rows × 450k orders).

⚠️ Sequential Scan: Filter on unindexed column line_items.status.

Targeted Index Suggestion & Healed Remediation

// 1. Recommended Index DDL:

CREATE INDEX CONCURRENTLY IF NOT EXISTS idx_line_items_status ON line_items(status);

// 2. Auto-Healed Query (Remediated Cost: 2.42 · -99.98%):

SELECT * FROM orders o JOIN line_items l ON o.id = l.order_id WHERE l.status = 'pending' LIMIT 50;

Status: Healed · [LOW RISK] · SET TRANSACTION READ ONLY Safe
Engineered For Cloud PostgreSQL Environments
Supabase Neon Serverless AWS RDS PostgreSQL CockroachDB Heroku Postgres
4-Stage Production Safety Rail

How QueryCraft Protects Your Production Database

Every query is schema-grounded, ambiguity-checked, pre-flight cost analyzed, and self-healed before execution.

01 / 04 Pipeline Guard

Stage 01: Live Schema Grounding

QueryCraft introspects your database's live tables, column types (UUID, JSONB, NUMERIC), and PK/FK foreign key graphs. Prompts are grounded strictly on verified catalog entities so the model never guesses or invents tables.

Rejects non-existent columns
Resolves exact FK JOIN paths
Zero schema hallucinations
pipeline_telemetry.sql
READ-ONLY SANDBOX
Input Natural Language:

"calculate total revenue by customer country"

Grounded Live Information Schema DDL:
customers (id, name, country)
orders (id, customer_id, total, status)
Verified 2 / 24 tables · Foreign Keys linked
PostgreSQL Engine SafeZero Mutations Permitted
The AI Database Reliability Gap

Why Generic AI Fails on Production Databases

Generic AI coding assistants guess schemas, write unconstrained queries that trigger massive cloud compute spikes, and fail silently on PostgreSQL syntax errors.

The Problem: Generic AI Assistants

Blind Guessing & Runaway Infrastructure Spikes

LLMs without database guardrails hallucinate nonexistent tables, execute unconstrained joins that lock multi-million row production databases, and risk accidental data mutation.

  • ✕
    Schema & Typo Hallucinations: Invents column names (cust_id vs customer_id) triggering SQLSTATE 42703.
  • ✕
    Runaway Cloud Bills: Triggers full sequential scans and memory-intensive cross-joins across multi-million row tables.
  • ✕
    Silent Cryptic Errors: Fails on missing GROUP BY clauses (42803) and incorrect type castings (22P02).
  • ✕
    Accidental Mutations: Can inadvertently emit mutating DML/DDL (DELETE, DROP, UPDATE).
Unbounded execution on live customer databases
The Solution: QueryCraft Defensive Proxy

Pre-Flight Safety, EXPLAIN Guard & Self-Healing

QueryCraft acts as a defensive proxy. It enforces SET TRANSACTION READ ONLY, dry-runs EXPLAIN costs, and auto-corrects errors before execution.

  • ✓
    Zero-Hallucination Grounding: Introspects live PostgreSQL tables, UUIDs, JSONB, and foreign keys directly into the prompt.
  • ✓
    Pre-Flight Cost Guard: Dry-runs AST plans with a 3-tier risk engine ([LOW], [MED], [HIGH]).
  • ✓
    SQL Doctor Critic Loop: Automatically catches and heals syntax and grouping errors with up to 3 self-healing retries.
  • ✓
    Strict Read-Only & LIMIT 50: Enforces 8000ms statement timeouts and guaranteed mutation prevention.
Production-safe AI database proxy with live EXPLAIN guard
The 5 Core Pillars

Architected for Zero Hallucinations & Infrastructure Safety

Five tightly coupled subsystems engineered to make AI queries as predictable and safe as a compiled binary.

Pillar 01 · AI Firewall
LOW <60MED <300HIGH >300

Pre-Flight Cost Guard

Never spike your AWS RDS bill again. QueryCraft dry-runs EXPLAIN (FORMAT JSON), estimates compute costs, and blocks runaway sequential scans with a 3-Tier Risk Engine (LOW/MED/HIGH).

Baseline Scan vs Optimized Remediated Plan-99.8% Cost Reduction
Unindexed Query

Cost: 14,289.4

[HIGH RISK · Seq Scan]
QueryCraft Healed

Cost: 2.42

[LOW RISK · Index Scan]
Pillar 02 · Critic Agent

SQL Doctor (Critic Loop)

Stop debugging cryptic errors. The SQL Doctor catches 42703 (missing columns) and 22P02 (type errors), diagnosing and self-healing the query up to 3 times automatically.

SQLSTATE 42703 CaughtSelf-Healing 1/3
SELECT cust_name, email FROM users
SELECT customer_name, email FROM users
Pillar 03 · stdio JSON-RPC

Universal MCP Server

Bring QueryCraft to your IDE. Exposes 6 native tools to Cursor and Claude Desktop over stdio so your agent can safely query your database without leaving the editor.

Available MCP Tools:
evaluate_and_heal_sqlinspect_schemagenerate_safe_sql
Pillar 04 · Live DDL Introspection

Zero-Hallucination Schema Grounding

Stop the guessing game. QueryCraft introspects your live PostgreSQL schema—tables, UUIDs, JSONB, and Foreign Keys—to ensure the AI only writes valid SQL.

ordersUUID PK

├─ customer_id (UUID, FK -> customers.id)

├─ metadata (JSONB)

└─ created_at (TIMESTAMPTZ)

Pillar 05 · Conversational Loop

Interactive Clarification

No more blind assumptions. If a query is ambiguous, QueryCraft pauses and asks targeted questions using 1-tap interactive response chips.

Paused for Filter Context:
Developer Workflow

How QueryCraft Protects Your Production Database

From natural language query to safe, read-only results in under 500 milliseconds.

01

Connect Your Database

Securely link your Supabase, Neon, or RDS instance. (Credentials are stateless and never saved).

Stateless In-Memory Session
02

Ask or Let Your IDE Write

Type a natural language prompt in the Web Studio or use Cursor via the MCP server.

Web Studio or MCP stdio
03

The Firewall Inspects

QueryCraft maps the schema, checks the EXPLAIN cost, and flags missing indexes.

3-Tier Compute Risk Analysis
04

Execute Safely

The query runs under an 8000ms timeout limit with a strict LIMIT 50 clamp, returning clean Markdown or a CSV export.

Read-Only & CSV Ready

Start querying safely today.

Join engineers protecting their production PostgreSQL databases from runaway AI queries and cryptic syntax errors.

$npm install -g querycraft && querycraft auth login