/engineering-advanced-skills:sql-database-assistantfrom engineering-advanced-skills
Reviews SQL queries for index and scan problems, documents schemas from DDL, and generates migrations with rollback and destructive-change flags.
Ships in engineering-advanced-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
Category: Engineering Domain: Database Development & Optimization
The SQL Database Assistant skill provides tools for analyzing SQL query performance, exploring database schemas from DDL files, and generating migration SQL from schema differences. It helps teams write efficient queries, maintain clean schemas, and manage database evolution safely.
Before analyzing or generating, settle the inputs below. When one is missing or vague and would change the result, ask about it; when it wouldn't, use a sensible default and say which one you used.
Ask about the two or three inputs that matter most for this request, not the whole list. If the user wants a result straight away, produce it and state your assumptions at the top.
# Review a file of queries (bundled sample: 8 findings; --strict exits 1 on any finding)
python scripts/query_optimizer.py --file examples/queries.sql --strict
# Review one inline query
python scripts/query_optimizer.py --query "SELECT * FROM users WHERE name LIKE '%john%'"
# Document a schema
python scripts/schema_explorer.py --file examples/schema.sql --format markdown
# Diff two schemas: additive change exits 0, drops exit 1 until reviewed
python scripts/migration_generator.py --from examples/schema.sql --to examples/schema_additive.sql
python scripts/migration_generator.py --from examples/schema.sql --to examples/schema_v2.sql
| Tool | What it checks or produces | Key flags |
|---|---|---|
query_optimizer.py | SELECT *, leading-wildcard LIKE, missing WHERE, correlated subqueries, join and OR patterns, DISTINCT, unbounded ORDER BY, = NULL; comments are ignored | --file or --query, --format text/json, --strict |
schema_explorer.py | Table catalog, columns with types/nullability/defaults, indexes, foreign keys | --file, --format text/json/markdown |
migration_generator.py | UP and commented DOWN SQL for added/dropped tables and columns and type changes, with a destructive-change banner | --from, --to, --format, --allow-destructive |
Exit codes: 0 ok; 1 query_optimizer.py --strict found something, or
migration_generator.py produced destructive steps (drops or type changes) without
--allow-destructive; 2 bad input (file not found). Index changes are not diffed.
The optimizer reads query text only. For a real diagnosis ask for the plan
(EXPLAIN (ANALYZE, BUFFERS) in PostgreSQL, EXPLAIN ANALYZE in MySQL 8) and trust it over
the script when they disagree: look for sequential scans on large tables, row-estimate
errors and sorts or hashes spilling to disk.
[DESTRUCTIVE] step, decide how the data is preserved (backup, copy column, expand-and-contract) before passing --allow-destructive# Lint SQL queries (--file takes one file, so loop over the directory)
for f in queries/*.sql; do
python scripts/query_optimizer.py --file "$f" --format json --strict || exit 1
done
# Generate schema docs
python scripts/schema_explorer.py --file schema.sql --format markdown > SCHEMA.md
In Scope:
query_optimizer.py: SELECT *, likely index candidates, correlated subqueries, missing WHERE, join checks and leading-wildcard LIKE, with --strict for CI.schema_explorer.py: tables, columns, indexes and foreign keys, in text, JSON or Markdown.migration_generator.py, with up steps and commented rollback steps.references/sql-optimization.md.Out of Scope:
EXPLAIN or applying migrations.engineering/database-designer/).engineering/migration-architect/).engineering/snowflake-development/).Important Caveats:
ALTER COLUMN ... TYPE and need adapting for other databases.--file takes a single file, not a directory.| Pattern | Issue | Fix |
|---|---|---|
SELECT * | Fetches unnecessary data | List specific columns |
LIKE '%term%' | 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 |
OR in WHERE | Poor index usage | Use UNION or IN |
| Functions on indexed columns | Prevents index use | Apply to value side |
| Query Pattern | Index Type |
|---|---|
WHERE col = value | B-tree on col |
WHERE col1 = v AND col2 = v | Composite (col1, col2) |
ORDER BY col | B-tree on col |
WHERE col LIKE 'prefix%' | B-tree on col |
WHERE col IN (...) | B-tree on col |
| Full-text search | Full-text index |
Mistake: Running a migration that drops a column because "there is a rollback script". Why it happens: The DOWN section looks like an undo button. Instead: DOWN recreates the column empty. Copy or back up the data first, and prefer expand-and-contract (add new, backfill, switch reads, drop later).
Mistake: Creating every index the optimizer suggests. Why it happens: Each suggestion looks cheap. Instead: Indexes cost writes and storage. Confirm with the query plan and the column's selectivity, and check for an existing composite index that already covers it.
Mistake: Applying a generated drop-plus-add for what is really a renamed column.
Why it happens: A schema diff cannot tell a rename from a replacement.
Instead: Replace the pair with ALTER TABLE ... RENAME COLUMN (or a staged copy for zero downtime) before running it.
| File | Purpose |
|---|---|
scripts/query_optimizer.py | Static SQL query review |
scripts/schema_explorer.py | Schema documentation from DDL |
scripts/migration_generator.py | Schema diff to UP/DOWN migration with destructive flags |
examples/queries.sql | Queries with deliberate anti-patterns |
examples/schema.sql | Six-table e-commerce schema |
examples/schema_additive.sql, schema_v2.sql | Target schemas: additive (exit 0) and destructive (exit 1) |
references/sql-optimization.md | Index strategies, query patterns, anti-patterns |
examples/queries.sql (opens in a new tab)examples/schema.sql (opens in a new tab)examples/schema_additive.sql (opens in a new tab)examples/schema_v2.sql (opens in a new tab)references/sql-optimization.md (opens in a new tab)scripts/migration_generator.py (opens in a new tab)scripts/query_optimizer.py (opens in a new tab)scripts/schema_explorer.py (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub borghei/claude-skills --plugin engineering-advanced-skills100 skills in this plugin
/a11y-auditStatic WCAG scan of HTML files (alt text, headings, labels, ARIA, lang, landmarks) and colour contrast checks for colour pairs or CSS. Use when auditing templates for accessibility, checking contrast, or adding an a11y gate to CI.
/agent-designerDesigns multi-agent system architectures with orchestration patterns, tool schemas, and performance evaluation. Use when building AI agent systems, designing agent workflows, creating tool schemas, or evaluating agent performance.
/agent-harnessTest and evaluation harness for AI agents — scenario suites, deterministic replay, regression diffing, cost and latency budgets. Use when agent quality is vibe-checked, before shipping a prompt or model change, or when evals drift.
/agenthubRuns a multi-agent job as a dependency graph: validates the DAG, tracks each agent's state on a board, then ranks and merges their outputs. Use when spawning parallel agents, monitoring a run, or merging results.
/agentic-evaluation-frameworkBuilds LLM and agent evals: weighted rubrics, LLM-as-judge design, inter-rater agreement and pairwise ranking (Elo, Bradley-Terry) from scores you collect. Use when setting up a judge, scoring outputs, or comparing model or prompt variants.
/agent-protocolDesign AI agent communication protocols: MCP tool schemas, A2A, function calling, and inter- agent messaging. Use when building multi-agent systems, defining tool interfaces, or implementing agent-to-agent communication.
Other plugins' skills for the same job