koriym/koriym.sqlquality/sql-quality-fix
Claude Code and agent skill by koriym/koriym.sqlquality
- community
Checking that the SKILL.md file is still in the repository.
Fix MySQL performance problems in SQL files and prove each fix - rewrites are checked to return the same rows, indexes are measured as invisible indexes before anyone adds them. Use when asked to fix, optimize or speed up the SQL of a project.
Install
npx vskill@latest install koriym/koriym.sqlquality/sql-quality-fixSKILL.md
SQL Quality Fix
Fix the problems sql-quality analyze reports, one at a time, and keep only fixes the tool has verified.
Arguments
$ARGUMENTS: the SQL directory, optionally the params file, and options.
sql/ sql/params.phpsql/ sql/params.php --keep-indexes
--keep-indexes: keep the indexes try-index finds effective, in the database. Without it no index is left behind; the effective ones are reported as DDL for a migration.
Ground rules
- A rewrite is kept only when
comparesaysequivalent: truewithboth_empty: false. - An index is recommended only when
try-indexsayseffective: true. - Never run
CREATE INDEX,DROP INDEXor any other DDL yourself;try-indexadds the trial index
INVISIBLE, so no other session's plan changes, and drops it again.
- Work on a development database.
try-indexbuilds a real index: it reads the whole table.
Steps
0. Baseline
Exit 2: stop and report stderr. Files in skipped with UnboundParameter need parameters first (/sql-params-generate).
1. Rewrites
For each issue whose suggestion.kind is rewrite, or whose type is fixed by rewriting (FunctionInvalidatesIndex, ImplicitTypeConversion, OrderByRand, DeepOffset, UnnecessaryDistinct, IneffectiveUnion, DependentSubquery), write the rewritten statement and check it:
- Exit 0,
equivalent: true,both_empty: false, andsame_order: truewhen the statement has an
ORDER BY: replace the file's statement. Report cost_change_percent and issues.resolved.
both_empty: true: the parameters return no rows, so the check proves nothing. Pick parameters that
return rows (--before-params / --after-params take a JSON object) and compare again.
- Exit 1: the rows differ. Do not apply it; try another rewrite or list it for manual review.
same_order: falseon a statement with an ORDER BY: the rows come back in another order. Do not
apply it; list it for manual review. Without an ORDER BY the order is not part of the result.
A rewrite that changes column names, or a statement that depends on NOW() / RAND(), cannot pass; list it for manual review instead.
2. Indexes
For each issue with suggestion.kind index, try its suggestion.ddl against the file:
Pass --keep only with --keep-indexes. Exit 0 is effective (the plan uses the index and the cost fell at least 5%), exit 1 is not. Exit 2 with Lock wait timeout: a transaction holds the table; retry later rather than waiting it out. InvisibleIndexesPresent: the table already has an invisible index; report it and skip the trial. stderr names the DROP INDEX that removes the trial index; if a run is interrupted, run that statement before anything else. Record index.ddl, cost_change_percent and issues.resolved either way. Two suggestions for the same table: try the composite one first.
3. Verify
baseline.new must be empty; if a rewrite introduced an issue, revert it. baseline.unverified lists files that no longer analyze; revert the change that caused it.
4. Report
Write build/sql-quality/fix-report.md:
Take every number from the tool's output; do not estimate.
Security
- Security scanPassed, 90 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/sql-quality-fix/SKILL.md
Popularity
- 7-day trend score
- 0
Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/koriym/koriym.sqlquality/sql-quality-fix)