/sqlserver-before-you-ship:before-you-shipfrom SQL Server: Before You Ship That
Checks trade-offs before shipping SQL Server code: T-SQL queries, table design, index changes. Based on Erik Darling's decision chart. Each card shows one action with costs, risks, speed, and backfire conditions.
Ships in SQL Server: Before You Ship That. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
This is the agent version of the chart at https://erikdarling.com/before-you-ship. The chart walks a developer through questions about the code they're working on, and each question leads to a card with one action and its trade-offs. The cards are in cards/, and each card's demo code and measurements are in evidence/, both next to this file.
dbo.Orders, dbo.Posts and dbo.Tasks differently, and some borrow a table from another card and say so. Cards that need StackOverflow2013 say so.Look for NOLOCK or READUNCOMMITTED table hints and SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED before anything else. Report every one first, above every other finding. If you can ask the author, ask them to take the hints out, or to confirm the dirty reads are acceptable, before you review the rest of that query. If you can't ask, review the rest with the hints still in, because until the author takes them out, that is the code that ships. For each hinted read, follow the rows to where they go next. Work out what a row read twice, a row missed, or a row that later rolls back does there: an insert into a table with a primary key or a unique index fails on the second copy, a count or a total is wrong, a wrong value gets written. Report that failure with the hint's finding. If it ends in an error, name the error. If it ends in a wrong result, name the result and how it is wrong.
What to tell the author:
NOLOCK doesn't mean the query takes no locks. It means the query ignores the locks other queries take, so it can read data that later rolls back, count rows twice, or miss them entirely.NOLOCK read decides what gets written. An UPDATE that joins to a table read WITH (NOLOCK) can copy in a value that later rolls back, and the copy stays. A NOT EXISTS check read with NOLOCK can skip an insert that needed to happen, or let a duplicate through.NOLOCK on the table an UPDATE or DELETE changes does nothing, because SQL Server ignores it there.SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED is NOLOCK on every table in every query the session runs, until something sets it back.Sources: Aaron Bertrand's Dirty Reads, Permanent Damage, and Learn T-SQL With Erik: Writing Bad Data With NOLOCK Hints, which shows the first one on video.
Scan the code for these and read the cards they point to. One statement can match several rows. The map covers what the code can't show, like how a query runs today and who depends on it.
SELECT *, or more columns than the caller uses → Ask for lessOFFSET ... FETCH, ROW_NUMBER() paging, COUNT(*) OVER () next to a page of rows → Find the page, then fetch the rowsWHERE or ON (YEAR(col), ISNULL(col, ...), COALESCE(col, ...)), LIKE '%...', a column compared to a value of another type → Filter so indexes can help youcol = @p OR @p IS NULL, one query that handles every combination of optional filters → Only search what was asked forDECLARE @x = ... followed by WHERE col = @x → Local variables hide their valuesDATEDIFF, DATEADD, CONVERT or AT TIME ZONE on a column, BETWEEN on a datetime column → Convert the search value, not the columnSTRING_SPLIT, comma-separated list parameters, table-valued parameters → Split lists into a #temp tableOR in a join's ON clause → Don't join on ORLEFT JOIN ... WHERE x.col IS NULL, NOT IN (SELECT ...) → NOT EXISTS says what you meanUNION or UNION ALL → UNION ALL isn't always fasterDECLARE @t table → Table variables don't know what's in themRETURNS @t TABLE) → Most functions hide their workAddWithValue, nvarchar parameters against varchar columns, DateTime against datetime2 → The app picks your parameter typesWITH (NOLOCK), READUNCOMMITTED, SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED: report these first, per First: NOLOCK → Readers shouldn't wait on writersBEGIN TRANSACTION and COMMIT; a modification with no index to find its rows → Locks last as long as the transactionSET IMPLICIT_TRANSACTIONS ON, INSERT ... EXEC, error paths that skip COMMIT or ROLLBACK → Transactions you didn't know you openedIF EXISTS (...) UPDATE ... ELSE INSERT, or any update-then-insert → Upserts break under concurrencyMERGE → What MERGE does better, Upserts break under concurrency, Swart's avoid listSELECT TOP (1) and then an UPDATE to claim a row, READPAST → Claim it in one statementTRY ... CATCH, XACT_ABORT, THROW, RAISERROR → Know what you'll do with the error firstCREATE TRIGGER, SELECT @id = i.id FROM inserted, writes to a table that has a trigger → Triggers fire per statement, not per rowSELECT MAX(id) after an insert, re-reading rows just written, SCOPE_IDENTITY() → Don't ask twiceSELECT list on a stored procedure or view other code reads → Mind your query consumersnvarchar(max) or varchar(max) by default, dates stored as strings, a column type that doesn't match what it's compared to → Types are a performance featureint identity on a table that could reach billions of rows, bigint on small lookup tables, an identity next to a natural key that's already narrow, unique, static and ever-increasing → Choose your clustering on purposeCREATE TABLE with no clustered index, DELETE from a heap → Heaps are for stagingGROUP BY over millions of rows → Reporting tables want columnstoreWITH NOCHECK, CHECK or DEFAULT constraints that call scalar functions, foreign key columns with no index → Constraints help the optimizerDELETE ... WHERE date_column < ... to purge or archive old rows → Move partitions, not rowsis_deleted or similar flags → Soft deletes are a filter on every queryALTER TABLE ... ADD → Some ALTERs are free. Some aren't.ALTER TABLE ... ALTER COLUMN → The most dangerous ALTERCREATE INDEX, ALTER INDEX ... REBUILD or DROP INDEX in a deploy script for a live table → Index work on a live tableORDER BY columns sitting in INCLUDE → Keys sort. Includes ride along.CREATE INDEX ... WHERE → Filtered indexes need to see the filterWHERE across two columns or inside a function, like DATEDIFF(MINUTE, opened, closed) > 1440 → Index the expression with a computed columnCREATE VIEW ... WITH SCHEMABINDING with a unique clustered index on it → Indexed views move the work to the writesCREATE INDEX with no DATA_COMPRESSION → Start with page compressionINCLUDE on a column the workload updates → The write taxDROP INDEX because usage stats say it's unused → Unused since when?, Disable, then dropOrder the findings by what they cost the user, worst first:
NOLOCK reads that decide writes, upserts and MERGE under concurrency, transactions left open, errors that leave work half done, triggers that assume one row.ALTER work on a live table.For each finding:
Keep to what the cards back. If you spot something else, list it separately and say no card covers it.
Check for NOLOCK first (see above).
cards/a-top-above-a-scan-means-a-missing-index.md (opens in a new tab)cards/an-eager-index-spool-is-an-index-you-didn-t-create.md (opens in a new tab)cards/ask-for-less.md (opens in a new tab)cards/audit-before-you-add.md (opens in a new tab)cards/choose-your-clustering-on-purpose.md (opens in a new tab)cards/claim-it-in-one-statement.md (opens in a new tab)cards/constraints-help-the-optimizer.md (opens in a new tab)cards/convert-the-search-value-not-the-column.md (opens in a new tab)cards/ctes-aren-t-temp-tables.md (opens in a new tab)cards/dev-lied-to-you.md (opens in a new tab)cards/disable-then-drop.md (opens in a new tab)cards/don-t-ask-twice.md (opens in a new tab)cards/don-t-join-on-or.md (opens in a new tab)cards/filter-so-indexes-can-help-you.md (opens in a new tab)cards/filtered-indexes-need-to-see-the-filter.md (opens in a new tab)cards/find-the-page-then-fetch-the-rows.md (opens in a new tab)cards/heaps-are-for-staging.md (opens in a new tab)cards/index-the-expression-with-a-computed-column.md (opens in a new tab)cards/index-work-on-a-live-table.md (opens in a new tab)cards/indexed-views-move-the-work-to-the-writes.md (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub erikdarlingdata/claude-plugins --plugin sqlserver-before-you-shipOther plugins' skills for the same job