sql-analyzer
Analyzes SQL queries for anti-patterns, performance issues, and suggests optimizations.
13 stars
Best use case
sql-analyzer is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Analyzes SQL queries for anti-patterns, performance issues, and suggests optimizations.
Teams using sql-analyzer should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
$curl -o ~/.claude/skills/sql-analyzer/SKILL.md --create-dirs "https://raw.githubusercontent.com/abdullah1854/MCPGateway/main/.agents/skills/sql-analyzer/SKILL.md"
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/sql-analyzer/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How sql-analyzer Compares
| Feature / Agent | sql-analyzer | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Analyzes SQL queries for anti-patterns, performance issues, and suggests optimizations.
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
# sql-analyzer
Analyzes SQL queries for anti-patterns, performance issues, and suggests optimizations.
## Metadata
- **Version**: 1.0.0
- **Category**: database
- **Source**: workspace
## Tags
`sql`, `database`, `performance`, `optimization`
## MCP Dependencies
None specified
## Inputs
- `query` (string) (required): SQL query to analyze
- `dialect` (string) (optional): SQL dialect: mssql, postgres, mysql
## Workflow
No workflow defined
## Anti-Hallucination Rules
None specified
## Verification Checklist
None specified
## Usage
```typescript
// Execute via MCP Gateway:
gateway_execute_skill({ name: "sql-analyzer", inputs: { ... } })
// Or via REST API:
// POST /api/code/skills/sql-analyzer/execute
// Body: { "inputs": { ... } }
```
## Code
```typescript
const { query, dialect = 'mssql' } = inputs;
const upperQuery = query.toUpperCase();
const issues = [];
// Check for SELECT *
if (/SELECT\s+\*/.test(upperQuery)) {
issues.push({ severity: 'medium', issue: 'SELECT * retrieves all columns', fix: 'List only needed columns' });
}
// Check for missing WHERE on UPDATE/DELETE
if (/(UPDATE|DELETE)\s+\w+/.test(upperQuery) && !/WHERE/.test(upperQuery)) {
issues.push({ severity: 'critical', issue: 'UPDATE/DELETE without WHERE', fix: 'Add WHERE clause' });
}
// Check for leading wildcard LIKE
if (/LIKE\s+['"]%/.test(upperQuery)) {
issues.push({ severity: 'high', issue: 'LIKE with leading wildcard prevents index usage', fix: 'Use full-text search or remove leading wildcard' });
}
// Check for ORDER BY ordinal
if (/ORDER\s+BY\s+\d+/.test(upperQuery)) {
issues.push({ severity: 'low', issue: 'ORDER BY with ordinal position', fix: 'Use column names' });
}
// Complexity score
let score = 1;
const joinCount = (upperQuery.match(/\bJOIN\b/g) || []).length;
score += joinCount * 2;
const subqueryCount = (upperQuery.match(/SELECT/g) || []).length - 1;
score += subqueryCount * 3;
let result = `# SQL Analysis\n\n`;
result += `**Complexity**: ${score < 5 ? 'Low' : score < 10 ? 'Medium' : 'High'} (${score}/10)\n\n`;
if (issues.length === 0) {
result += '✅ No significant issues found\n';
} else {
result += `## Issues (${issues.length})\n\n`;
for (const i of issues) {
const icon = i.severity === 'critical' ? '🔴' : i.severity === 'high' ? '🟡' : '🟢';
result += `${icon} **${i.severity.toUpperCase()}**: ${i.issue}\n Fix: ${i.fix}\n\n`;
}
}
console.log(result);
```
---
Created: Mon Dec 22 2025 10:35:19 GMT+0800 (Singapore Standard Time)
Updated: Mon Dec 22 2025 10:35:19 GMT+0800 (Singapore Standard Time)Related Skills
We are still matching the closest adjacent skills for this page. In the meantime, continue through the full directory.