Use when writing or reviewing MSSQL/T-SQL, creating stored procedures, designing table schemas, writing views, building migrations, defining custom types, or architecting a SQL Server application database. Also use when writing RAISERROR patterns, CHECK constraints with scalar functions, base/subtype table hierarchies, composite key designs, role-scoped views with row-level security, or idempotent DDL scripts. If you are touching MSSQL for an application database, use this skill. Not for PostgreSQL, MySQL, Oracle, or SQLite — patterns are SQL Server-specific.
95
94%
Does it follow best practices?
Impact
98%
1.81xAverage score across 5 eval scenarios
Passed
No known issues
{
"context": "Tests whether the agent follows hierarchical composite key instructions: composite PKs that grow wider at each level, max-plus-one functions scoped to parent key instead of IDENTITY columns, and correct constraint predicate naming.",
"type": "weighted_checklist",
"checklist": [
{
"name": "Composite PKs grow wider per level",
"description": "Each child table's PRIMARY KEY includes all columns from the parent's PRIMARY KEY plus one new discriminator column (e.g., Client PK=(ClientNo), Case PK=(ClientNo, CaseNo), Document PK=(ClientNo, CaseNo, DocumentNo))",
"max_score": 15
},
{
"name": "No IDENTITY columns",
"description": "No table uses IDENTITY (or AUTO_INCREMENT equivalent) for any primary key column",
"max_score": 12
},
{
"name": "Max-plus-one functions exist",
"description": "Scalar functions for generating the next key value (e.g., NextCaseNo_fn, NextDocumentNo_fn) are defined — at least one per non-root level in the hierarchy",
"max_score": 12
},
{
"name": "Max-plus-one scoped to parent",
"description": "The max-plus-one functions accept the parent key as parameter(s) and compute MAX scoped to that parent (e.g., SELECT MAX(CaseNo) FROM Case WHERE ClientNo = @ClientNo)",
"max_score": 12
},
{
"name": "ISNULL default to zero",
"description": "Max-plus-one functions use ISNULL(..., 0) + 1 pattern to handle the case where no child records exist yet",
"max_score": 8
},
{
"name": "FK references full parent PK",
"description": "Each child table's FOREIGN KEY references the parent's complete composite primary key (not a subset or a surrogate)",
"max_score": 12
},
{
"name": "Predicate constraint names",
"description": "Foreign key constraints use predicate-style names describing the business relationship (e.g., Case_BelongsTo_Client, Document_IsFiledUnder_Case) — NOT FK_ prefix patterns",
"max_score": 10
},
{
"name": "No suffix for sequential identifiers",
"description": "Internally-generated sequential key columns use the No suffix (ClientNo, CaseNo, DocumentNo) rather than Id or ID",
"max_score": 8
},
{
"name": "Function naming convention",
"description": "Key-generation functions follow the Next<Column>_fn naming pattern (e.g., NextCaseNo_fn, NextDocumentNo_fn)",
"max_score": 11
}
]
}