Published: 2026-03-19

AI Skills for SQL Databases: Let Claude Code, Codex, and Cursor Query Your Data

AI coding agents can write SQL. But they can't see your schema, test their queries, or know which tables actually exist. AI skills change that — a single file teaches any agent to query SQL Server, PostgreSQL, MySQL, Oracle, and SQLite through your desktop IDE.

The Problem: AI Writes SQL Blind

You ask Claude Code to write a query joining your orders and customers tables. It produces syntactically correct SQL with table names it hallucinated. You correct it, paste your CREATE TABLE statements, and try again. Better, but the context is stale tomorrow when someone adds a column.

This is the state of AI-assisted SQL development today. The agent can generate syntax, but it has no access to your actual database. It can't list your connections, introspect your schema, or execute a SELECT to verify its output. Every interaction requires you to be the middleman, copying context back and forth.

The root cause is simple: AI agents don't know how to talk to your database tools. They need to be taught.

What Is an AI Skill?

An AI skill is a markdown file — typically called SKILL.md — that gets loaded into an agent's context when relevant. It teaches the agent how to use a specific tool: what commands are available, how to authenticate, what the output looks like, and what to do when things go wrong.

Skills are the emerging standard for extending AI coding agents. Claude Code loads them from .claude/skills/, Codex CLI and Cursor pick them up from .agents/skills/, and other agents follow similar conventions. A single skill file works across all of them.

The Jam SQL skill teaches agents to use the jam-sql CLI, which communicates with the Jam SQL Studio desktop app running on your machine. The app manages all database connections, credentials, and permissions. The agent just runs shell commands.

How It Works

The architecture has three layers:

  1. The AI agent (Claude Code, Codex, Cursor, etc.) reads the skill file and learns the jam-sql CLI commands.
  2. The CLI translates those commands into MCP protocol calls over localhost HTTP. It handles authentication, session management, and error formatting.
  3. Jam SQL Studio receives the calls, enforces permissions, executes queries against your actual databases, and returns structured results.

The agent never touches the MCP protocol directly. It never sees your database credentials. It runs shell commands and reads the output — exactly like it runs git or npm.

Setup in 3 Minutes

1. Install the skill

jam-sql add-skill

This auto-detects installed AI agents and copies the skill file to the right directories. Works with Claude Code, Codex CLI, Cursor, Copilot, Cline, Windsurf, and Warp.

2. Pair with the app

When you ask the agent to query a database, it runs jam-sql pair automatically. A consent dialog appears in the app — approve it, and the CLI is authorized. No manual token copying.

3. Start querying

The agent can now:

  • List your saved connections: jam-sql connections
  • Run queries: jam-sql query "SELECT TOP 10 * FROM orders" -c <connection-id>
  • Explore schemas: jam-sql call schema_get_tables connectionId=... database=...
  • Compare schemas: jam-sql schema-compare --source ... --target ...
  • Open tabs in the IDE: jam-sql call ui_open_tab type=query initialSql="..."

The skill teaches the discovery pattern: check status, pair if needed, list connections, then work with data. When the app adds new tools, the agent discovers them via jam-sql tools — no skill update needed.

Supported Databases

The same skill and CLI work across all databases that Jam SQL Studio supports:

  • SQL Server — including Azure SQL Database, Azure SQL Managed Instance, and SQL Server on Linux
  • PostgreSQL — including Amazon RDS, Azure Database for PostgreSQL, and Supabase
  • MySQL — including MariaDB, Amazon RDS, Azure Database for MySQL, and PlanetScale
  • Oracle Database — no Oracle Client required (Thin mode), works on macOS, Linux, and Windows
  • SQLite — local file databases, including those used by mobile apps and embedded systems

The agent doesn't need to know which database engine it's talking to. It sends SQL, and the app handles the rest.

Security: The App Controls Everything

The skill file does not contain safety rules like "never run DELETE queries." Instead, the app enforces its own permission model at runtime:

  • Block (default) — The agent can introspect schemas and write SQL into the editor, but cannot execute anything.
  • Read-only — SELECT, EXPLAIN, SHOW, and DESCRIBE are allowed. No writes, no DDL.
  • Confirm — Write queries trigger an in-app approval dialog. You see the full SQL, the target connection, and you have 60 seconds to approve or deny. Auto-denied on timeout.

Database credentials are never exposed to the agent. The MCP server binds to 127.0.0.1 only — no external access. Authentication uses a bearer token generated per app session.

Per-connection overrides let you allow read-only on your dev database while blocking your production instance entirely. The agent can't escalate — these policies are enforced server-side, not in the skill file where an agent could reinterpret them.

Which AI Agents Work?

Any agent with shell access can use the skill:

  • Claude Code (Anthropic) — loads skill from .claude/skills/
  • Codex CLI (OpenAI) — loads skill from .agents/skills/
  • Cursor — loads skill from .cursor/skills/ or .agents/skills/
  • GitHub Copilot — with MCP extension in VS Code
  • OpenCode — terminal coding agent with MCP support
  • Windsurf — loads skill from .windsurf/skills/ or .agents/skills/
  • Cline — loads skill from .agents/skills/
  • Warp AI — terminal-native agent

Agents with native MCP client support (like Claude Desktop) can also connect directly to the MCP server without the CLI, configured in the app's Settings → AI Integrations.

Real Workflow Examples

Schema-Aware Query Generation

You ask the agent: "Write a query that shows each customer's total spending." It runs jam-sql call schema_get_tables to discover your schema, finds dbo.Orders and dbo.Customers, reads the column definitions and foreign keys, then writes a JOIN query using the correct column names and types. No hallucination.

Data Exploration

You're investigating a data issue. You tell the agent: "Find all orders from last month with negative totals." The agent writes the query, executes it, gets the results, and analyzes the data — all without you switching windows. If it finds anomalies, it can drill deeper on its own.

Migration Script Generation

You need to add audit columns to a set of tables. The agent reads the current schema, identifies which tables need the change, generates ALTER TABLE scripts with the correct types and defaults, and can even compare the result against a target schema using jam-sql schema-compare.

Multi-Database Comparison

You want to check if staging matches production. The agent runs jam-sql schema-compare between two connections, waits for results, and reports the differences. No need to manually configure comparison tools or interpret XML output.

Why a Skill + CLI, Not Direct MCP?

Most AI agents can run shell commands. Not all of them have native MCP client support. The CLI approach means one integration works everywhere — from Claude Code to a bash script.

The CLI is also self-updating. It's bundled with the desktop app and auto-installed to your PATH. When the app updates and adds new database tools, the CLI wraps them automatically. The agent discovers new tools via jam-sql tools — the skill file rarely needs updating.

This is a deliberate design choice: the skill teaches patterns, not protocols. It shows the agent how to check status, pair, discover tools, and run queries. The MCP protocol details are hidden behind the CLI.

Getting Started

  1. Download Jam SQL Studio (free for personal use)
  2. Add your database connections in the app
  3. Enable the MCP server: Settings → AI Integrations → Enable MCP server
  4. Run jam-sql add-skill from your terminal
  5. Ask your AI agent to query your database

The entire setup takes about three minutes. Once connected, the agent has live access to your schemas, can execute queries, and works with the results — all through the safety controls you configure in the app.

Give Your AI Agent Database Access

Jam SQL Studio's AI skill works with Claude Code, Codex, Cursor, Copilot, and more. Connect to SQL Server, PostgreSQL, MySQL, Oracle, and SQLite.

Related