SQL Optimization Patterns
ynulihao/AgentSkillOS
Master SQL query optimization, indexing strategies, and EXPLAIN analysis to dramatically improve database performance and eliminate slow queries.
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 skills add borghei/Claude-Skills --skill sql-database-assistant -a claude-codeProject install by default; add -g for ~/.claude/skills/.
$ gh skill install borghei/Claude-Skills sql-database-assistant --agent claude-codeProject scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).
$ 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-srcUse ~/.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/
Install the "sql-database-assistant" agent skill from https://github.com/borghei/Claude-Skills/tree/main/engineering/sql-database-assistant into .claude/skills/sql-database-assistant/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "sql-database-assistant", then confirm the skill loads.Claude Code copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$skill-installer install https://github.com/borghei/Claude-Skills/tree/main/engineering/sql-database-assistantType this inside Codex. $skill-installer <name> installs a curated skill from openai/skills. The installer writes to $CODEX_HOME/skills (default ~/.codex/skills). Restart Codex if the skill does not show up.
$ npx skills add borghei/Claude-Skills --skill sql-database-assistant -a codexProject install goes to .agents/skills/; add -g for ~/.codex/skills/.
$ gh skill install borghei/Claude-Skills sql-database-assistant --agent codexProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/borghei/Claude-Skills.git skills-src && mkdir -p .agents/skills && cp -r skills-src/engineering/sql-database-assistant .agents/skills/sql-database-assistant && rm -rf skills-srcUse ~/.agents/skills/ instead of .agents/skills for a personal install.
Codex skills documentation · loads skills from .agents/skills/
Install the "sql-database-assistant" agent skill from https://github.com/borghei/Claude-Skills/tree/main/engineering/sql-database-assistant into .agents/skills/sql-database-assistant/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "sql-database-assistant", then confirm the skill loads.Codex copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ npx skills add borghei/Claude-Skills --skill sql-database-assistant -a cursorProject install goes to .agents/skills/; add -g for ~/.cursor/skills/.
$ gh skill install borghei/Claude-Skills sql-database-assistant --agent cursorProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/borghei/Claude-Skills.git skills-src && mkdir -p .cursor/skills && cp -r skills-src/engineering/sql-database-assistant .cursor/skills/sql-database-assistant && rm -rf skills-srcUse ~/.cursor/skills/ instead of .cursor/skills for a personal install.
Cursor skills documentation · loads skills from .cursor/skills/, .agents/skills/, .claude/skills/, .codex/skills/
Install the "sql-database-assistant" agent skill from https://github.com/borghei/Claude-Skills/tree/main/engineering/sql-database-assistant into .cursor/skills/sql-database-assistant/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "sql-database-assistant", then confirm the skill loads.Cursor copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ gemini skills install https://github.com/borghei/Claude-Skills.git --path engineering/sql-database-assistant--scope user (default) or --scope workspace; --path is the subfolder of the repo that holds the skill; --consent skips the security confirmation prompt.
$ npx skills add borghei/Claude-Skills --skill sql-database-assistant -a gemini-cliProject install goes to .agents/skills/; add -g for ~/.gemini/skills/.
$ gh skill install borghei/Claude-Skills sql-database-assistant --agent gemini-cliProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/borghei/Claude-Skills.git skills-src && mkdir -p .gemini/skills && cp -r skills-src/engineering/sql-database-assistant .gemini/skills/sql-database-assistant && rm -rf skills-srcUse ~/.gemini/skills/ instead of .gemini/skills for a personal install, then run /skills reload.
Gemini CLI skills documentation · loads skills from .gemini/skills/, .agents/skills/
Install the "sql-database-assistant" agent skill from https://github.com/borghei/Claude-Skills/tree/main/engineering/sql-database-assistant into .gemini/skills/sql-database-assistant/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "sql-database-assistant", then confirm the skill loads.Gemini CLI copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ gh skill install borghei/Claude-Skills sql-database-assistantInstalls for Copilot at project scope by default; add --scope user for a personal install. Preview a skill first with gh skill preview. Needs GitHub CLI 2.90.0 or later (public preview).
$ npx skills add borghei/Claude-Skills --skill sql-database-assistant -a github-copilotProject install goes to .agents/skills/; add -g for ~/.copilot/skills/.
$ git clone --depth 1 https://github.com/borghei/Claude-Skills.git skills-src && mkdir -p .github/skills && cp -r skills-src/engineering/sql-database-assistant .github/skills/sql-database-assistant && rm -rf skills-srcUse ~/.copilot/skills/ instead of .github/skills for a personal install. Commit .github/skills so cloud agent and code review can use it.
GitHub Copilot skills documentation · loads skills from .github/skills/, .claude/skills/, .agents/skills/
Install the "sql-database-assistant" agent skill from https://github.com/borghei/Claude-Skills/tree/main/engineering/sql-database-assistant into .github/skills/sql-database-assistant/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "sql-database-assistant", then confirm the skill loads.GitHub Copilot copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ npx skills add borghei/Claude-Skills --skill sql-database-assistant -a opencodeOpenCode documents no install command of its own. Project install goes to .agents/skills/; add -g for ~/.config/opencode/skills/.
$ gh skill install borghei/Claude-Skills sql-database-assistant --agent opencodeProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/borghei/Claude-Skills.git skills-src && mkdir -p .opencode/skills && cp -r skills-src/engineering/sql-database-assistant .opencode/skills/sql-database-assistant && rm -rf skills-srcUse ~/.config/opencode/skills/ instead of .opencode/skills for a personal install.
OpenCode skills documentation · loads skills from .opencode/skills/, .claude/skills/, .agents/skills/
Install the "sql-database-assistant" agent skill from https://github.com/borghei/Claude-Skills/tree/main/engineering/sql-database-assistant into .opencode/skills/sql-database-assistant/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "sql-database-assistant", then confirm the skill loads.OpenCode copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
sql-database-assistantThis 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".
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.
5 steps, taken from the first numbered list in SKILL.md.
Read from SKILL.md and the folder at commit c9a1487. It shows what the files ask for, not the result of running them.
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.
Ships 3 files in scripts/ (Python), which the agent can run.
Shell commands in SKILL.md call:
pythonFrom the folder's file list and the shell code blocks in SKILL.md.
No URLs in SKILL.md.
From URLs in SKILL.md, links to its own repository left out.
Names no API keys, tokens, secrets or passwords.
From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.
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.
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.
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.
The full file from borghei/Claude-Skills at commit c9a1487, republished under its MIT licence (© borghei). 573 words, ~1,462 tokens.
.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.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, confirm these inputs. If any is unknown or vague, ASK — do not assume:
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.
# 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 jsonAnalyzes SQL queries for performance issues and optimization opportunities.
| 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 |
Generates documentation from SQL DDL (CREATE TABLE) files.
| 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 |
Generates migration SQL by comparing two schema DDL files.
| 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 |
|---|---|---|
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 |
© borghei, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file
SKILL.md and 6 other files (scripts, references) in engineering/sql-database-assistant of borghei/Claude-Skills.
Open the folder on GitHubat commit c9a1487
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.
| Skill | Stars | Used in | Tokens | Auto-check | Licence | Repo updated |
|---|---|---|---|---|---|---|
| SQL Database Assistant this skillborghei/Claude-Skills | 874 | — | ~1.5k | Automated safety check: Pass | MIT | |
| SQL Optimization Patternsynulihao/AgentSkillOS | 617 | 10 repos | ~3.3k | Automated safety check: Pass | None | |
| SQL Optimization InterviewerPrepLabsAI/InterviewMentor | 112 | — | ~2.1k | Automated safety check: Pass | MIT | |
| SQL ProJeffallan/claude-skills | 12k | — | ~1.3k | Automated safety check: Pass | MIT | |
| Discover Databaserand/cc-polymath | 181 | — | ~2k | Automated safety check: Pass | MIT | |
| Agent SQL Proxiaoyuge886/aigc | 198 | — | ~315 | Automated safety check: Pass | MIT |
ynulihao/AgentSkillOS
Master SQL query optimization, indexing strategies, and EXPLAIN analysis to dramatically improve database performance and eliminate slow queries.
PrepLabsAI/InterviewMentor
A Data Engineering interviewer focused on database performance.
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.
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.
xiaoyuge886/aigc
Expert SQL developer specializing in complex query optimization, database design, and performance tuning across PostgreSQL, MySQL, SQL Server, and Oracle.
aiskillstore/marketplace
Expert SQL query writing, optimization, and database schema design with support for PostgreSQL, MySQL, SQLite, and SQL Server.
borghei/Claude-Skills
Run delivery when AI coding and ops agents take tickets. An agent skill from borghei/Claude-Skills.
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.
borghei/Claude-Skills
Idea to AI-generated prototype to customer validation to engineering handoff.
borghei/Claude-Skills
Analytics engineering across data modeling, dbt, transformation, and semantic layers.
borghei/Claude-Skills
Ansoff Matrix — 4-quadrant framework for growth options: market penetration, market/product development, and diversification.
borghei/Claude-Skills
OKR brainstorming and validation using the Radical Focus framework — outcome objectives, measurable key results, counter-metrics.
Works with
Categories
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".
SQL Database Assistant fits situations like: asks to optimize SQL queries; explore database schemas; generate migration SQL; analyze query performance.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.