Agent skill

SQL Database Assistant

by borghei in borghei/Claude-Skills

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".

MITAuto-check passedDatabases

Install SQL Database Assistant

skills CLI
$ npx skills add borghei/Claude-Skills --skill sql-database-assistant -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install borghei/Claude-Skills sql-database-assistant --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/borghei/Claude-Skills.git skills-src && mkdir -p .claude/skills && cp -r skills-src/engineering/sql-database-assistant .claude/skills/sql-database-assistant && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
sql-database-assistant
GitHub stars
874
Token cost
~1.5k tokens
SKILL.md length
573 words
Files
7 (incl. scripts, references)
Skills in repo
364
Repo updated
First seen
Licence
MIT

At a glance

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".

  • Works in 5 steps: Identify slow queries - Collect queries… → Analyze - Run query_optimizer.py on each… → Review findings - Prioritize by… → …
  • Asks to optimize SQL queries
  • SKILL.md covers Overview, Clarify First, Quick Start and Tools Overview, plus 3 more sections
  • Runs Python scripts from its folder; calls python

What it does

SQL Database Assistant is an agent skill from borghei/Claude-Skills. 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".

Its SKILL.md is about 1.5k tokens, which your agent loads only when the skill is triggered. The skill folder holds 9 other files, including scripts and reference files (for example `references/sql-optimization.md`, `scripts/migration_generator.py` and `scripts/query_optimizer.py`).

It sits in Databases, covering SQL, Query optimization and Database schema design. It works with SQL. The repository describes itself as: 385 AI skills, 77 expert agents, and 900 stdlib Python tools for every team: engineering, PM, marketing, C-level, compliance, business ops, research, and a LinkedIn toolkit… The licence is MIT.

When your agent uses it

  • Asks to optimize SQL queries
  • Explore database schemas
  • Generate migration SQL
  • Analyze query performance

Example prompts

  • “optimize SQL queries”
  • “explore database schemas”
  • “generate migration SQL”
  • “/sql-database-assistant”

Requirements

  • Python 3

Workflow steps

5 steps, taken from the first numbered list in SKILL.md.

  1. Identify slow queries - Collect queries from slow query log
  2. Analyze - Run query_optimizer.py on each query
  3. Review findings - Prioritize by estimated impact
  4. Optimize - Apply suggested improvements
  5. Verify - Re-analyze to confirm optimization

What it can do on your machine

Read from SKILL.md and the folder at commit c9a1487. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Ships 3 files in scripts/ (Python), which the agent can run.

    Shell commands in SKILL.md call:

    • python

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

SQL Database Assistant loads about 1.5k tokens when it runs, and up to ~2.5k if it reads all its reference files. Until then it costs about 53 tokens; SKILL.md has 573 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~53
When it runs · the whole SKILL.md, loaded when a task matches
~1.5k
With references · SKILL.md plus every file in references/, read only if the agent opens them
~2.5k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); the scripts in this folder are not scanned.

SKILL.md

The full file from borghei/Claude-Skills at commit c9a1487, republished under its MIT licence (© borghei). 573 words, ~1,462 tokens.

