SqlServer.Rules CLAUDE.md

Claude Code instructions for SqlServer.Rules, a .NET project that analyzes SQL Server code and includes tests and command-line tools. They document common build, test, and sample-analysis commands.

In plain words
What is it for?
Use them to build and test the project, run an individual test, analyze SQL samples, or work on its analyzer rules and extensions.
Why use it?
They make routine development safer by showing the supported commands, project targets, test filters, and the Windows-only Visual Studio extension limitation.

Instructions file

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add instructions/erikej/sqlserver.rules/claude-md
Clone the repo
git clone --depth 1 https://github.com/ErikEJ/SqlServer.Rules
Per session 1,932 This file is loaded in full into every session.
When invoked 1,932 The same file — it is already loaded in full.
Security scan A 0 findings. Scan, not verified.
Origin fork From a forked repository.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.01932 $0.01932
Opus 5 $0.00966 $0.00966
Sonnet 5 $0.00386 $0.00386
Haiku 4.5 $0.00193 $0.00193

Measured 2d ago against content hash e5029e53bc9b, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

SqlServer.Rules CLAUDE.md scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

CLAUDE.md · 81 lines

How it starts

The opening of the file, as written. The whole thing — 81 lines — stays where its author put it; the contents beside it link to each section on GitHub.

CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

Build, Test, Run

The solution file is SqlServer.Rules.slnx (slnx format — handled by modern dotnet SDK). CI uses .NET 10 SDK; the rules library targets netstandard2.1 + net472, tools/tests target net8.0 and net10.0.

dotnet restore
dotnet build --no-restore --configuration Release
dotnet test --no-build --configuration Release

Run a single test project / single test:

dotnet test test/SqlServer.Rules.Test/SqlServer.Rules.Tests.csproj
dotnet test test/SqlServer.Rules.Test/SqlServer.Rules.Tests.csproj --filter "FullyQualifiedName~SRD0039Tests"

Run the CLI against samples after a build:

./tools/SqlAnalyzerCli/bin/Release/net10.0/ErikEJ.TSQLAnalyzerCli -i tools/SqlAnalyzerCli/testfiles/simple.sql
./tools/SqlAnalyzerCli/bin/Release/net10.0/ErikEJ.TSQLAnalyzerCli -i tools/SqlAnalyzerCli/testfiles/Chinook.dacpac

The VSIX (tools/SqlAnalyzerVsix) is Windows-only (WPF) and is excluded from the main build (<Build Project="false" /> in the slnx). Build it with MSBuild directly when needed.

sqlprojects/* are also marked non-build in the slnx — they exist as test fixtures (real SQL projects with intentional rule violations) consumed by the test projects via relative file paths.

Architecture

How a rule works

  1. src/SqlServer.Rules/ is packaged as ErikEJ.DacFX.SqlServer.Rules — a DacFx code-analysis NuGet that drops SqlServer.Rules.dll / SqlServer.Rules.NetFx.dll into analyzers/dotnet/cs/ (the net472 build is renamed to .NetFx.dll in a post-build step, see src/SqlServer.Rules/SqlServer.Rules.csproj). Both TFMs ship in one package so the analyzer loads under both legacy SSDT (net472) and modern SDK-style SQL projects.
  2. Every rule inherits from BaseSqlCodeAnalysisRule (src/SqlServer.Rules/BaseSqlCodeAnalysisRule.cs), which extends DacFx's SqlCodeAnalysisRule. The base class exposes the shared ProgrammingSchemas / ProgrammingAndViewSchemas element-type sets, keyword/data-type lists, a shared case-insensitive Comparer, and the heavy GetDataType(...) / GetColumnDataType(...) helpers (with ConditionalWeakTable caches keyed on TSqlObject — don't bypass these caches, column-type resolution is expensive).
  3. Rules are discovered by MEF via [ExportCodeAnalysisRule]. The RuleId is always Constants.RuleNameSpace + "SR{D|N|P}####" (e.g. SqlServer.Rules.SRD0038). The category comes from Constants.Design / Naming / Performance in src/SqlServer.Rules/Globals/Constants.cs. Rules are organized in folders by category that mirror these constants.
  4. Most rules walk the ScriptDom AST using visitors under src/SqlServer.Rules/Visitors/. Prefer reusing an existing visitor — there are ~90 of them covering most node types. New visitors derive from BaseVisitor (or a more specific TSqlConcreteFragmentVisitor subclass).
  5. XML doc comments on a rule class carry metadata used by the docs generator: <FriendlyName>, <IsIgnorable>, <ExampleMd>. These get parsed into docs/{Design,Naming,Performance}/SR*.md.

Read the full file on GitHub · 81 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 81 lines · 1,932 tokens per session scan A e5029e53bc9b

Subscribe to this mod's changes

SqlServer.Rules CLAUDE.md is an instructions file published in the GitHub repository ErikEJ/SqlServer.Rules (240 stars, last pushed 12d ago), licensed MIT. It adds 1,932 tokens to every session, about $0.0097 per session on Opus 5. A static security scan graded it A with 0 findings. It comes from a forked repository.