Review SQL and query code for injection risk, parameterization, indexing and performance, transactions, NULL and constraints, and dialect portability. Language-only atomic skill; output is a findings list.
Review SQL and query-related code for language and query conventions only. Cover injection and parameterization, indexing and execution-plan concerns, transactions and isolation, NULL and unique constraints, dialect portability, large-table and paging patterns, and sensitive columns and permissions. Emit a findings list in the standard format for aggregation. Do not define scope or perform full security/architecture review; injection is in scope here as an SQL-specific concern, but broader security is for review-security.
Core Objective
Primary goal: Produce a SQL-focused findings list covering injection/parameterization, indexing, transactions, NULL/constraints, dialect portability, paging patterns, and sensitive column access for the given code scope.
Success Criteria (ALL must be met):
✅ SQL-only scope: Only SQL and query conventions are reviewed; no scope selection, full security, or architecture analysis performed
✅ All seven SQL dimensions covered: Injection/parameterization, indexing/execution plan, transactions/isolation, NULL/unique constraints, dialect/portability, large table/paging patterns, and sensitive columns/permissions are assessed where relevant
✅ Findings format compliant: Each finding includes Location, Category (language-sql), Severity, Title, Description, and optional Suggestion
✅ Critical injection issues flagged: SQL injection patterns (string concatenation, interpolation with user input) are marked as critical severity
✅ Location-precise references: All findings reference specific file:line or query identifier locations
Acceptance Test: Does the output contain a SQL findings list covering all relevant query dimensions, with injection risks marked critical and specific location references for every finding?
Scope Boundaries
This skill handles:
SQL injection via string concatenation or interpolation — parameterized queries and prepared statements
NULL handling in comparisons/aggregates, unique constraints, NOT NULL correctness
Database dialect portability (LIMIT/OFFSET/FETCH, date functions, vendor-specific syntax)
Large table full scans, paging strategies (keyset vs OFFSET)
Sensitive column exposure in SELECT, least-privilege role usage
This skill does NOT handle:
Scope selection — scope is provided by the caller
Broader security analysis (beyond SQL injection) — use review-security
Architecture analysis — use review-architecture
Full orchestrated review — use orchestrate-code-review
Handoff point: When all SQL findings are emitted, hand off to orchestrate-code-review for aggregation. For broader security concerns (auth, crypto, config), redirect to review-security.
Use Cases
Orchestrated review: Used as the language step when orchestrate-code-review runs for projects that include SQL (.sql files, embedded SQL, or ORM-generated SQL).
SQL-only review: When the user wants only query correctness, performance, and safety checked.
Migration or portability: Check dialect-specific constructs and portability across databases.
When to use: When the code under review includes SQL (raw .sql, embedded in code, or ORM-generated). Scope (diff vs paths) is determined by the caller or user.
Behavior
Scope of this skill
Analyze: SQL and query logic in the given scope (files, snippets, or diff). Accept .sql files, embedded SQL in application code, or ORM-generated SQL when visible.
Do not: Decide scope (diff vs codebase); do not perform full application security or architecture review. Focus on SQL/query dimension.
Review checklist (SQL dimension only)
Injection and parameterization: No string concatenation or interpolation for user input in SQL; use parameterized queries or prepared statements; avoid dynamic SQL from untrusted input.
Indexing and execution plan: Queries that filter or join on unindexed columns; SELECT * on large tables; missing indexes for WHERE/JOIN/ORDER BY.
Transactions and isolation: Appropriate transaction boundaries; isolation level and locking; avoid long-running transactions; deadlock risk.
NULL and unique constraints: Handling of NULL in comparisons and aggregates; unique constraints and duplicate handling; NOT NULL where appropriate.
Dialect and portability: Database-specific syntax (e.g. LIMIT vs OFFSET/FETCH, date functions) and portability if multi-DB support is required.
Large tables and paging: Full scans on large tables; paging (keyset vs OFFSET) and scalability.
Sensitive columns and permissions: Sensitive data in SELECT; least-privilege and role usage in SQL (where visible).
Tone and references
Professional and technical: Reference specific locations (file:line or query identifier). Emit findings with Location, Category, Severity, Title, Description, Suggestion.
Input & Output
Input
Code scope: Files or snippets containing SQL (e.g. .sql files, code with embedded SQL, or ORM-generated SQL when available). Provided by the user or scope skill.
Output
Emit zero or more findings in the format defined in specs/findings-list.md, with Categorylanguage-sql.
Category for this skill is language-sql.
Restrictions
Hard Boundaries
Do not perform scope selection or full security/architecture review. Stay within SQL and query conventions.
Do not give conclusions without specific locations or actionable suggestions.
Do not assume a specific database vendor unless stated; note dialect when relevant.
Skill Boundaries
Do NOT do these (other skills handle them):
Do NOT select or define the code scope — scope is determined by the caller or orchestrate-code-review
Do NOT perform broad security analysis beyond SQL injection — use review-security
Do NOT perform architecture analysis — use review-architecture
Do NOT review non-SQL code for SQL conventions (SQL injection in application code should be flagged by review-security)
When to stop and hand off:
When all SQL findings are emitted, hand off to orchestrate-code-review for aggregation
When the user needs broader security analysis (auth, crypto, config), redirect to review-security
When the user needs a full review (scope + language + cognitive), redirect to orchestrate-code-review
Self-Check
Core Success Criteria
SQL-only scope: Only SQL and query conventions are reviewed; no scope selection, full security, or architecture analysis performed
All seven SQL dimensions covered: Injection/parameterization, indexing/execution plan, transactions/isolation, NULL/unique constraints, dialect/portability, large table/paging patterns, and sensitive columns/permissions are assessed where relevant
Findings format compliant: Each finding includes Location, Category (language-sql), Severity, Title, Description, and optional Suggestion
Critical injection issues flagged: SQL injection patterns (string concatenation, interpolation with user input) are marked as critical severity
Location-precise references: All findings reference specific file:line or query identifier locations
Process Quality Checks
Was only the SQL/query dimension reviewed (no scope/architecture beyond query design)?
Are parameterization, indexing, transactions, NULL/constraints, and portability covered where relevant?
Is each finding emitted with Location, Category=language-sql, Severity, Title, Description, and optional Suggestion?
Are issues referenced with file:line or query identifier?
Acceptance Test
Does the output contain a SQL findings list covering all relevant query dimensions, with injection risks marked critical and specific location references for every finding?
Examples
Example 1: String concatenation in query
Input: Query built with string concatenation including user input.
Expected: Emit a critical finding for SQL injection; suggest parameterized query or prepared statement. Category = language-sql.
Example 2: Large table without paging
Input: SELECT * FROM large_table ORDER BY id without LIMIT or paging.
Expected: Emit finding for performance and scalability; suggest paging (e.g. keyset or OFFSET/FETCH) and avoid SELECT * if not needed. Category = language-sql.
Edge case: ORM-generated SQL
Input: Only application code using an ORM; generated SQL not visible.
Expected: Review any raw SQL or query builders in the code; if no SQL is visible, state that and skip or report "No SQL to review in scope." Do not invent SQL.
1---2name: review-sql3description: Review SQL and query code for injection risk, parameterization, indexing and performance, transactions, NULL and constraints, and dialect portability. Language-only atomic skill; output is a findings list.4license: MIT5---67# Skill: Review SQL89## Purpose1011Review **SQL** and query-related code for **language and query conventions** only. Cover injection and parameterization, indexing and execution-plan concerns, transactions and isolation, NULL and unique constraints, dialect portability, large-table and paging patterns, and sensitive columns and permissions. Emit a **findings list** in the standard format for aggregation. Do not define scope or perform full security/architecture review; injection is in scope here as an SQL-specific concern, but broader security is for [review-security](../review-security/SKILL.md).1213---1415## Core Objective1617**Primary goal**: Produce a SQL-focused findings list covering injection/parameterization, indexing, transactions, NULL/constraints, dialect portability, paging patterns, and sensitive column access for the given code scope.1819**Success Criteria** (ALL must be met):20211. ✅ **SQL-only scope**: Only SQL and query conventions are reviewed; no scope selection, full security, or architecture analysis performed222. ✅ **All seven SQL dimensions covered**: Injection/parameterization, indexing/execution plan, transactions/isolation, NULL/unique constraints, dialect/portability, large table/paging patterns, and sensitive columns/permissions are assessed where relevant233. ✅ **Findings format compliant**: Each finding includes Location, Category (`language-sql`), Severity, Title, Description, and optional Suggestion244. ✅ **Critical injection issues flagged**: SQL injection patterns (string concatenation, interpolation with user input) are marked as `critical` severity255. ✅ **Location-precise references**: All findings reference specific file:line or query identifier locations2627**Acceptance Test**: Does the output contain a SQL findings list covering all relevant query dimensions, with injection risks marked `critical` and specific location references for every finding?2829---3031## Scope Boundaries3233**This skill handles**:3435- SQL injection via string concatenation or interpolation — parameterized queries and prepared statements36- Indexing gaps for WHERE/JOIN/ORDER BY columns37- Transaction boundaries, isolation levels, deadlock risk, long-running transactions38- NULL handling in comparisons/aggregates, unique constraints, NOT NULL correctness39- Database dialect portability (LIMIT/OFFSET/FETCH, date functions, vendor-specific syntax)40- Large table full scans, paging strategies (keyset vs OFFSET)41- Sensitive column exposure in SELECT, least-privilege role usage4243**This skill does NOT handle**:4445- Scope selection — scope is provided by the caller46- Broader security analysis (beyond SQL injection) — use `review-security`47- Architecture analysis — use `review-architecture`48- Full orchestrated review — use `orchestrate-code-review`4950**Handoff point**: When all SQL findings are emitted, hand off to `orchestrate-code-review` for aggregation. For broader security concerns (auth, crypto, config), redirect to `review-security`.5152---5354## Use Cases5556- **Orchestrated review**: Used as the language step when [orchestrate-code-review](../orchestrate-code-review/SKILL.md) runs for projects that include SQL (.sql files, embedded SQL, or ORM-generated SQL).57- **SQL-only review**: When the user wants only query correctness, performance, and safety checked.58- **Migration or portability**: Check dialect-specific constructs and portability across databases.5960**When to use**: When the code under review includes SQL (raw .sql, embedded in code, or ORM-generated). Scope (diff vs paths) is determined by the caller or user.6162---6364## Behavior6566### Scope of this skill6768- **Analyze**: SQL and query logic in the **given scope** (files, snippets, or diff). Accept .sql files, embedded SQL in application code, or ORM-generated SQL when visible.69- **Do not**: Decide scope (diff vs codebase); do not perform full application security or architecture review. Focus on SQL/query dimension.7071### Review checklist (SQL dimension only)72731. **Injection and parameterization**: No string concatenation or interpolation for user input in SQL; use parameterized queries or prepared statements; avoid dynamic SQL from untrusted input.742. **Indexing and execution plan**: Queries that filter or join on unindexed columns; SELECT * on large tables; missing indexes for WHERE/JOIN/ORDER BY.753. **Transactions and isolation**: Appropriate transaction boundaries; isolation level and locking; avoid long-running transactions; deadlock risk.764. **NULL and unique constraints**: Handling of NULL in comparisons and aggregates; unique constraints and duplicate handling; NOT NULL where appropriate.775. **Dialect and portability**: Database-specific syntax (e.g. LIMIT vs OFFSET/FETCH, date functions) and portability if multi-DB support is required.786. **Large tables and paging**: Full scans on large tables; paging (keyset vs OFFSET) and scalability.797. **Sensitive columns and permissions**: Sensitive data in SELECT; least-privilege and role usage in SQL (where visible).8081### Tone and references8283- **Professional and technical**: Reference specific locations (file:line or query identifier). Emit findings with Location, Category, Severity, Title, Description, Suggestion.8485---8687## Input & Output8889### Input9091- **Code scope**: Files or snippets containing SQL (e.g. .sql files, code with embedded SQL, or ORM-generated SQL when available). Provided by the user or scope skill.9293### Output9495- Emit zero or more **findings** in the format defined in [specs/findings-list.md](../../specs/findings-list.md), with **Category** `language-sql`.96- Category for this skill is **language-sql**.9798---99100## Restrictions101102### Hard Boundaries103104- **Do not** perform scope selection or full security/architecture review. Stay within SQL and query conventions.105- **Do not** give conclusions without specific locations or actionable suggestions.106- **Do not** assume a specific database vendor unless stated; note dialect when relevant.107108### Skill Boundaries109110**Do NOT do these** (other skills handle them):111112- Do NOT select or define the code scope — scope is determined by the caller or `orchestrate-code-review`113- Do NOT perform broad security analysis beyond SQL injection — use `review-security`114- Do NOT perform architecture analysis — use `review-architecture`115- Do NOT review non-SQL code for SQL conventions (SQL injection in application code should be flagged by `review-security`)116117**When to stop and hand off**:118119- When all SQL findings are emitted, hand off to `orchestrate-code-review` for aggregation120- When the user needs broader security analysis (auth, crypto, config), redirect to `review-security`121- When the user needs a full review (scope + language + cognitive), redirect to `orchestrate-code-review`122123---124125## Self-Check126127### Core Success Criteria128129- [ ] **SQL-only scope**: Only SQL and query conventions are reviewed; no scope selection, full security, or architecture analysis performed130- [ ] **All seven SQL dimensions covered**: Injection/parameterization, indexing/execution plan, transactions/isolation, NULL/unique constraints, dialect/portability, large table/paging patterns, and sensitive columns/permissions are assessed where relevant131- [ ] **Findings format compliant**: Each finding includes Location, Category (`language-sql`), Severity, Title, Description, and optional Suggestion132- [ ] **Critical injection issues flagged**: SQL injection patterns (string concatenation, interpolation with user input) are marked as `critical` severity133- [ ] **Location-precise references**: All findings reference specific file:line or query identifier locations134135### Process Quality Checks136137- [ ] Was only the SQL/query dimension reviewed (no scope/architecture beyond query design)?138- [ ] Are parameterization, indexing, transactions, NULL/constraints, and portability covered where relevant?139- [ ] Is each finding emitted with Location, Category=language-sql, Severity, Title, Description, and optional Suggestion?140- [ ] Are issues referenced with file:line or query identifier?141142### Acceptance Test143144Does the output contain a SQL findings list covering all relevant query dimensions, with injection risks marked `critical` and specific location references for every finding?145146---147148## Examples149150### Example 1: String concatenation in query151152- **Input**: Query built with string concatenation including user input.153- **Expected**: Emit a critical finding for SQL injection; suggest parameterized query or prepared statement. Category = language-sql.154155### Example 2: Large table without paging156157- **Input**: SELECT * FROM large_table ORDER BY id without LIMIT or paging.158- **Expected**: Emit finding for performance and scalability; suggest paging (e.g. keyset or OFFSET/FETCH) and avoid SELECT * if not needed. Category = language-sql.159160### Edge case: ORM-generated SQL161162- **Input**: Only application code using an ORM; generated SQL not visible.163- **Expected**: Review any raw SQL or query builders in the code; if no SQL is visible, state that and skip or report "No SQL to review in scope." Do not invent SQL.
Run npx skillmds@latest add nesnilnehc/review-sql in your terminal (requires Node.js), paste this page's agent-chat prompt into Claude, Cursor, or any MCP-connected agent, or download the SKILL.md file and copy it into your agent's skills directory.
Review SQL and query code for injection risk, parameterization, indexing and performance, transactions, NULL and constraints, and dialect portability. Language-only atomic skill; output is a findings list. It is listed under Data & Analytics on SkillMD.
This skill has not completed SkillMD's automated safety review yet. SkillMD never runs a skill's scripts for you; review the SKILL.md before installing.
This skill is tagged as working with Claude Code, Claude.ai, OpenAI Codex. SKILL.md is an open format, so most agents that read a skills directory can load it too.
Yes. Installing skills from SkillMD is free. This skill is licensed under MIT.
nesnilnehc (@nesnilnehc) published this skill. Their other Agent Skills are listed on their SkillMD profile.