sql-database-assistant
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".
What this skill does
# 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. ## 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. | 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 | ### schema_explorer.py 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 | ### migration_generator.py 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 | ## 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 ### 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 - [SQL Optimization](references/sql-optimization.md) - Index strategies, query patterns, anti-patterns ## Common Patterns Quick Reference ### Query Anti-Patterns | 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 | ### Index Guidelines | 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 | ### 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
Related in Backend & APIs
jfrog
IncludedInteract with the JFrog Platform via the JFrog CLI and REST/GraphQL APIs. Use this skill when the user wants to manage Artifactory repositories, upload or download artifacts, manage builds, configure permissions, manage users and groups, work with access tokens, configure JFrog CLI servers, search artifacts, manage properties, set up replication, manage JFrog Projects, run security audits or scans, look up CVE details, query exposures scan results from JFrog Advanced Security, manage release bundles and lifecycle operations, aggregate or export platform data, or perform any JFrog Platform administration task. Also use when the user mentions jf, jfrog, artifactory, xray, distribution, evidence, apptrust, onemodel, graphql, workers, mission control, curation, advanced security, exposures, or any JFrog product name.
cupynumeric-migration-readiness
IncludedPre-migration readiness assessor for porting NumPy to cuPyNumeric. Use BEFORE substantial porting work begins when the user asks whether code will scale on GPU, whether they should migrate to cuPyNumeric, which NumPy patterns transfer cleanly, what must be refactored before porting, or mentions pre-port assessment, scaling analysis, or refactor planning. Inspect the user's source code, look up NumPy usage, cross-reference the cuPyNumeric API support manifest, and distinguish distributed-scaling-friendly patterns from blockers such as unsupported APIs, scalar synchronization, host round-trips, Python/object-heavy control flow, shape/data-dependent branching, and in-place mutation hazards. Produce a verdict of READY, LIGHT REFACTOR, SIGNIFICANT REFACTOR, or NOT RECOMMENDED, with concrete refactor pointers.
alibabacloud-data-agent-skill
IncludedInvoke Alibaba Cloud Apsara Data Agent for Analytics via CLI to perform natural language-driven data analysis on enterprise databases. Data Agent for Analytics is an intelligent data analysis agent developed by Alibaba Cloud Database team for enterprise users. It automatically completes requirement analysis, data understanding, analysis insights, and report generation based on natural language descriptions. This tool supports: discovering data resources (instances/databases/tables) managed in DMS, initiating query or deep analysis sessions, real-time progress tracking, and retrieving analysis conclusions and generated reports. Use this Skill when users need to query databases, analyze data trends, generate data reports, ask questions in natural language, or mention "Data Agent", "data analysis", "database query", "SQL analysis", "data insights".
token-optimizer
IncludedReduce OpenClaw token usage and API costs through smart model routing, heartbeat optimization, budget tracking, and native 2026.2.15 features (session pruning, bootstrap size limits, cache TTL alignment). Use when token costs are high, API rate limits are being hit, or hosting multiple agents at scale. The 4 executable scripts (context_optimizer, model_router, heartbeat_optimizer, token_tracker) are local-only — no network requests, no subprocess calls, no system modifications. Reference files (PROVIDERS.md, config-patches.json) document optional multi-provider strategies that require external API keys and network access if you choose to use them. See SECURITY.md for full breakdown.
resend-cli
IncludedUse this skill when the task is specifically about operating Resend from an AI agent, terminal session, or CI job via the official resend CLI: installing/authenticating the CLI, sending/listing/updating/cancelling emails, batch sends, domains and DNS, webhooks and local listeners, inbound receiving, contacts, topics, segments, broadcasts, templates, API keys, profiles, or debugging Resend CLI/API failures. Trigger on mentions of Resend CLI, `resend`, `resend doctor`, `resend emails send`, `resend domains`, `resend webhooks listen`, `resend emails receiving`, or agent-friendly terminal automation.
alibabacloud-odps-maxframe-coding
IncludedUse this skill for MaxFrame SDK development and documentation navigation on Alibaba Cloud MaxCompute (ODPS). Helps answer MaxFrame API, concept, official example, and supported pandas API questions; create data processing programs; read/write MaxCompute tables; debug jobs (remote or local); and build custom DPE runtime images. Trigger when users mention MaxFrame, MaxCompute with MaxFrame, ODPS table processing, DPE runtime, MaxFrame docs/examples, DataFrame/Tensor operations, or GPU runtime setup. Works for both English and Chinese queries about Alibaba Cloud data processing with MaxFrame.