SQL Database Query Architect skill for Claude and Codex
Production-ready SQL for a complex data question against your schema: the right joins, CTEs, and window functions for your dialect, with the logic explained…
Install it once and Claude or Codex runs it for you. When your request matches, your AI loads the skill, asks for anything it is missing, and works through the template itself. Prefer to fill it in by hand? See the full prompt template.
Download the skill (.zip) · View SKILL.md
When it is used
Use when a complex data question needs a production-ready SQL query designed against a known schema with CTEs, window functions, and dialect-correct syntax. Do not use for diagnosing why an existing query is slow, or a quick one-table statement. Related topics: coding, sql.
What it will ask you for
- Database dialect (choose one: MySQL, PostgreSQL, SQL Server, Oracle, SQLite)
- Schema (longer free text)
- Data request (longer free text)
- Operation (choose one: SELECT, INSERT, UPDATE, DELETE, JOIN, AGGREGATE)
- Performance hints (choose any: Use indexes, Partition tables, Apply CTEs, Leverage window functions, Enable query caching)
- Row limit (number from 1 to 1000)
How it works
- Restate the request as the grain of the result set (one row per what) and confirm the schema can produce it.
- Build the query as named CTEs that each do one thing, joined on the schema's keys, with window functions where rows are compared within a group.
- Write it in the chosen dialect's syntax for limits, dates, strings, and quoting.
- Apply each selected performance hint where it changes the plan and note where it would not help.
- For writes, lead with the WHERE clause and add a preview SELECT; then explain the logic in evaluation order.
What you get
A sql code block with the query, a short explanation in engine evaluation order, and one line per performance hint applied or declined.
What it watches out for
- Joining two one-to-many relations in the same query, which multiplies rows and inflates every aggregate.
- Using LIMIT in SQL Server or Oracle, where the syntax is TOP or FETCH FIRST.
- Writing an UPDATE or DELETE without a WHERE preview, so a typo touches the whole table.
How to install
Claude.ai and the Claude desktop app
- Download the skill .zip.
- Open Settings, then Capabilities, and find Skills.
- Choose Upload skill and select the .zip.
- Ask Claude for help with the task. It loads the skill when your request matches.
Claude Code
- Download the skill .zip.
- Unzip it into ~/.claude/skills/ (or .claude/skills/ inside a project).
- Start a new session. Claude Code loads the skill when your request matches.
Codex
- Download the skill .zip.
- Unzip it into ~/.agents/skills/ (or .agents/skills/ inside a project).
- Codex picks it up on its own. Type $ and the skill name to use it, or just ask for the task.
Cursor
- Download the Cursor rule (.mdc).
- Save it in .cursor/rules/ inside your project.
- Cursor's agent applies the rule when your request matches its description.
AGENTS.md (Codex, Cursor, and other coding agents)
- Copy the AGENTS.md section.
- Paste it into AGENTS.md at the root of your repository, creating the file if needed.
- Coding agents that read AGENTS.md follow it when your request fits.