Skill library / Cursor

SQL Query Helper skill for Cursor

Writing SQL without knowing the schema leads to wrong joins. This skill points Cursor at your schema first, then writes queries that are correct, readable and index-friendly.

Customise this skill free →

What it's good for

How the skill works

  1. Read the schema or migration files to confirm tables and columns
  2. Write the query with explicit column lists and aliases
  3. Explain each join in one line
  4. Suggest indexes if filtering on unindexed columns
  5. For writes, wrap in a transaction and show a dry-run SELECT first

Built-in rules

Example

You: “Monthly revenue by plan for the last 12 months”
Result: A Postgres query with date_trunc grouping, a join explanation and an index suggestion on invoices(created_at).

SKILL.md template

Save as sql-query-helper/SKILL.md.

---
name: sql-query-helper
description: "Writes and optimises SQL queries against the project's schema, explaining joins and indexes. Use when the user asks for a query, report, migration or to speed up slow SQL."
---

# SQL Query Helper

## Workflow
1. Read the schema or migration files to confirm tables and columns
2. Write the query with explicit column lists and aliases
3. Explain each join in one line
4. Suggest indexes if filtering on unindexed columns
5. For writes, wrap in a transaction and show a dry-run SELECT first

## Rules
- Never use SELECT * in production queries
- Never run destructive statements without confirmation
- Use parameter placeholders, never string concatenation

How to install in Cursor

Put the folder in .cursor/skills/ (or .agents/skills/), or copy the included .mdc file into .cursor/rules/.

Pro tip

Set globs to **/*.sql and your migrations folder so the rule activates with database work.

Want it tailored to how you work?

Answer a few questions and get a customised version with examples, a Cursor rule and GPT/Gem instructions, emailed free.

Make my version →

FAQ

How do I install the sql query helper skill in Cursor?

Put the folder in .cursor/skills/ (or .agents/skills/), or copy the included .mdc file into .cursor/rules/.

Is it free?

Yes. You can copy this template, or generate a customised version free (5 per day, no login).

Does it work on other platforms?

Yes. The SKILL.md follows the open Agent Skills standard, and every generated package also includes a Cursor rule and ChatGPT/Gemini instructions.

Related skills