sql-review

sql-review is a command for GitHub Copilot from saajunaid/caddis-plugin. It costs 17 tokens per session (1,193 once invoked), scanned A, original, MIT.

A SQL code reviewer that checks queries for security, performance, correctness, and common good practices. SQL is the language commonly used to work with databases.

In plain words
What is it for?
Use it to review SQL across major database systems.
Why use it?
It helps catch unsafe, slow, or incorrect database queries before they are used.

Command for GitHub Copilot

Written for GitHub Copilot: a Copilot chat mode or prompt.

Good fit Use it to review SQL across major database systems.

Compare 6 commands from other repositories ↓
Install with agentmods
npx agentmods add commands/saajunaid/caddis-plugin/sql-review
Install

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.

Clone the repo
git clone --depth 1 https://github.com/saajunaid/caddis-plugin

Made for: GitHub Copilot.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for sql-review

README.md
[![agentmods](https://agentmods.dev/badge/commands/saajunaid/caddis-plugin/sql-review/github.svg)](https://agentmods.dev/commands/saajunaid/caddis-plugin/sql-review)
Your own site
<a href="https://agentmods.dev/commands/saajunaid/caddis-plugin/sql-review"><img src="https://agentmods.dev/badge/commands/saajunaid/caddis-plugin/sql-review/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for sql-review

Your own site · 80×15
<a href="https://agentmods.dev/commands/saajunaid/caddis-plugin/sql-review"><img src="https://agentmods.dev/badge/commands/saajunaid/caddis-plugin/sql-review.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 17 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,193 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What 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.

ModelPer sessionOnce invoked
Fable 5.1 $0.00017 $0.01193
Opus 5.5 $0.00007 $0.00477
Sonnet 5.5 $0.00003 $0.00239
Haiku 4.5 $0.00002 $0.00119

Measured 1mo ago against content hash eb1266c6048a, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

sql-review 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 1mo ago.

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.

.github/prompts/sql-review.prompt.md · 180 lines

How it starts

The opening of the file, as written. The whole thing — 180 lines — stays where its author put it; the contents beside it link to each section on GitHub.

/sql-review - SQL Code Review

Perform a thorough SQL code review of the provided code (or selection) focusing on security, performance, maintainability, and database best practices.

Input

SQL code to review: {{input}}

If no SQL provided, scan the workspace for .sql files, stored procedures, or inline queries.


Review Categories

1. Security Analysis

SQL Injection Prevention
-- BAD: SQL Injection vulnerability
query = "SELECT * FROM users WHERE id = " + userInput;

-- GOOD: Parameterized queries
-- PostgreSQL/MySQL
PREPARE stmt FROM 'SELECT * FROM users WHERE id = ?';
-- SQL Server
EXEC sp_executesql N'SELECT * FROM users WHERE id = @id', N'@id INT', @id = @user_id;
Access Control
  • Principle of Least Privilege: Grant minimum required permissions
  • Use database roles instead of direct user permissions
  • Review DEFINER vs INVOKER rights on functions/procedures
  • Avoid SELECT * on tables with sensitive columns

2. Performance Optimization

Common Anti-Patterns

Functions in WHERE clauses (prevents index usage):

-- BAD
SELECT * FROM orders WHERE YEAR(order_date) = 2024;
-- GOOD
SELECT * FROM orders WHERE order_date >= '2024-01-01' AND order_date < '2025-01-01';

N+1 Query Problem:

-- BAD: N+1 queries in application code
for user in users:
    orders = query("SELECT * FROM orders WHERE user_id = ?", user.id)
-- GOOD: Single query
SELECT u.*, o.* FROM users u LEFT JOIN orders o ON u.id = o.user_id;

Overuse of DISTINCT (masking join issues):

-- BAD
SELECT DISTINCT u.name FROM users u, orders o WHERE u.id = o.user_id;
-- GOOD
SELECT u.name FROM users u INNER JOIN orders o ON u.id = o.user_id GROUP BY u.name;
Index Strategy
  • Missing indexes on WHERE/JOIN/ORDER BY columns
  • Over-indexing (unused or redundant indexes)
  • Composite index column order
  • Covering indexes for frequently queried column sets
Join Optimization
  • Verify appropriate join types (INNER vs LEFT vs EXISTS)
  • Optimize join order for smaller result sets first
  • Identify accidental cartesian products (missing join conditions)

Read the full file on GitHub · 180 lines

Changes

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.

  1. 1mo ago First seen · 180 lines · 17 tokens per session scan A eb1266c6048a

Subscribe to this mod's changes

sql-review is a command published in the GitHub repository saajunaid/caddis-plugin (0 stars, last pushed today), licensed MIT. It adds 17 tokens to every session and 1,193 once invoked, about $0.0001 per session on Opus 5.5. 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-09-09.