Skill library / For developers
Cursor skill for SQL queries
For developers and analysts who write SQL inside a codebase and want queries that match the real schema.
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.
Use this skill nowSee the SKILL.md
Answer up to 4 quick questions, add your email, and get a version written around you, ready to paste into Cursor. Free, no account needed.
What it's good for
- Ad-hoc reporting queries
- Optimising slow queries flagged in logs
- Writing safe migrations
The SKILL.md file
Save as sql-query-helper/SKILL.md. It follows the open Agent Skills format.
---
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 it in Cursor
Put the folder in .cursor/skills/ (or .agents/skills/), or copy the included .mdc file into .cursor/rules/.
Example
Illustrative example. This shows the kind of request and result to expect. It is not a real conversation, and your result will depend on what you give it.
You ask: “Monthly revenue by plan for the last 12 months”
What you get back: A Postgres query with date_trunc grouping, a join explanation and an index suggestion on invoices(created_at).
Pro tip
Set globs to **/*.sql and your migrations folder so the rule activates with database work.
Make your own version
This prompt is a good start, but it doesn't know you. Answer a few quick questions about your situation and how you like things done, and we'll write a version that does. It appears on screen with a Copy button and setup steps for your AI, and we email you a copy. Free, up to 10 a month.
Make my own version freeQuestions
Does it know my schema?
It reads the schema in your project, so tables and columns match what actually exists.
Will it suggest indexes?
Yes. It explains which indexes a query relies on and suggests new ones where useful.
How do I install it 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 the prompt on this page for free, with no sign-up. If you want a version written around you, our generator is free too (up to 10 a month, no account needed): answer a few questions and we email you a copy.