Loading...
Loading...
This skill should be used when the user asks to "optimize SQL queries", "explore database schemas", "generate migration SQL", "analyze query performance", or "document database structure".
npx skill4agent add borghei/claude-skills sql-database-assistantCategory: Engineering Domain: Database Development & Optimization
# Analyze a SQL query for performance issues
python scripts/query_optimizer.py --file slow_query.sql
# Analyze inline SQL
python scripts/query_optimizer.py --query "SELECT * FROM users WHERE name LIKE '%john%'"
# Explore schema from DDL file
python scripts/schema_explorer.py --file schema.sql
# Generate migration from schema diff
python scripts/migration_generator.py --from old_schema.sql --to new_schema.sql
# JSON output
python scripts/query_optimizer.py --file query.sql --format json| Feature | Description |
|---|---|
| SELECT * detection | Flags queries selecting all columns |
| Missing index hints | Identifies WHERE/JOIN columns likely needing indexes |
| N+1 detection | Flags correlated subquery patterns |
| Full table scan | Detects queries without WHERE clauses on large tables |
| JOIN analysis | Checks join conditions and types |
| LIKE optimization | Flags leading wildcard LIKE patterns |
| Feature | Description |
|---|---|
| Table catalog | Lists all tables with column counts |
| Column details | Documents types, nullability, defaults |
| Index listing | Catalogs indexes and their columns |
| Relationship mapping | Identifies foreign key relationships |
| Markdown output | Generates schema documentation |
| Feature | Description |
|---|---|
| Column additions | ALTER TABLE ADD COLUMN for new columns |
| Column removals | ALTER TABLE DROP COLUMN for removed columns |
| Type changes | ALTER TABLE ALTER COLUMN for type modifications |
| New tables | CREATE TABLE for entirely new tables |
| Dropped tables | DROP TABLE for removed tables |
| Index changes | CREATE/DROP INDEX for index differences |
# Lint SQL queries
python scripts/query_optimizer.py --file queries/ --format json --strict
# Generate schema docs
python scripts/schema_explorer.py --file schema.sql --format markdown > SCHEMA.md| Pattern | Issue | Fix |
|---|---|---|
| Fetches unnecessary data | List specific columns |
| Cannot use index | Use full-text search |
| Correlated subquery | N+1 query pattern | Rewrite as JOIN |
| No WHERE clause | Full table scan | Add filtering conditions |
| Poor index usage | Use UNION or IN |
| Functions on indexed columns | Prevents index use | Apply to value side |
| Query Pattern | Index Type |
|---|---|
| B-tree on col |
| Composite (col1, col2) |
| B-tree on col |
| B-tree on col |
| B-tree on col |
| Full-text search | Full-text index |