Getting it into your agent
One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.
npx agentmods add rules/hamzaamjad/cursor-rules/212-sql-correctnessgit clone --depth 1 https://github.com/hamzaamjad/cursor-rulesWhat it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5 | $0.00000 | $0.00901 |
| Opus 5 | $0.00000 | $0.00451 |
| Sonnet 5 | $0.00000 | $0.00180 |
| Haiku 4.5 | $0.00000 | $0.00090 |
Grade A, and why
212-sql-correctness scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
What it actually says
sql-correctness.mdc
- Purpose: To guide AI assistants and developers in writing correct and robust SQL queries, paying attention to dialect specifics and common pitfalls.
- Requirements:
- Dialect Awareness:
- Explicitly confirm the target SQL dialect (e.g., Redshift, PostgreSQL, MySQL, BigQuery, Snowflake).
- Verify function usage against the specific dialect's documentation, especially for date/time manipulation (e.g.,
DATEADD/DATE_ADD/+ INTERVAL,DATEDIFF,GETDATE/NOW/CURRENT_TIMESTAMP), string manipulation, and JSON functions.
- Join Logic:
- Verify join types (
INNER,LEFT,RIGHT,FULL OUTER) match the intended logic for handling matching and non-matching rows. - Ensure join conditions (
ONclause) correctly link tables using appropriate keys and comparisons. Avoid unintentional cross joins.
- Verify join types (
- Column References:
- Qualify column names with table aliases or full table names when multiple tables are involved to avoid ambiguity.
- Double-check column names for typos against the source schema.
- Filtering:
- Ensure
WHEREclauses accurately reflect the desired filtering conditions. - Be mindful of
NULLhandling in comparisons (useIS NULL/IS NOT NULL).
- Ensure
- Aggregation & Window Functions:
- Verify
GROUP BYclauses include all non-aggregated columns in theSELECTlist (unless the dialect permits otherwise). - Ensure window function
PARTITION BYandORDER BYclauses are correctly specified for the intended calculation. - Redshift Specific: Avoid using
COUNT(DISTINCT col) OVER (PARTITION BY ...)due to potential parser limitations. Instead, pre-aggregate data to the required grain in a preceding CTE to ensure distinctness, then useCOUNT(*) OVER (PARTITION BY ...)on the pre-aggregated data.
- Verify
- Output Ordering:
- Include an
ORDER BYclause for finalSELECTstatements intended for human consumption or reporting to ensure deterministic results, unless ordering is irrelevant or handled downstream.
- Include an
- Syntax & Formatting:
- Validate overall query syntax against the target dialect.
- Maintain consistent formatting (indentation, capitalization of keywords) for readability. Refer to
sql-performance.mdcfor performance-related style.
- Dialect Awareness:
- Validation:
- Check: Is the target SQL dialect mentioned or assumed correctly?
- Check: Are dialect-specific functions used appropriately? (e.g., Redshift
DATEADDvs. PostgreSQL interval math). - Check: Is join logic clear and likely correct? Are columns qualified?
- Check: Does the query include an
ORDER BYclause if the output is likely for reporting? - Check: Is the syntax valid for the target platform?
- Examples:
- Scenario: Calculating days between two dates in Redshift.
- Weak (PostgreSQL style):
SELECT end_date - start_date FROM my_table; - Improved (Redshift style):
SELECT DATEDIFF(day, start_date, end_date) FROM my_table;
- Weak (PostgreSQL style):
- Scenario: Getting user name but handling missing users.
- Weak (Might error or lose rows on INNER JOIN):
SELECT o.order_id, u.name FROM orders o JOIN users u ON o.user_id = u.id; - Improved (Handles missing users):
SELECT o.order_id, COALESCE(u.name, 'Unknown') FROM orders o LEFT JOIN users u ON o.user_id = u.id;
- Weak (Might error or lose rows on INNER JOIN):
- Scenario: Calculating days between two dates in Redshift.
- Changes: Updated to include recent SQL dialects and best practices for ensuring SQL correctness, including handling of JSON data types and new window functions.
- Source References: Retrospective from GTM compensation SQL task (July 2024).
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- yesterday First seen · 44 lines · 0 tokens per session scan A 579a46ace1bb
212-sql-correctness is a cursor rule published in the GitHub repository hamzaamjad/cursor-rules (2 stars, last pushed 1y ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 901 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.
Other cursor rules, from other repositories
angular-20
This rule provides comprehensive best practices and coding standards for Angular development, focusing on modern TypeScript, standalone components, signals, and performance optimizations.
dev-standard
Apache Superset development standards and guidelines for Cursor IDE.
typescript
Changes to these high-fan-out internals can affect every message, delta, element, or rerun. Keep work in them minimal, and benchmark changes with representative stress-test apps.
coolify-ai-docs
Master reference to all Coolify AI documentation in .ai/ directory.
python_lib
Tips and guidelines specific to the development of the Streamlit Python library, not applicable to scripts and e2e tests.
specs
This directory contains product and tech specs for Streamlit features.