Analyzes and optimizes ORM/database-access code across stacks (EF Core, Prisma, TypeORM, Drizzle, SQLAlchemy, Django ORM, Hibernate, Spring Data, GORM). Detects N+1, lazy loading, over-fetching, cartesian explosion, missing indexes, and rewrites queries.
Ships in AI for Developers 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.
Find and fix the performance problems in ORM-based data access, then return the optimized code with a short explanation of every change. The problems are universal; only the syntax differs per ORM.
You don't need pasted snippets. Work directly from whatever target the user gives:
git clone --depth 1 <url> /tmp/repo && cd /tmp/repoRead the manifest before reading queries:
| Manifest | Look for | ORM | Reference to load |
|---|---|---|---|
*.csproj | Microsoft.EntityFrameworkCore | EF Core | references/ef-core-patterns.md |
package.json | @prisma/client, typeorm, drizzle-orm | Prisma / TypeORM / Drizzle | references/prisma-typeorm-patterns.md |
pyproject.toml, requirements*.txt | sqlalchemy, django | SQLAlchemy / Django ORM | references/sqlalchemy-django-patterns.md |
pom.xml, build.gradle(.kts) | hibernate, spring-boot-starter-data-jpa | Hibernate / JPA / Spring Data | references/hibernate-jpa-patterns.md |
go.mod | gorm.io/gorm | GORM | references/gorm-patterns.md |
Load only the reference for the detected ORM, and only when the checklist below isn't enough. For other data-access libraries (Dapper, Knex, sqlx, jOOQ, ActiveRecord, Eloquent) apply the universal checklist with that library's idioms.
Then locate candidate queries, e.g.:
# .NET
grep -rn "\.Include(\|\.ToListAsync\|AsNoTracking\|DbContext" --include=*.cs <target> | grep -v "/obj/\|/bin/"
# Node / TypeScript
grep -rn "\.findMany\|\.findUnique\|getRepository\|createQueryBuilder\|db\.select\|db\.query\." --include=*.ts <target> | grep -v node_modules
# Python
grep -rn "\.objects\.\|session\.\(query\|execute\|scalars\)\|select(" --include=*.py <target>
# Java / Kotlin
grep -rn "@OneToMany\|@ManyToOne\|FetchType\|@Query\|JpaRepository" <target>/src
# Go
grep -rn "\.Preload(\|\.Find(\|\.First(\|db\.Where" --include=*.go <target>
On a large project, scan the matched files, prioritize the worst offenders (loops, list endpoints, dashboards, reports), and skip unrelated code. Tell the user which files you scanned and group findings by file.
A loop (or lazy relation access) that fires one query per row. The classic killer.
for / map / forEach / list comprehension.WHERE id IN (...)), or project everything in one query.Loading full entities/rows when only a few columns are used.
Read-only queries paying for change tracking or session bookkeeping.
AsNoTracking, Hibernate read-only transactions/hints, SQLAlchemy column selects, Django .values()).Eager-loading two or more collections through JOINs multiplies rows (orders x items x payments).
WHERE, ORDER BY, LIMIT and aggregates into the query, before materialization.OFFSET; paging without a stable ORDER BY.WHERE id > :last ORDER BY id LIMIT n) for deep pages; stable, indexed sort key.count() > 0, loading a list just to check its length.AnyAsync, .exists(), existsBy..., findFirst selecting only the id).ExecuteUpdateAsync, createMany/updateMany, bulk_create/QuerySet.update(), JPQL bulk UPDATE + JDBC batching, CreateInBatches). Warn that bulk statements usually bypass entity hooks, events, and interceptors.ToList() in async code, a sync session inside async def); long transactions holding connections; external HTTP calls inside a transaction.EXPLAIN / EXPLAIN ANALYZE on the slow statement.| Problem | EF Core | Prisma / TypeORM / Drizzle | SQLAlchemy / Django | Hibernate / JPA | GORM |
|---|---|---|---|---|---|
| Eager load | Include / ThenInclude | include / relations / with | selectinload, joinedload / select_related, prefetch_related | JOIN FETCH, @EntityGraph | Preload, Joins |
| Projection | .Select(x => new Dto(...)) | select: {...} / .select([...]) / db.select({...}) | select(Model.a, Model.b) / .values(), .only() | DTO / record / interface projection | Select(...) + Scan(&dto) |
| Read-only | AsNoTracking() | n/a (no change tracker) | column selects / .values() | @Transactional(readOnly = true), read-only hint | n/a |
| Split collections | AsSplitQuery() | separate queries | selectinload / prefetch_related | @BatchSize, hibernate.default_batch_fetch_size | Preload (separate query) |
| Bulk write | ExecuteUpdateAsync / ExecuteDeleteAsync | updateMany / .update().where() | update() statement / QuerySet.update(), bulk_create | JPQL UPDATE, JDBC batching | Model(...).Where(...).Updates(...), CreateInBatches |
| Show SQL | ToQueryString(), LogTo | log: ['query'] / logging: true / logger: true | echo=True / str(qs.query) | spring.jpa.show-sql, hibernate.generate_statistics | db.Debug(), db.ToSQL(...) |
## Summary
<stack + ORM detected; one paragraph: what was slow and the headline fixes>
## Findings
1. [N+1] <file:line> - <problem> -> <fix>
2. [No projection] ... -> ...
## Optimized code
<the rewritten query/method, ready to paste>
## Verify on your side
- <index suggestions, SQL/EXPLAIN to run, anything needing the real schema or data>
USAGE.md (opens in a new tab)references/ef-core-patterns.md (opens in a new tab)references/gorm-patterns.md (opens in a new tab)references/hibernate-jpa-patterns.md (opens in a new tab)references/prisma-typeorm-patterns.md (opens in a new tab)references/sqlalchemy-django-patterns.md (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
Prisma, TypeORM, Drizzle, SQLAlchemy, PostgreSQL, SQLite, MySQL
45 skills in this plugin
/api-endpoint-scaffolderScaffold HTTP API endpoints in any stack - ASP.NET Core Minimal APIs or controllers, Express, Fastify, NestJS, FastAPI, Django REST Framework, Spring Boot controllers, Go net/http, chi, Gin - one feature per endpoint (REPR style) with request validation, typed responses, route grouping, auth, and OpenAPI metadata. Use this skill whenever the user wants to add an endpoint or route, convert controllers to minimal APIs, structure routes or routers, set up endpoint groups, TypedResults, route handlers, request DTOs/schemas (zod, Pydantic, Bean Validation, binding tags), or asks "how do I add an endpoint / structure my API routes". Always use this skill for endpoint scaffolding; it generates a complete, validated endpoint that matches the project's conventions./architecture-test-generatorGenerate architecture tests / fitness functions that fail the build when architectural rules are violated - layer dependencies, module boundaries, cycles, naming, and visibility conventions - in any stack: NetArchTest or ArchUnitNET (.NET), ArchUnit or Konsist (Java/Kotlin), dependency-cruiser or eslint-plugin-boundaries (TypeScript/JavaScript), import-linter (Python), go-arch-lint or depguard (Go). Use this skill whenever the user wants architecture tests, to enforce layering or the dependency rule, dependency rules as tests, import rules, forbidden imports, no circular dependencies, naming conventions, fitness functions, or asks "how do I stop people breaking the architecture / enforce my layers / keep modules from importing each other". Always use this skill for architecture-test requests; it generates rules matching the project's real structure./ai-dev-toolkit:orm-query-optimizerfrom AI for Developers Toolkit
npx claudepluginhub stefanthecode/ai-for-developers --plugin ai-dev-toolkitOther plugins' skills for the same job