Download SKILL.mdSave it as .claude/skills/sql-database-assistant/SKILL.md (or your agent's skills folder). This skill also uses 6 other files; get the full folder from GitHub.
name
sql-database-assistant
description
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".
license
MIT + Commons Clause
metadata.version
1.0.0
metadata.author
borghei
metadata.category
engineering
metadata.domain
databases
metadata.updated
2026-04-02
metadata.tags
sql, database, optimization, migration, schema

SQL Database Assistant

Category: Engineering Domain: Database Development & Optimization

Overview

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.

Clarify First

Before analyzing or generating, confirm these inputs. If any is unknown or vague, ASK — do not assume:

  • Task — query optimization / schema documentation / migration generation (selects the script)
  • SQL input — the query, the DDL file, or the from/to schema pair to operate on (the script's actual input)
  • Target database / dialect — Postgres / MySQL / etc. (changes index recommendations and migration SQL syntax)

Stop rule: ask only the 2-3 that most change the output. If the user says "just draft it," proceed and list your assumptions at the top of the artifact.

Quick Start

bash
# 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

Tools Overview

query_optimizer.py

Analyzes SQL queries for performance issues and optimization opportunities.

FeatureDescription
SELECT * detectionFlags queries selecting all columns
Missing index hintsIdentifies WHERE/JOIN columns likely needing indexes
N+1 detectionFlags correlated subquery patterns
Full table scanDetects queries without WHERE clauses on large tables
JOIN analysisChecks join conditions and types
LIKE optimizationFlags leading wildcard LIKE patterns
schema_explorer.py

Generates documentation from SQL DDL (CREATE TABLE) files.

FeatureDescription
Table catalogLists all tables with column counts
Column detailsDocuments types, nullability, defaults
Index listingCatalogs indexes and their columns
Relationship mappingIdentifies foreign key relationships
Markdown outputGenerates schema documentation
migration_generator.py

Generates migration SQL by comparing two schema DDL files.

FeatureDescription
Column additionsALTER TABLE ADD COLUMN for new columns
Column removalsALTER TABLE DROP COLUMN for removed columns
Type changesALTER TABLE ALTER COLUMN for type modifications
New tablesCREATE TABLE for entirely new tables
Dropped tablesDROP TABLE for removed tables
Index changesCREATE/DROP INDEX for index differences

Workflows

Query Optimization Workflow
  1. Identify slow queries - Collect queries from slow query log
  2. Analyze - Run query_optimizer.py on each query
  3. Review findings - Prioritize by estimated impact
  4. Optimize - Apply suggested improvements
  5. Verify - Re-analyze to confirm optimization
Show full SKILL.md (228 more words)Show less
Schema Documentation Workflow
  1. Export DDL - Dump schema from database
  2. Explore - Run schema_explorer.py to generate docs
  3. Review - Check relationships and data types
  4. Publish - Include in project documentation
Migration Workflow
  1. Capture current - Export current schema DDL
  2. Define target - Write desired schema DDL
  3. Generate migration - Run migration_generator.py
  4. Review SQL - Check generated migration for safety
  5. Test - Apply to staging database first
  6. Deploy - Apply to production with rollback plan
CI Integration
bash
# 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

Reference Documentation

Common Patterns Quick Reference

Query Anti-Patterns
PatternIssueFix
SELECT *Fetches unnecessary dataList specific columns
LIKE '%term%'Cannot use indexUse full-text search
Correlated subqueryN+1 query patternRewrite as JOIN
No WHERE clauseFull table scanAdd filtering conditions
OR in WHEREPoor index usageUse UNION or IN
Functions on indexed columnsPrevents index useApply to value side
Index Guidelines
Query PatternIndex Type
WHERE col = valueB-tree on col
WHERE col1 = v AND col2 = vComposite (col1, col2)
ORDER BY colB-tree on col
WHERE col LIKE 'prefix%'B-tree on col
WHERE col IN (...)B-tree on col
Full-text searchFull-text index
Migration Safety
  • Always generate rollback SQL alongside forward migration
  • Test migrations against a copy of production data
  • Add columns as nullable first, then backfill, then add constraints
  • Never rename columns directly; add new, migrate data, drop old

© borghei, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 6 other files (scripts, references) in engineering/sql-database-assistant of borghei/Claude-Skills.

  • SKILL.md
  • examples/queries.sql
  • examples/schema.sql
  • references/sql-optimization.md
  • scripts/migration_generator.py
  • scripts/query_optimizer.py
  • scripts/schema_explorer.py

Open the folder on GitHubat commit c9a1487

Compare with similar skills

SQL Database Assistant next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

SQL Database Assistant compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
SQL Database Assistant this skillborghei/Claude-Skills874—~1.5kAutomated safety check: PassMIT
SQL Optimization Patternsynulihao/AgentSkillOS61710 repos~3.3kAutomated safety check: PassNone
SQL Optimization InterviewerPrepLabsAI/InterviewMentor112—~2.1kAutomated safety check: PassMIT
SQL ProJeffallan/claude-skills12k—~1.3kAutomated safety check: PassMIT
Discover Databaserand/cc-polymath181—~2kAutomated safety check: PassMIT
Agent SQL Proxiaoyuge886/aigc198—~315Automated safety check: PassMIT

Similar skills

  • SQL Optimization Patterns

    ynulihao/AgentSkillOS

    Master SQL query optimization, indexing strategies, and EXPLAIN analysis to dramatically improve database performance and eliminate slow queries.

    617 GitHub starsUsed in 10 repos~3.3k tokens
    DatabasesAuto-check passed
  • SQL Optimization Interviewer

    PrepLabsAI/InterviewMentor

    A Data Engineering interviewer focused on database performance.

    112 GitHub stars~2.1k tokensUpdated today
    DatabasesAuto-check passed
  • SQL Pro

    Jeffallan/claude-skills

    Optimizes SQL queries and designs schemas using CTEs, window functions, covering indexes and EXPLAIN ANALYZE, with notes on dialect differences between major databases.

    12k GitHub stars~1.3k tokensUpdated 4 days ago
    DatabasesAuto-check passed
  • Discover Database

    rand/cc-polymath

    Automatically discover database skills when working with SQL, PostgreSQL, MongoDB, Redis, database schema design, query optimization, migrations, connection pooling, ORMs, or database selection.

    181 GitHub stars~2k tokensUpdated 7 mo ago
    DatabasesAuto-check passed
  • Agent SQL Pro

    xiaoyuge886/aigc

    Expert SQL developer specializing in complex query optimization, database design, and performance tuning across PostgreSQL, MySQL, SQL Server, and Oracle.

    198 GitHub stars~315 tokensUpdated 2 mo ago
    DatabasesAuto-check passed
  • SQL Expert

    aiskillstore/marketplace

    Expert SQL query writing, optimization, and database schema design with support for PostgreSQL, MySQL, SQLite, and SQL Server.

    430 GitHub stars~3.4k tokensUpdated today
    DatabasesAuto-check passed

More from borghei/Claude-Skills

All 364 skills in this repo
  • Agents In The Team

    borghei/Claude-Skills

    Run delivery when AI coding and ops agents take tickets. An agent skill from borghei/Claude-Skills.

    874 GitHub stars~4.2k tokensUpdated today
    Auto-check passed
  • AI Content Disclosure

    borghei/Claude-Skills

    Check AI-generated marketing content and reviews for required disclosures under the EU AI Act, FTC rules and platform AI-label policies.

    874 GitHub stars~3.4k tokensUpdated today
    Auto-check passed
  • AI Prototyping

    borghei/Claude-Skills

    Idea to AI-generated prototype to customer validation to engineering handoff.

    874 GitHub stars~3.6k tokensUpdated today
    Auto-check passed
  • Analytics Engineer

    borghei/Claude-Skills

    Analytics engineering across data modeling, dbt, transformation, and semantic layers.

    874 GitHub stars~3.4k tokensUpdated today
    Auto-check passed
  • Ansoff Matrix

    borghei/Claude-Skills

    Ansoff Matrix — 4-quadrant framework for growth options: market penetration, market/product development, and diversification.

    874 GitHub stars~2.2k tokensUpdated today
    Auto-check passed
  • Brainstorm Okrs

    borghei/Claude-Skills

    OKR brainstorming and validation using the Radical Focus framework — outcome objectives, measurable key results, counter-metrics.

    874 GitHub stars~1.4k tokensUpdated today
    Auto-check passed

Works with

Categories

Questions about SQL Database Assistant

What does SQL Database Assistant do?

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". SQL Database Assistant is an agent skill from borghei/Claude-Skills. 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".

When should I use SQL Database Assistant?

SQL Database Assistant fits situations like: asks to optimize SQL queries; explore database schemas; generate migration SQL; analyze query performance.

How do I install SQL Database Assistant in Claude Code?

Run `npx skills add borghei/Claude-Skills --skill sql-database-assistant -a claude-code`. Or copy the skill folder (engineering/sql-database-assistant in borghei/Claude-Skills) into .claude/skills/sql-database-assistant in your project. Claude Code loads it when a task matches its description.

How do I install SQL Database Assistant in Codex?

Run `npx skills add borghei/Claude-Skills --skill sql-database-assistant -a codex`. Or copy the skill folder (engineering/sql-database-assistant in borghei/Claude-Skills) into .agents/skills/sql-database-assistant in your project. Codex loads it when a task matches its description.

Can I use SQL Database Assistant in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add borghei/Claude-Skills --skill sql-database-assistant -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/sql-database-assistant, .gemini/skills/sql-database-assistant, .github/skills/sql-database-assistant and .opencode/skills/sql-database-assistant in your project.

What does SQL Database Assistant need to run?

Going by SKILL.md and its folder, SQL Database Assistant needs Python for the scripts in its folder and the command-line tools its instructions call (python). Our summary lists: Python 3.

Does SQL Database Assistant access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is SQL Database Assistant safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. The check reads SKILL.md only: the scripts in the folder are not scanned, so read them before running anything.

What licence does SQL Database Assistant use?

SQL Database Assistant is published under the MIT licence (declared in SKILL.md). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does SQL Database Assistant use?

About 1.5k tokens (SKILL.md is roughly 5.8k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full. Its references folder adds about 1k tokens, read only when the agent opens those files.

What are the alternatives to SQL Database Assistant?

Skills that share tags, products or a category with SQL Database Assistant: SQL Optimization Patterns (ynulihao/AgentSkillOS, 617 stars), SQL Optimization Interviewer (PrepLabsAI/InterviewMentor, 112 stars), SQL Pro (Jeffallan/claude-skills, 12k stars) and Discover Database (rand/cc-polymath, 181 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains SQL Database Assistant?

borghei (a GitHub user) maintains it in borghei/Claude-Skills, which has 874 GitHub stars. The repository holds 364 skills in this directory. The repository was last updated on October 7, 2026.

Source: borghei/Claude-Skills on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.