Audits and fixes classic ADO.NET data-access code (SqlConnection, SqlCommand, SqlDataReader, DataSet) on .NET Framework. Applies a security, correctness, and performance checklist, then rewrites the code with explanations.
Ships in .NET Pack (legacy .NET Framework + Migration Pack to .NET 10). 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
12 skills in this plugin
/aspnet-mvc-webapi-migrator(.NET) Migrate ASP.NET MVC 5 and Web API 2 code to ASP.NET Core on .NET 10, one controller at a time - actions, routes, filters, model binding, IHttpActionResult, child actions, OutputCache, bundling - plus the app plumbing around them - Global.asax, IHttpModule, IHttpHandler/.ashx, HttpContext.Current, Newtonsoft.Json formatters and XML content negotiation. Use this skill whenever the user wants to "migrate this controller", "Web API 2 to ASP.NET Core", "MVC 5 to .NET 10", "replace Global.asax", "convert this HTTP module to middleware", "port this .ashx handler", or is moving endpoints one by one in a strangler-fig migration. Always use this skill for MVC/Web API migrations instead of answering from memory; it keeps routes, status codes and payloads identical and proves it with parity tests./ef6-to-efcore-migrator(.NET) Move an Entity Framework 6 data layer to .NET 10 in two safe steps - first EF 6.5 on .NET 10 as a bridge (same model, same queries, no rewrite), then EF Core one DbContext at a time behind query parity tests. Covers DbModelBuilder fluent config, EDMX models, lazy loading, database initializers and Seed, DbFunctions/SqlFunctions, string Include, cascade-delete and orphan differences, and a baseline migration for an existing database. Use this skill whenever the user mentions EF6, EntityFramework 6, "EF6 to EF Core", EDMX, DbModelBuilder, "EF6 on .NET 8/10", lazy loading differences, or is moving a data layer in a .NET Framework migration. Always use this skill for EF6 migrations instead of answering from memory./dotnet-pack:adonet-data-access-auditorfrom .NET Pack (legacy .NET Framework + Migration Pack to .NET 10)
npx claudepluginhub stefanthecode/ai-for-developers --plugin dotnet-packOther plugins' skills for the same job