plugins/ce/skills/writing-sql/SKILL.md
Trains Claude to write SQL at Staff+ DBA level by targeting the non-obvious patterns Claude's defaults miss. Covers multi-column statistics for correlated predicates, operator class selection for index usage, aggregate FILTER patterns, keyset pagination, and the query anti-patterns that silently destroy production performance. Use when writing complex SQL, reviewing a query for correctness or performance, adding indexes, or optimizing a slow query.
npx skillsauth add rileyhilliard/claude-essentials writing-sqlInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Core principle: Every query you write has an execution plan. Write SQL with that plan in mind, not just the result.
This skill covers only what Claude's defaults miss. Topics already handled by managing-databases/postgres-querying.md (LATERAL, CTE materialization, DISTINCT ON, EXPLAIN red flags, ROWS vs RANGE) are not repeated here.
| Task | Load | |------|------| | Planner picking bad plans on multi-column WHERE | extended-statistics.md | | LIKE search not using index, text pattern matching | index-internals.md | | Composite index column ordering, INCLUDE clause | index-internals.md | | Type mismatch between param and column silently bypassing index | index-internals.md | | Conditional aggregation, pivot queries, subtotals | aggregation-patterns.md | | GROUPING SETS, ROLLUP, CUBE | aggregation-patterns.md | | NULL edge cases in aggregates and window functions | aggregation-patterns.md | | Paginating large result sets | query-anti-patterns.md | | NOT IN returning zero rows unexpectedly | query-anti-patterns.md | | DISTINCT added to fix duplicate rows | query-anti-patterns.md | | Correlated subqueries in SELECT list | query-anti-patterns.md | | Functions in WHERE bypassing indexes | query-anti-patterns.md |
These apply to every query, no exceptions:
development
Selects and applies professional journalistic story structures (WSJ Formula, Inverted Pyramid, Hourglass, Tick-Tock, etc.) based on the content being written. Use when writing articles, blog posts, features, essays, long-form content, news stories, trend pieces, investigative reports, profiles, or any narrative prose longer than a few paragraphs. Also use when the user asks for help structuring a piece, choosing a story framework, organizing a draft, outlining an article, or wants to know which article format fits their content. Trigger on requests like "help me structure this," "what format should I use," "write a feature about," "draft a blog post on," or any mention of story structure, article architecture, or narrative frameworks. Complements the writer skill (which handles tone and anti-AI rhetoric) by providing the structural blueprint.
testing
Writing style and tone guide for human-sounding content. Use when writing documentation, READMEs, commit messages, PR descriptions, blog posts, LinkedIn posts, social media content, or any user-facing content.
data-ai
Create implementation plans with tasks grouped by subsystem. Related tasks share agent context; groups parallelize across subsystems.
development
Debugging framework that finds root causes before proposing fixes. Use when investigating bugs, errors, unexpected behavior, failed tests, or when previous fixes haven't worked.