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.
Optimize SQL query performance through EXPLAIN analysis, indexing strategies, and query rewriting for PostgreSQL, MySQL, and SQL Server.
$ npx skills add ancoleman/ai-design-components --skill optimizing-sql -a claude-codeProject install by default; add -g for ~/.claude/skills/.
$ gh skill install ancoleman/ai-design-components optimizing-sql --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/ancoleman/ai-design-components.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skills/optimizing-sql .claude/skills/optimizing-sql && 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 "optimizing-sql" agent skill from https://github.com/ancoleman/ai-design-components/tree/main/skills/optimizing-sql into .claude/skills/optimizing-sql/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "optimizing-sql", 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/ancoleman/ai-design-components/tree/main/skills/optimizing-sqlType 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 ancoleman/ai-design-components --skill optimizing-sql -a codexProject install goes to .agents/skills/; add -g for ~/.codex/skills/.
$ gh skill install ancoleman/ai-design-components optimizing-sql --agent codexProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/ancoleman/ai-design-components.git skills-src && mkdir -p .agents/skills && cp -r skills-src/skills/optimizing-sql .agents/skills/optimizing-sql && rm -rf skills-srcUse ~/.agents/skills/ instead of .agents/skills for a personal install.
Codex skills documentation · loads skills from .agents/skills/
Install the "optimizing-sql" agent skill from https://github.com/ancoleman/ai-design-components/tree/main/skills/optimizing-sql into .agents/skills/optimizing-sql/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "optimizing-sql", 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 ancoleman/ai-design-components --skill optimizing-sql -a cursorProject install goes to .agents/skills/; add -g for ~/.cursor/skills/.
$ gh skill install ancoleman/ai-design-components optimizing-sql --agent cursorProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/ancoleman/ai-design-components.git skills-src && mkdir -p .cursor/skills && cp -r skills-src/skills/optimizing-sql .cursor/skills/optimizing-sql && 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 "optimizing-sql" agent skill from https://github.com/ancoleman/ai-design-components/tree/main/skills/optimizing-sql into .cursor/skills/optimizing-sql/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "optimizing-sql", 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/ancoleman/ai-design-components.git --path skills/optimizing-sql--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 ancoleman/ai-design-components --skill optimizing-sql -a gemini-cliProject install goes to .agents/skills/; add -g for ~/.gemini/skills/.
$ gh skill install ancoleman/ai-design-components optimizing-sql --agent gemini-cliProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/ancoleman/ai-design-components.git skills-src && mkdir -p .gemini/skills && cp -r skills-src/skills/optimizing-sql .gemini/skills/optimizing-sql && 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 "optimizing-sql" agent skill from https://github.com/ancoleman/ai-design-components/tree/main/skills/optimizing-sql into .gemini/skills/optimizing-sql/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "optimizing-sql", 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 ancoleman/ai-design-components optimizing-sqlInstalls 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 ancoleman/ai-design-components --skill optimizing-sql -a github-copilotProject install goes to .agents/skills/; add -g for ~/.copilot/skills/.
$ git clone --depth 1 https://github.com/ancoleman/ai-design-components.git skills-src && mkdir -p .github/skills && cp -r skills-src/skills/optimizing-sql .github/skills/optimizing-sql && 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 "optimizing-sql" agent skill from https://github.com/ancoleman/ai-design-components/tree/main/skills/optimizing-sql into .github/skills/optimizing-sql/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "optimizing-sql", 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 ancoleman/ai-design-components --skill optimizing-sql -a opencodeOpenCode documents no install command of its own. Project install goes to .agents/skills/; add -g for ~/.config/opencode/skills/.
$ gh skill install ancoleman/ai-design-components optimizing-sql --agent opencodeProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/ancoleman/ai-design-components.git skills-src && mkdir -p .opencode/skills && cp -r skills-src/skills/optimizing-sql .opencode/skills/optimizing-sql && 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 "optimizing-sql" agent skill from https://github.com/ancoleman/ai-design-components/tree/main/skills/optimizing-sql into .opencode/skills/optimizing-sql/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "optimizing-sql", 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.
optimizing-sqlOptimize SQL query performance through EXPLAIN analysis, indexing strategies, and query rewriting for PostgreSQL, MySQL, and SQL Server.
Optimizing SQL is an agent skill from ancoleman/ai-design-components. Optimize SQL query performance through EXPLAIN analysis, indexing strategies, and query rewriting for PostgreSQL, MySQL, and SQL Server. Use when debugging slow queries, analyzing execution plans, or improving database performance.
Its SKILL.md is about 3k tokens, which your agent loads only when the skill is triggered. The skill folder holds 15 other files, including reference files (for example `outputs.yaml`, `references/anti-patterns.md` and `references/composite-indexes.md`).
It sits in Databases, covering SQL and Query optimization. It works with SQL, Microsoft SQL Server, MySQL and PostgreSQL. The repository describes itself as: Comprehensive UI/UX and Backend component design skills for AI-assisted development with Claude. The licence is MIT.
5 steps, taken from the step headings in SKILL.md.
Read from SKILL.md and the folder at commit 76551b7. 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.
No scripts in the folder and no shell commands in SKILL.md (its code samples are sql).
From 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.
Optimizing SQL loads about 3k tokens when it runs, and up to ~33k if it reads all its reference files. Until then it costs about 62 tokens; SKILL.md has 905 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); files beside SKILL.md are not scanned.
The full file from ancoleman/ai-design-components at commit 76551b7, republished under its MIT licence (© ancoleman). 905 words, ~2,962 tokens.
.claude/skills/optimizing-sql/SKILL.md (or your agent's skills folder). This skill also uses 13 other files; get the full folder from GitHub.Provide tactical guidance for optimizing SQL query performance across PostgreSQL, MySQL, and SQL Server through execution plan analysis, strategic indexing, and query rewriting.
Trigger this skill when encountering:
Run execution plan analysis to identify bottlenecks:
PostgreSQL:
EXPLAIN ANALYZE SELECT * FROM users WHERE email = 'user@example.com';MySQL:
EXPLAIN FORMAT=JSON SELECT * FROM products WHERE category_id = 5;SQL Server: Use SQL Server Management Studio: Display Estimated Execution Plan (Ctrl+L)
Key Metrics to Monitor:
For detailed execution plan interpretation, see references/explain-guide.md.
Common Red Flags:
| Indicator | Problem | Solution |
|---|---|---|
| Seq Scan / Table Scan | Full table scan on large table | Add index on filter columns |
| High row count | Processing excessive rows | Add WHERE filter or index |
| Nested Loop with large outer table | Inefficient join algorithm | Index join columns |
| Correlated subquery | Subquery executes per row | Rewrite as JOIN or EXISTS |
| Sort operation on large result set | Expensive sorting | Add index matching ORDER BY |
For scan type interpretation, see references/scan-types.md.
Index Decision Framework:
Is column used in WHERE, JOIN, ORDER BY, or GROUP BY?
├─ YES → Is column selective (many unique values)?
│ ├─ YES → Is table frequently queried?
│ │ ├─ YES → ADD INDEX
│ │ └─ NO → Consider based on query frequency
│ └─ NO (low selectivity) → Skip index
└─ NO → Skip indexIndex Types by Use Case:
PostgreSQL:
MySQL:
SQL Server:
For comprehensive indexing guidance, see references/indexing-decisions.md and references/index-types.md.
For queries filtering on multiple columns, use composite indexes:
Column Order Matters:
Example:
-- Query pattern
SELECT * FROM orders
WHERE customer_id = 123 AND status = 'shipped'
ORDER BY created_at DESC
LIMIT 10;
-- Optimal composite index
CREATE INDEX idx_orders_customer_status_created
ON orders (customer_id, status, created_at DESC);For composite index design patterns, see references/composite-indexes.md.
Common Anti-Patterns to Avoid:
1. SELECT * (Over-fetching)
-- ❌ Bad: Fetches all columns
SELECT * FROM users WHERE id = 1;
-- ✅ Good: Fetch only needed columns
SELECT id, name, email FROM users WHERE id = 1;2. N+1 Queries
-- ❌ Bad: 1 + N queries
SELECT * FROM users LIMIT 100;
-- Then in loop: SELECT * FROM posts WHERE user_id = ?;
-- ✅ Good: Single JOIN
SELECT users.*, posts.id AS post_id, posts.title
FROM users
LEFT JOIN posts ON users.id = posts.user_id;3. Non-Sargable Queries (functions on indexed columns)
-- ❌ Bad: Function prevents index usage
SELECT * FROM orders WHERE YEAR(created_at) = 2025;
-- ✅ Good: Sargable range condition
SELECT * FROM orders
WHERE created_at >= '2025-01-01' AND created_at < '2026-01-01';4. Correlated Subqueries
-- ❌ Bad: Subquery executes per row
SELECT name,
(SELECT COUNT(*) FROM orders WHERE orders.user_id = users.id)
FROM users;
-- ✅ Good: JOIN with GROUP BY
SELECT users.name, COUNT(orders.id) AS order_count
FROM users
LEFT JOIN orders ON users.id = orders.user_id
GROUP BY users.id, users.name;For complete anti-pattern reference, see references/anti-patterns.md.
For efficient query patterns, see references/efficient-patterns.md.
| Query Pattern | Index Type | Example |
|---|---|---|
WHERE column = value | Single-column B-tree | CREATE INDEX ON table (column) |
WHERE col1 = ? AND col2 = ? | Composite B-tree | CREATE INDEX ON table (col1, col2) |
WHERE text_col LIKE '%word%' | Full-text (GIN/Full-text) | CREATE INDEX ON table USING GIN (to_tsvector('english', text_col)) |
WHERE geom && box | Spatial (GiST) | CREATE INDEX ON table USING GIST (geom) |
WHERE json_col @> '{"key":"value"}' | JSONB (GIN) | CREATE INDEX ON table USING GIN (json_col) |
| Scan Type | Performance | When Acceptable |
|---|---|---|
| Index-Only Scan | Best | Always preferred |
| Index Scan | Excellent | Small-medium result sets |
| Bitmap Heap Scan | Good | Medium result sets (PostgreSQL) |
| Sequential Scan | Poor | Only for small tables (<1000 rows) or full table queries |
| Table Scan | Poor | Only for small tables or unavoidable full scans |
Partial Indexes (index subset of rows):
CREATE INDEX idx_active_users_login
ON users (last_login)
WHERE status = 'active';Expression Indexes (index computed values):
CREATE INDEX idx_users_email_lower
ON users (LOWER(email));Covering Indexes (avoid heap access):
CREATE INDEX idx_users_email_covering
ON users (email) INCLUDE (id, name);For comprehensive PostgreSQL optimization, see references/postgresql.md.
Index Hints (override optimizer):
SELECT * FROM orders USE INDEX (idx_orders_customer)
WHERE customer_id = 123;Storage Engine Selection:
For comprehensive MySQL optimization, see references/mysql.md.
Query Store (track query performance over time):
ALTER DATABASE YourDatabase SET QUERY_STORE = ON;Execution Plan Warnings:
For comprehensive SQL Server optimization, see references/sqlserver.md.
Break complex queries into readable, maintainable parts:
WITH active_customers AS (
SELECT id, name FROM customers WHERE status = 'active'
),
recent_orders AS (
SELECT customer_id, COUNT(*) as order_count
FROM orders
WHERE created_at > NOW() - INTERVAL '30 days'
GROUP BY customer_id
)
SELECT ac.name, COALESCE(ro.order_count, 0) as orders
FROM active_customers ac
LEFT JOIN recent_orders ro ON ac.id = ro.customer_id;Use EXISTS for better performance with large datasets:
-- ✅ Good: EXISTS stops at first match
SELECT * FROM users
WHERE EXISTS (SELECT 1 FROM orders WHERE orders.user_id = users.id);
-- ❌ Less efficient: IN builds full list
SELECT * FROM users
WHERE id IN (SELECT user_id FROM orders);Consider denormalization when:
Denormalization Strategies:
Scenario: API endpoint taking 2 seconds to load
Step 1: Identify Slow Query
Use APM/observability tools to identify database query causing delayStep 2: Run EXPLAIN ANALYZE
EXPLAIN ANALYZE SELECT * FROM orders
WHERE customer_id = 123
ORDER BY created_at DESC
LIMIT 10;Step 3: Analyze Output
Seq Scan on orders (cost=0.00..2500.00 rows=10)
Filter: (customer_id = 123)
Rows Removed by Filter: 99990Problem: Sequential scan filtering 99,990 rows
Step 4: Add Composite Index
CREATE INDEX idx_orders_customer_created
ON orders (customer_id, created_at DESC);Step 5: Verify Improvement
EXPLAIN ANALYZE SELECT * FROM orders
WHERE customer_id = 123
ORDER BY created_at DESC
LIMIT 10;Index Scan using idx_orders_customer_created (cost=0.42..12.44 rows=10)
Index Cond: (customer_id = 123)Result: 200x faster (2000ms → 10ms)
Regular Optimization Tasks:
PostgreSQL Statistics Update:
ANALYZE table_name;MySQL Statistics Update:
ANALYZE TABLE table_name;SQL Server Statistics Update:
UPDATE STATISTICS table_name;For comprehensive documentation, reference these files:
references/explain-guide.md - Detailed EXPLAIN plan interpretationreferences/scan-types.md - Scan type meanings and performance implicationsreferences/indexing-decisions.md - When and how to add indexesreferences/index-types.md - Database-specific index typesreferences/composite-indexes.md - Multi-column index designreferences/anti-patterns.md - Common anti-patterns with solutionsreferences/efficient-patterns.md - Efficient query patternsreferences/postgresql.md - PostgreSQL-specific optimizationsreferences/mysql.md - MySQL-specific optimizationsreferences/sqlserver.md - SQL Server-specific optimizationsFor working SQL examples, see examples/ directory.
© ancoleman, 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 13 other files (references) in skills/optimizing-sql of ancoleman/ai-design-components.
Open the folder on GitHubat commit 76551b7
Optimizing SQL 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 |
|---|---|---|---|---|---|---|
| Optimizing SQL this skillancoleman/ai-design-components | 526 | — | ~3k | Automated safety check: Pass | MIT | |
| SQL ProJeffallan/claude-skills | 12k | — | ~1.3k | Automated safety check: Pass | MIT | |
| SQL Optimizationgithub/awesome-copilot | 40k | 2 repos | ~2.3k | Automated safety check: Pass | MIT | |
| Agent SQL Proxiaoyuge886/aigc | 198 | — | ~315 | Automated safety check: Pass | MIT | |
| SQL Expertaiskillstore/marketplace | 430 | — | ~3.4k | Automated safety check: Pass | None | |
| SQL MasterFerroxLabs/wayland | 608 | — | ~4k | Automated safety check: Pass | Apache-2.0 |
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.
github/awesome-copilot
Universal SQL performance optimization assistant for comprehensive query tuning, indexing strategies, and database performance analysis across all SQL databases (MySQL, PostgreSQL, SQL Server…
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.
FerroxLabs/wayland
Advanced SQL expertise including window functions, CTEs, recursive queries, query optimization with EXPLAIN plans, indexing strategies, pivot/unpivot operations, JSON operations, full-text search…
rmyndharis/antigravity-skills
SQL database migrations with zero-downtime strategies for PostgreSQL, MySQL, SQL Server
ancoleman/ai-design-components
Builds AI chat interfaces and conversational UI with streaming responses, context management, and multi-modal support.
ancoleman/ai-design-components
Builds form components and data collection interfaces including contact forms, registration flows, checkout processes, surveys, and settings pages.
ancoleman/ai-design-components
Builds tables and data grids for displaying tabular information, from simple HTML tables to complex enterprise data grids.
ancoleman/ai-design-components
Creates comprehensive dashboard and analytics interfaces that combine data visualization, KPI cards, real-time updates, and interactive layouts.
ancoleman/ai-design-components
Designs layout systems and responsive interfaces including grid systems, flexbox patterns, sidebar layouts, and responsive breakpoints.
ancoleman/ai-design-components
Displays chronological events and activity through timelines, activity feeds, Gantt charts, and calendar interfaces.
Works with
Categories
Optimize SQL query performance through EXPLAIN analysis, indexing strategies, and query rewriting for PostgreSQL, MySQL, and SQL Server. Optimizing SQL is an agent skill from ancoleman/ai-design-components. Optimize SQL query performance through EXPLAIN analysis, indexing strategies, and query rewriting for PostgreSQL, MySQL, and SQL Server.
Optimizing SQL fits situations like: debugging slow queries; analyzing execution plans; improving database performance.
Run `npx skills add ancoleman/ai-design-components --skill optimizing-sql -a claude-code`. Or copy the skill folder (skills/optimizing-sql in ancoleman/ai-design-components) into .claude/skills/optimizing-sql in your project. Claude Code loads it when a task matches its description.
Run `npx skills add ancoleman/ai-design-components --skill optimizing-sql -a codex`. Or copy the skill folder (skills/optimizing-sql in ancoleman/ai-design-components) into .agents/skills/optimizing-sql 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 ancoleman/ai-design-components --skill optimizing-sql -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/optimizing-sql, .gemini/skills/optimizing-sql, .github/skills/optimizing-sql and .opencode/skills/optimizing-sql in your project.
SKILL.md names no scripts, command-line tools or credentials: Optimizing SQL is instructions for the agent only.
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. Review the folder before installing.
Optimizing SQL is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.
About 3k tokens (SKILL.md is roughly 12k 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 30k tokens, read only when the agent opens those files.
Skills that share tags, products or a category with Optimizing SQL: SQL Pro (Jeffallan/claude-skills, 12k stars), SQL Optimization (github/awesome-copilot, 40k stars), Agent SQL Pro (xiaoyuge886/aigc, 198 stars) and SQL Expert (aiskillstore/marketplace, 430 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.
ancoleman (a GitHub user) maintains it in ancoleman/ai-design-components, which has 526 GitHub stars. The repository holds 75 skills in this directory. The repository was last updated on December 11, 2025.
Source: ancoleman/ai-design-components on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.