/optimize-query
Analyze and optimize a slow SQL query for better performance.
$ npx -y skills add rohitg00/awesome-claude-code-toolkit --agent claude-codeHow it fires
How this command gets triggered: by you, by Claude, or both.
- Fires itselfClaude auto-loads it when your prompt matches the work.
- You can call itInvoke it directly when you want it.
- Slash command
/optimize-query
Context preview
What this command does when you run it.
Analyze and optimize a slow SQL query for better performance.
Command definition
optimize-query.md/optimize-query - Optimize SQL Query
Analyze and optimize a slow SQL query for better performance.
Steps
1. Read the SQL query provided by the user or from a slow query log 2. Parse the query to understand: tables, joins, conditions, aggregations, sorting 3. Run EXPLAIN ANALYZE to get the current execution plan 4. Identify performance bottlenecks: full table scans, nested loops, sort operations 5. Check if appropriate indexes exist for WHERE, JOIN, and ORDER BY columns 6. Suggest index additions that would improve the query execution plan 7. Rewrite the query to eliminate N+1 patterns, unnecessary subqueries, or redundant joins 8. Replace correlated subqueries with JOINs or CTEs where beneficial 9. Add query hints or optimizer directives if needed for the specific database 10. Run EXPLAIN ANALYZE on the optimized query and compare execution times 11. Present a before/after comparison: execution plan, estimated rows, actual time 12. Provide the optimized query with inline comments explaining each change
Rules
- Always show the EXPLAIN output before and after optimization
- Prefer index-based solutions over query rewrites when possible
- Do not add indexes without considering write performance impact
- Consider the data distribution when recommending indexes
- Test optimizations with production-like data volumes
- Preserve the exact result set; optimization must not change query results
- Warn about queries that may perform differently with larger datasets
Read more
/optimize-query - Optimize SQL Query
Analyze and optimize a slow SQL query for better performance.
Steps
1. Read the SQL query provided by the user or from a slow query log 2. Parse the query to understand: tables, joins, conditions, aggregations, sorting 3. Run EXPLAIN ANALYZE to get the current execution plan 4. Identify performance bottlenecks: full table scans, nested loops, sort operations 5. Check if appropriate indexes exist for WHERE, JOIN, and ORDER BY columns 6. Suggest index additions that would improve the query execution plan 7. Rewrite the query to eliminate N+1 patterns, unnecessary subqueries, or redundant joins 8. Replace correlated subqueries with JOINs or CTEs where beneficial 9. Add query hints or optimizer directives if needed for the specific database 10. Run EXPLAIN ANALYZE on the optimized query and compare execution times 11. Present a before/after comparison: execution plan, estimated rows, actual time 12. Provide the optimized query with inline comments explaining each change
Rules
- Always show the EXPLAIN output before and after optimization
- Prefer index-based solutions over query rewrites when possible
- Do not add indexes without considering write performance impact
- Consider the data distribution when recommending indexes
- Test optimizations with production-like data volumes
- Preserve the exact result set; optimization must not change query results
- Warn about queries that may perform differently with larger datasets
The most comprehensive toolkit for Claude Code -- 135 agents, 35 curated skills (+400,000 via SkillKit), 42 commands, 176+ plugins, 20 hooks, 15 rules, 7 templates, 15 MCP configs, 26 companion apps, 53 ecosystem entries, and more.
Repo: rohitg00/awesome-claude-code-toolkit
Other commands on rohitg00-claude-code-toolkit.
- /adr
Write an Architecture Decision Record documenting a significant technical decision.
Open command - /design-review
Conduct a structured design review of a module, feature, or system component.
Open command - /diagram
Generate Mermaid diagrams from codebase analysis or description.
Open command - /migrate
Plan and execute a framework or library migration incrementally.
Open command - /plan
Create a structured implementation plan for the requested feature or change.
Open command - /refactor
Perform a systematic refactoring of the specified code area.
Open command

