Koskamo

Fix and optimize failing SQL queries

The agent identifies errors in a provided SQL statement, corrects the syntax, and provides optimization hints or index suggestions for better performance.

How it works

Read-onlySoftware development

The agent takes a failing SQL query and its associated error message from the user. It uses the fix_sql tool to generate a corrected statement and an explanation of the error. Optionally, it can use optimize_sql to analyze the query for performance issues, providing reasoning and index hints to improve execution speed.

Prompt

Paste this into an agent that has the servers below connected. Adjust the names and dates to your own.

Prompt for Fix and optimize failing SQL queries
Fix this failing query: [paste query and error]. Then, optimize it for better performance.

MCP servers it needs

Source

The vendor page this playbook is drawn from, and the passage that supports it.

fix_sql — Paste a failing query and its error; get the corrected statement and why it broke. optimize_sql — Slow query in, faster query out, with the reasoning and index hints.
Text-to-SQL MCP Server for Postgres, MySQL & SQL Server | AI2SQL

Each playbook is drawn from the vendor page it cites and reviewed by Koskamo before it is published. Koskamo does not run these servers or your agent: check what each tool will do before you let it act on your accounts.