Agent skill

sql-expert

Write, optimize, and debug T-SQL queries for Microsoft SQL Server. Covers CTEs, window functions, PIVOT, MERGE, APPLY operators, execution plan analysis, indexing strategies, and stored procedures. Use when working with SQL Server, T-SQL scripts, .sql files, stored procedures, query optimization, or database performance tuning.

Stars 232
Forks 15

Install this agent skill to your Project

npx add-skill https://github.com/aiskillstore/marketplace/tree/main/skills/hmohamed01/sql-expert

SKILL.md

SQL Expert

Expert assistance for Microsoft SQL Server and T-SQL development.

Instructions

When helping with T-SQL:

  1. Gather context first - Ask about table structures, relationships, data volumes, and SQL Server version if not provided
  2. Write for performance - Produce queries that scale, avoiding anti-patterns from the start
  3. Explain reasoning - Describe why a technique was chosen, not just how it works
  4. Present alternatives - When multiple approaches exist, explain trade-offs
  5. Handle edge cases - Consider NULLs, empty result sets, and boundary conditions
  6. Note version requirements - Flag features that require specific SQL Server versions

Core Capabilities

  • Query optimization: Execution plan analysis, index recommendations, eliminating anti-patterns
  • Advanced techniques: CTEs (recursive/non-recursive), window functions, PIVOT/UNPIVOT, MERGE, CROSS/OUTER APPLY
  • Data processing: JSON/XML handling, temporal tables, dynamic SQL
  • Stored procedures: Error handling with TRY...CATCH, transaction management, table-valued parameters

Quick Reference

Anti-Patterns to Catch

sql
-- Non-SARGable (BAD)
WHERE YEAR(date_column) = 2024
-- SARGable (GOOD)
WHERE date_column >= '2024-01-01' AND date_column < '2025-01-01'

-- Implicit conversion (BAD)
WHERE nvarchar_column = @varchar_param
-- Type match (GOOD)
WHERE nvarchar_column = @nvarchar_param

Error Handling Template

sql
BEGIN TRY
    BEGIN TRANSACTION;
    -- operations
    COMMIT TRANSACTION;
END TRY
BEGIN CATCH
    IF @@TRANCOUNT > 0 ROLLBACK TRANSACTION;
    THROW;
END CATCH;

Version-Specific Features

Feature Version
STRING_AGG, TRIM 2017+
JSON functions, STRING_SPLIT 2016+
GENERATE_SERIES, GREATEST/LEAST 2022+

Additional References

  • references/patterns.md - Query patterns and templates (CTEs, pagination, PIVOT, MERGE, window functions)
  • references/performance.md - Execution plan analysis, parameter sniffing, Query Store, wait statistics
  • references/security.md - SQL injection prevention, dynamic SQL safety, permissions, data masking
  • references/data-types.md - Type selection, collation handling, precision/scale, storage optimization
  • references/transactions.md - Isolation levels, deadlock prevention, distributed transactions, sagas

Expand your agent's capabilities with these related and highly-rated skills.

aiskillstore/marketplace

perigon-backend

Perigon ASP.NET Core + EF Core + Aspire conventions

232 15
Explore
aiskillstore/marketplace

perigon-agent

Pointers for Copilot/agents to apply Perigon conventions

232 15
Explore
aiskillstore/marketplace

perigon-angular

Angular 21+ standalone/Material/signal conventions for Perigon WebApp

232 15
Explore
aiskillstore/marketplace

fastapi-mastery

Comprehensive FastAPI development skill covering REST API creation, routing, request/response handling, validation, authentication, database integration, middleware, and deployment. Use when working with FastAPI projects, building APIs, implementing CRUD operations, setting up authentication/authorization, integrating databases (SQL/NoSQL), adding middleware, handling WebSockets, or deploying FastAPI applications. Triggered by requests involving .py files with FastAPI code, API endpoint creation, Pydantic models, or FastAPI-specific features.

232 15
Explore
aiskillstore/marketplace

context7-efficient

Token-efficient library documentation fetcher using Context7 MCP with 86.8% token savings through intelligent shell pipeline filtering. Fetches code examples, API references, and best practices for JavaScript, Python, Go, Rust, and other libraries. Use when users ask about library documentation, need code examples, want API usage patterns, are learning a new framework, need syntax reference, or troubleshooting with library-specific information. Triggers include questions like "Show me React hooks", "How do I use Prisma", "What's the Next.js routing syntax", or any request for library/framework documentation.

232 15
Explore
aiskillstore/marketplace

browser-use

Browser automation using Playwright MCP. Navigate websites, fill forms, click elements, take screenshots, and extract data. Use when tasks require web browsing, form submission, web scraping, UI testing, or any browser interaction.

232 15
Explore

Didn't find tool you were looking for?

Be as detailed as possible for better results