# Legacy SQL Review

> Review legacy SQL and mapper queries for correctness, performance, binding safety, pagination issues, and maintainability.

- Skill: `gabeujin/legacy-sql-review` (Agent Skill)
- Install (CLI): `npx skillmds@latest add gabeujin/legacy-sql-review`
- Raw SKILL.md: https://api.skillmd.com/api/skills/gabeujin/legacy-sql-review/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Data & Analytics
- Author: Gabeujin (https://skillmd.com/u/gabeujin)
- Updated: 2026-09-10
- Page: https://skillmd.com/skills/gabeujin/legacy-sql-review

---


# Legacy SQL Review

Use this skill when reviewing SQL in legacy or enterprise systems, especially where mapper frameworks and vendor-specific database behavior matter.

## Review Priorities

1. Correctness and data integrity
2. Missing or unsafe parameter binding
3. Pagination and ordering stability
4. Performance risks such as repeated subqueries, non-sargable predicates, or unnecessary DISTINCT/UNION
5. Hard-coded locale, code, or environment assumptions
6. Maintainability and mapper readability

## Procedure

1. Identify the purpose of the query and the expected result shape.
2. Review joins, filters, grouping, and ordering for correctness.
3. Check parameter binding and dynamic SQL behavior.
4. Look for vendor-specific edge cases such as pagination, null handling, or optimizer-hostile patterns.
5. Recommend concrete rewrites or targeted experiments when the issue is not provable from static review alone.

## Output Format

- Query goal
- Findings by severity
- Performance observations
- Binding and safety observations
- Suggested rewrite or validation steps
- Test data or execution scenarios worth checking

## Rules

- Be explicit when a concern is static evidence versus execution-plan speculation.
- Prefer practical rewrites over abstract style criticism.
- Highlight missing tests for edge-case data, pagination, and empty-result behavior.

