Audits classic ADO.NET code (SqlConnection, SqlCommand, SqlDataReader) for SQL injection, connection leaks, and wasteful reads, then rewrites it with fixes.
Ships in TheCodeMan .NET AI ToolKit. 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.
Audit classic ADO.NET code for the three things that go wrong in 20-year-old data layers -- SQL injection, leaked connections/commands/readers, and wasteful repeated reads -- then return the rewritten code with a one-line explanation per fix. This is for the old stack (System.Data.SqlClient / Microsoft.Data.SqlClient, SqlDataReader, DataSet/DataTable), not EF Core.
The user has hand-written ADO.NET (a DAL, a repository, a Helper class full of SqlCommands) and wants it made safe, leak-free, and faster -- or reviewed before a migration. They may paste code or point at a file. If nothing is provided, ask for the data-access method(s) and how the connection string is obtained.
You don't need pasted snippets. Work from whatever target the user gives:
path/to/OrderRepository.csData/ or DAL/ directory.csproj / .sln or the repo rootgit clone --depth 1 <url> /tmp/repo && cd /tmp/repoFind the ADO.NET yourself with Glob/Grep/Bash instead of asking for a paste:
grep -rl "SqlCommand\|SqlConnection\|SqlDataReader\|SqlDataAdapter" --include=*.cs <target> | grep -vi "/obj/\|/bin/"
grep -rn "ExecuteReader\|ExecuteNonQuery\|\" + \|GetOrdinal" --include=*.cs <target>
On a large data layer, prioritize the worst offenders (string-built SQL, undisposed connections) and tell the user which files you scanned.
SqlConnection, SqlCommand, SqlDataReader, DataAdapter, DataSet, and where user input enters the SQL.Apply every item. For each finding: problem -> impact -> fix.
The classic sin: "SELECT * FROM Users WHERE Name = '" + name + "'".
+, string.Format, $"...", or StringBuilder assembling SQL that contains any variable that could carry user input.cmd.Parameters.Add("@Name", SqlDbType.NVarChar, 100).Value = name; (typed + sized -- avoids implicit conversions and plan-cache bloat). Never use AddWithValue for varchar/char columns or for anything performance-sensitive; it infers the wrong type and causes implicit conversions that kill index usage. Table/column names can't be parameterized -- whitelist them against a fixed allow-list instead of concatenating.Old code opens a SqlConnection and never guarantees close on exception, or returns a SqlDataReader the caller forgets to dispose.
new SqlConnection(...) without using; conn.Open() with no try/finally or using; a reader/command created without using; connections stored in fields and reused.SqlConnection, SqlCommand, and SqlDataReader each in using (or using var). Connections are cheap because of connection pooling -- open late, close early, one per unit of work. Do not cache/share a single SqlConnection across calls or threads. If a method returns a reader, either materialize inside the method or accept that ownership transfer is a code smell -- prefer returning a List<T>/DTO.reader["Total"] called several times, or reader.GetOrdinal("X") inside the row loop.
reader["col"] / indexer accessed more than once per row; GetOrdinal called inside the while (reader.Read()) loop; boxing via reader["col"] then casting.int totalOrd = reader.GetOrdinal("Total");), then use typed getters inside the loop (reader.GetDecimal(totalOrd)), reading each column exactly once into a local. Typed getters avoid boxing; caching ordinals avoids a hash lookup per column per row.(string)reader["Name"] / direct casts that throw on DBNull; comparing to null instead of DBNull.Value.reader.IsDBNull(ord) ? null : reader.GetString(ord). For parameters, send (object?)value ?? DBNull.Value.ExecuteNonQuery calls that must succeed together but each runs on its own; a SqlTransaction opened but not assigned to cmd.Transaction; missing rollback on exception.using var tx = conn.BeginTransaction();, assign cmd.Transaction = tx; on every command, tx.Commit() at the end inside the try, and rely on using to roll back if Commit never runs (dispose of an uncommitted transaction rolls back). Set an appropriate isolation level explicitly if the default matters.ExecuteReader(), ExecuteNonQuery(), Open(), reader.Read() in code that is (or should be) async, blocking a thread on I/O.await conn.OpenAsync(ct), await cmd.ExecuteReaderAsync(ct), await reader.ReadAsync(ct), ExecuteNonQueryAsync(ct) -- and thread a CancellationToken through. (Note: System.Data.SqlClient is legacy; Microsoft.Data.SqlClient has better async + is where fixes land -- suggest it, but it's an optional swap.)CommandType.Text for what is really a stored proc; CommandTimeout never set for known-long queries; re-creating the same SqlCommand in a loop instead of reusing with changed parameter values; SELECT * feeding a reader that uses two columns.CommandType.StoredProcedure and pass the proc name; set a deliberate CommandTimeout for long ops; for batch inserts prepare once and change parameter values per iteration (or use SqlBulkCopy for large loads); select only needed columns.SqlDataAdapter.Fill(dataSet) to then read a handful of scalar values or loop once.SqlDataReader is lighter for forward-only reads; keep DataSet/DataTable only where disconnected editing/binding genuinely needs it (common in WinForms grids -- don't rip it out blindly).public async Task<List<OrderDto>> GetOrdersAsync(int customerId, CancellationToken ct)
{
const string sql = @"SELECT Id, Total, CreatedUtc
FROM dbo.Orders
WHERE CustomerId = @CustomerId";
using var conn = new SqlConnection(_connectionString);
using var cmd = new SqlCommand(sql, conn);
cmd.Parameters.Add("@CustomerId", SqlDbType.Int).Value = customerId; // typed + parameterized
await conn.OpenAsync(ct);
using var reader = await cmd.ExecuteReaderAsync(ct);
// ordinals resolved ONCE, before the loop
int idOrd = reader.GetOrdinal("Id");
int totalOrd = reader.GetOrdinal("Total");
int dateOrd = reader.GetOrdinal("CreatedUtc");
var result = new List<OrderDto>();
while (await reader.ReadAsync(ct))
{
result.Add(new OrderDto
{
Id = reader.GetInt32(idOrd), // typed getter, read once
Total = reader.GetDecimal(totalOrd),
Created = reader.IsDBNull(dateOrd) ? null : reader.GetDateTime(dateOrd)
});
}
return result;
}
## Summary
<one paragraph: the security + leak + perf headline findings>
## Findings
1. [SQL injection] <file/line> -- <problem> -> <fix>
2. [Leak / no using] ... -> ...
3. [Repeated read] ... -> ...
## Rewritten code
<the fixed method(s), ready to paste>
## Verify on your side
<column ordinals vs real schema, isolation level choice, System.Data vs Microsoft.Data.SqlClient>
using. Connection, command, reader, transaction -- no exceptions, pooling makes it cheap.What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
adonet, data-access, sql-injection, connection-leaks, code-review
49 skills in this plugin
/async-await-auditorAudit C#/.NET code for async/await anti-patterns and concurrency bugs. Use this skill whenever the user shares async C# code or asks about deadlocks, async void, .Result/.Wait(), blocking calls, ConfigureAwait, sync-over-async, fire-and-forget tasks, CancellationToken usage, or "why does my async code hang/deadlock". Always use this skill for async correctness/performance reviews instead of answering from memory; it applies a fixed checklist and rewrites the code./authorization-policy-generatorDesign ASP.NET Core authorization — policy-based, role-based, and claims/requirement-based with custom authorization handlers and resource-based checks. Use this skill whenever the user wants authorization policies, role/claim checks, custom AuthorizationHandler, resource-based authorization, permission checks, or asks "how do I authorize this / policy vs role / restrict this endpoint to X". Always use this skill for authorization requests; it generates policies, handlers, and endpoint wiring./benchmarkdotnet-setupSet up BenchmarkDotNet for a .NET project and interpret the results — proper benchmark classes, memory diagnostics, baselines, and reading ns/op + allocations. Use this skill whenever the user wants to benchmark code, measure performance, compare two implementations, set up BenchmarkDotNet, or asks "which is faster / how do I benchmark this / interpret these benchmark results". Always use this skill for micro-benchmarking requests; it writes correct benchmarks and explains the numbers./caching-strategy-setupAdd the right caching to a .NET app — IMemoryCache, distributed cache, or HybridCache (.NET 9+) — with correct keys, expiration, stampede protection, and invalidation. Use this skill whenever the user wants caching, to cache a query/response, IMemoryCache, Redis/distributed cache, HybridCache, output caching, or asks "how do I cache this / add caching / avoid cache stampede". Always use this skill for caching requests; it picks the right layer and wires expiration + invalidation correctly./cicd-pipeline-generatorGenerate a CI/CD pipeline for a .NET app — GitHub Actions or Azure DevOps — with restore, build, test, coverage, vulnerability scan, container build, and deploy stages. Use this skill whenever the user wants a CI/CD pipeline, GitHub Actions workflow, Azure DevOps YAML, build/test automation, a release pipeline, or asks "how do I set up CI / pipeline for .NET / automate build and deploy". Always use this skill for CI/CD requests; it generates a complete, sensible pipeline./clean-architecture-scaffolderScaffold a .NET solution using Clean Architecture or Vertical Slice Architecture. Use this skill whenever the user wants to start a new .NET project/solution, structure an existing one, add a new feature/use-case/slice, set up layers (Domain, Application, Infrastructure, API), wire up CQRS/MediatR, or asks "how should I structure my .NET project" / "scaffold a clean architecture solution". Always use this skill for .NET project-structure and scaffolding requests; it generates a consistent folder layout, project references, and a working sample feature rather than prose advice./dotnet-ai-toolkit:adonet-data-access-auditorfrom TheCodeMan .NET AI ToolKit
npx claudepluginhub stefanthecode/dotnet-ai-toolkit --plugin dotnet-ai-toolkitOther plugins' skills for the same job