Optimize Query
Analyze and optimize SQL queries for performance
- Type
- Slash Command
- Repository
- jeremylongshore/tons-of-skills-marketplace
- GitHub stars
- 2.8k
- License
- MIT
- Repo last updated
- Sep 27, 2026
What Optimize Query is
Optimize Query is a slash command published in the jeremylongshore/tons-of-skills-marketplace repository on GitHub, which has about 2.8k stars. The repository describes itself as: “Model-agnostic agent-skills platform with a harness-free canonical layer, verified adapters, and the ccpi package manager. Explore at tonsofskills.com.”
A slash command is a reusable prompt saved as a markdown file and run by typing its name after a slash. In Claude Code, custom commands have been merged into skills: a file in .claude/commands/ and a skill folder in .claude/skills/ both create the same kind of command, and existing command files keep working.
Optimize Query gives you a repeatable way to run the same instructions without retyping them, optionally with arguments.
How to install Optimize Query
Claude Code
- Download optimize-query.md from the repository.
- Save it to ~/.claude/commands/ (all projects) or .claude/commands/ (one project). As a skill, you can instead save it as ~/.claude/skills/<name>/SKILL.md.
- Run it by typing / followed by its name.
Claude Cowork
- Turn the command into a skill: create a folder with the file saved as SKILL.md and zip it.
- In Customize → Skills, click +, then upload the ZIP.
- Run it from any task with / and the skill name.
New to extending Cowork? Our plugins guide and Customize guide explain how skills, plugins, and connectors fit together.
Inside the source file
An excerpt from plugins/database/sql-query-optimizer/commands/optimize-query.md, shared under the repository's MIT license. Read the full file on GitHub.
You are an SQL performance optimization expert. Analyze queries and provide optimization recommendations.
Analysis Areas
- Query Structure
- Identify N+1 queries
- Check for SELECT *
- Analyze JOIN operations
- Review subquery usage
- Detect cartesian products
- Index Recommendations
- Suggest missing indexes
- Identify unused indexes
- Composite index opportunities
- Covering indexes
- Index maintenance
- Execution Plan Analysis
- Sequential vs index scans
- Join strategies
- Sort operations
- Temporary tables
- Cost estimation
- Query Rewrite Suggestions
- Convert subqueries to JOINs
- Use EXISTS vs IN
- Optimize WHERE clauses
- Reduce column selections
- Partition pruning
Optimization Checklist
- Avoid SELECT *: Specify only needed columns
- Use EXPLAIN: Always analyze execution plans
- Index WHERE/JOIN columns: Speed up filtering and joins
- Limit result sets: Use LIMIT/TOP appropriately
- Avoid functions on indexed columns: Breaks index usage
- Use appropriate JOIN types: INNER vs LEFT vs RIGHT
- Batch operations: Reduce round trips
- Use connection pooling: Reuse connections
Output Format
For each query provide:
- Current Issues: What's slow and why
- Optimized Query: Rewritten version
- Index Recommendations: CREATE INDEX statements
- Performance Impact: Expected improvement
- Testing Strategy: How to verify improvements
Example
Original Query:
SELECT * FROM orders o
WHERE o.user_id IN (SELECT id FROM users WHERE created_at > '2024-01-01');Optimized Query:
SELECT o.id, o.user_id, o.total, o.created_at
FROM orders o
INNER JOIN users u ON o.user_id = u.id
WHERE u.created_at > '2024-01-01';Index Recommendation:
CREATE INDEX idx_users_created_at ON users(created_at);
CREATE INDEX idx_orders_user_id ON orders(user_id); Before you install
- Read the whole file first. Skills, commands, and subagents are instructions Claude will follow, so make sure they match what you want.
- Check which tools, scripts, or MCP servers it uses. Local servers and scripts run with your permissions.
- Try it in a test project or a copy of your files before pointing it at real work.
- Pin the version you tested, and review changes before updating.
- Watch for instructions that fetch web content or run shell commands; those are where prompt injection risks start. See our prompt injection guide.
FAQ
What is Optimize Query?
Optimize Query is a slash command for Claude Code and Claude Cowork from the jeremylongshore/tons-of-skills-marketplace repository on GitHub. Analyze and optimize SQL queries for performance
How do I install Optimize Query in Claude Code?
Download optimize-query.md from the repository. Save it to ~/.claude/commands/ (all projects) or .claude/commands/ (one project). As a skill, you can instead save it as ~/.claude/skills/<name>/SKILL.md. Run it by typing / followed by its name.
Can I use Optimize Query in Claude Cowork?
Turn the command into a skill: create a folder with the file saved as SKILL.md and zip it. In Customize → Skills, click +, then upload the ZIP. Run it from any task with / and the skill name.
Is Optimize Query safe to install?
It is a third-party community resource, not reviewed by Anthropic or this site. Read the source file first, check which tools and connectors it uses, and install only from sources you trust.
Similar resources
- Geepers Links Validates URLs, detects broken links, updates redirects to final destinations, and enriches resource collections with accurate descriptions. Use when checking link health in HTML/Markdown or curating a link directory. Trigger with \"check the links\", \"fix broken URLs\". Subagent · jeremylongshore/tons-of-skills-marketplace
- Geepers Orchestrator Checkpoint Coordinates the session-end hygiene suite — scout, repo cleanup, status logging, and snippet harvesting — to leave a codebase clean and documented between sessions. Use when wrapping up a session or reaching a milestone. Trigger with \"checkpoint\", \"I'm done for today\". Subagent · jeremylongshore/tons-of-skills-marketplace
- Geepers Orchestrator Corpus Coordinates corpus linguistics agents (linguistics expert, KWIC/concordance UI, database performance) for building and optimizing language corpus tools. Use when working on concordancers, frequency analyzers, or KWIC displays. Trigger with \"build a corpus feature\", \"optimize corpus queries\". Subagent · jeremylongshore/tons-of-skills-marketplace
- Geepers Orchestrator Deploy Orchestrates safe service deployments by sequencing pre-validation, Caddy route configuration, service lifecycle management, and post-deploy health checks with rollback on failure. Use when deploying a new service or changing infrastructure routing. Trigger with \"deploy this service\", \"add a Caddy route\". Subagent · jeremylongshore/tons-of-skills-marketplace
- Optimize Staking Analyze and optimize staking rewards across protocols Slash Command · jeremylongshore/tons-of-skills-marketplace
- Optimize Gas Optimize gas fees with timing and routing strategies Slash Command · jeremylongshore/tons-of-skills-marketplace
- Optimize Title A/B test video titles for maximum CTR using proven formulas and Slash Command · jeremylongshore/tons-of-skills-marketplace
- Optimize Cache Optimize caching strategies and implementation Slash Command · jeremylongshore/tons-of-skills-marketplace