/super-review:ormfrom super-review
ORM-layer anti-patterns reference loaded by super-review:run. Covers Prisma 5/6, MikroORM 6, TypeORM, Drizzle. N+1, transaction propagation, identity map, soft-delete bypass, raw SQL escape hatches, Prisma 6 breaking changes (Bytes→Uint8Array, NotFoundError removed). Load when an ORM is detected in package.json.
Ships in super-review. 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.
None: SKILL.md is the whole skill.
ORM-layer anti-patterns for Correctness + Performance reviewers in super-review:run. Auto-loaded when prisma, @mikro-orm/core, typeorm, drizzle-orm etc. are detected.
Detection signal: A loop after an ORM query that accesses a relation field whose include/populate was only set on the happy path.
Verbatim bad code:
const users = await prisma.user.findMany({
where: { active: true },
include: req.includeOrders ? { orders: true } : undefined,
});
for (const u of users) {
total += u.orders?.reduce((s, o) => s + o.total, 0) ?? 0; // lazy fetch if include skipped
}
Why it's wrong: Prisma doesn't lazy-load — u.orders is undefined, the ?? 0 masks the bug, and the totals are silently zero. In MikroORM the same pattern does lazy-fetch, producing N round-trips.
Fix: Move the include condition out: always include when the loop reads relations; or use a select that throws on missing rather than undefined.
Review prompt one-liner: Any loop touching entity.relation after an ORM fetch must have that relation unconditionally included.
$transaction callback that captures the outer clientDetection signal: Inside prisma.$transaction(async (tx) => { ... }), calls to prisma.foo (not tx.foo).
Verbatim bad code:
await prisma.$transaction(async (tx) => {
const u = await tx.user.create({ data });
await prisma.profile.create({ data: { userId: u.id } }); // outside the tx!
});
Why it's wrong: Only tx.* calls participate in the transaction; prisma.* runs on a fresh connection and commits independently — partial writes survive a rollback.
Fix: Always shadow the name (async (prisma) => ...) or lint-rule the use of the outer client inside transaction callbacks.
Review prompt one-liner: Inside any $transaction callback, no reference to the outer Prisma client.
db from inside txDetection signal: A helper signature async function createUser(data) that calls db.insert(...) — called from inside await db.transaction(async (tx) => createUser(data)).
Verbatim bad code:
async function awardPoints(userId: number) {
return db.update(users).set({ points: sql`points + 10` }).where(eq(users.id, userId));
}
await db.transaction(async (tx) => {
await tx.insert(orders).values(o);
await awardPoints(o.userId); // runs OUTSIDE the tx
});
Why it's wrong: Drizzle docs require explicit tx passing — there's no AsyncLocalStorage propagation. The points update is non-transactional and survives rollback.
Fix: Every helper that may run inside a transaction takes tx: typeof db | Transaction as its first arg; pass it through.
Review prompt one-liner: Drizzle helpers that write must accept and use an explicit transaction handle — no closing over a module-scoped db.
Detection signal: A singleton em imported in route handlers without em.fork() per request.
Verbatim bad code:
import { em } from './orm';
app.get('/users/:id', async (req, res) => {
const u = await em.findOne(User, req.params.id);
res.json(u);
});
Why it's wrong: MikroORM docs: "You should always keep unique identity map per each request" — sharing leaks memory ("growing memory footprint, as every entity that became managed... would be kept in the Identity Map") and produces unstable responses because one request's populate state leaks into another's.
Fix: RequestContext.create(em, next) middleware, or explicit em.fork() at the top of every handler.
Review prompt one-liner: Every MikroORM request handler must obtain its EM via RequestContext or em.fork().
$queryRawUnsafe / manager.query with string interpolationDetection signal: Template literals containing user input passed to $queryRawUnsafe, em.execute, manager.query, or db.execute(sql.raw(...)).
Verbatim bad code:
const rows = await prisma.$queryRawUnsafe(
`SELECT * FROM users WHERE email = '${email}'`
);
Why it's wrong: Bypasses parameter binding — classic SQL injection. The Unsafe suffix exists precisely because the safe $queryRaw tagged-template form is one keystroke away.
Fix: prisma.$queryRaw\SELECT * FROM users WHERE email = ${email}`(tagged template binds parameters); for Drizzle usesql`... ${email}`; for MikroORM use em.getConnection().execute(sql, [email]). **Review prompt one-liner:** Any Unsafe/.query(string)` call with a non-literal must be flagged — switch to the tagged-template variant.
Detection signal: ORM filter/global scope that hides deleted_at IS NOT NULL, plus a raw join or include on a relation that doesn't apply the filter.
Verbatim bad code:
// MikroORM filter on Post hides deleted posts
@Filter({ name: 'soft', cond: { deletedAt: null }, default: true })
class Post { @ManyToOne() author!: User; }
// But:
await em.find(User, {}, { populate: ['posts'] });
// User has no soft-delete filter — populates deleted posts through the FK.
Why it's wrong: Filters are per-entity; the populated side bypasses the filter unless explicitly enabled there too. Prisma has no global soft-delete at all — every query must pass the predicate manually.
Fix: Apply soft-delete predicates at the database view layer (CREATE VIEW active_posts AS ...), or enforce filter on both ends with a unit test that queries deleted rows through every relation.
Review prompt one-liner: Any soft-delete scheme must be enforced at the view/RLS layer, not as an ORM-only filter.
SELECT * returning sensitive fieldsDetection signal: findMany/findOne without explicit select/fields, on an entity that has password hash, internal tokens, or PII.
Verbatim bad code:
const user = await prisma.user.findUnique({ where: { id } });
res.json(user); // includes passwordHash, mfaSecret, stripeCustomerId
Why it's wrong: ORMs default to all columns; serializing the entity directly leaks fields the API contract never promised.
Fix: Always select: { id: true, email: true, ... } for response shapes, or pass through a DTO; in MikroORM use wrap(u).toJSON() with @Serializer/hidden fields.
Review prompt one-liner: ORM result objects must never be passed to res.json without an explicit select or DTO mapping.
Detection signal: new PrismaClient() at module top level in a serverless handler without __prisma global guard, or per-request new PrismaClient() in a long-running server.
Verbatim bad code:
// every cold start + warm reuse leaks connections
export const handler = async (event) => {
const prisma = new PrismaClient();
return prisma.user.findMany();
};
Why it's wrong: Each new PrismaClient() opens a connection pool; serverless concurrency × pool size saturates Postgres max_connections in minutes.
Fix: Module-scoped singleton with global.__prisma ??= new PrismaClient(); in serverless, point at Prisma Accelerate / a pooler and set connection_limit=1.
Review prompt one-liner: Exactly one new PrismaClient() per process; serverless paths must use a global cache and a pooled URL.
Buffer assumption on Bytes fieldDetection signal: Code that calls .toString('utf8'), Buffer.concat, or .buffer on a Bytes field result.
Verbatim bad code:
const file = await prisma.file.findUnique({ where: { id } });
const text = file.data.toString('utf8'); // throws or returns "[object Uint8Array]"
Why it's wrong: Prisma 6 docs: "Prisma v6 replaces the usage of Buffer with Uint8Array to represent fields of type Bytes." Uint8Array.prototype.toString() doesn't accept an encoding argument — silent wrong output.
Fix: Use Buffer.from(file.data).toString('utf8') or new TextDecoder().decode(file.data).
Review prompt one-liner: After upgrading to Prisma 6, every .toString('utf8') on a Bytes field is a bug — wrap in Buffer.from() or TextDecoder.
findUniqueOrThrow catching the wrong error classDetection signal: catch (e) { if (e instanceof NotFoundError) ... }.
Verbatim bad code:
try {
return await prisma.user.findUniqueOrThrow({ where: { id } });
} catch (e) {
if (e instanceof Prisma.NotFoundError) return null; // class removed in v6
throw e;
}
Why it's wrong: Prisma 6 docs: "NotFoundError has been removed... catch PrismaClientKnownRequestError with error code P2025." Existing instanceof checks silently never match — 404s become 500s.
Fix: if (e instanceof Prisma.PrismaClientKnownRequestError && e.code === 'P2025').
Review prompt one-liner: Post-Prisma-6, no reference to NotFoundError — catch P2025 on PrismaClientKnownRequestError instead.
const user = await prisma.user.findUnique({
where: { id },
select: { id: true, email: true, name: true }, // no passwordHash, no mfaSecret
});
Why it works: Sensitive fields can't leak through res.json(user); schema additions don't auto-widen API contracts.
Affirm: Every ORM read for an API response declares an explicit select.
async function awardPoints(tx: Tx, userId: number, points: number) {
return tx.update(users).set({ points: sql`points + ${points}` }).where(eq(users.id, userId));
}
await db.transaction(async (tx) => {
await tx.insert(orders).values(o);
await awardPoints(tx, o.userId, 10); // same tx
});
Why it works: Helpers cannot accidentally write outside the transaction; rollback semantics correct; no global db capture.
Affirm: Every write helper that may run in a transaction takes tx as the first arg.
// middleware:
app.use((req, res, next) => RequestContext.create(em, next));
// handler:
app.get('/users/:id', async (req, res) => {
const em = RequestContext.getEntityManager()!; // fresh fork, per-request identity map
res.json(await em.findOne(User, req.params.id));
});
Why it works: Identity map is request-scoped; one request's loaded entities don't leak into the next; memory doesn't grow unboundedly.
Affirm: MikroORM handlers obtain em via RequestContext or em.fork(), never from a module singleton.
const rows = await prisma.$queryRaw`
SELECT id, email FROM users WHERE email = ${email} AND tenant_id = ${tenantId}
`;
Why it works: Prisma binds ${email} and ${tenantId} as parameters; SQL injection impossible by construction; $queryRawUnsafe not used.
Affirm: All raw SQL uses the tagged-template form ($queryRaw, sql\...`), never string-concat into $queryRawUnsafe/manager.query`.
CREATE VIEW active_users AS SELECT * FROM users WHERE deleted_at IS NULL;
-- ORM points at the view, not the table
Why it works: Single source of truth; impossible to forget the predicate on a join; RLS-compatible. Affirm: Soft-delete is enforced at the view or RLS layer, not as a per-query ORM filter that joins can bypass.
What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
Generated from the plugin's indexed repository (mattnowdev/super-review) — no native marketplace selected
npx claudepluginhub p/mattnowdev-super-review22 skills in this plugin
/accessibilityAccessibility (WCAG 2.2) review referenceWCAG 2.2 accessibility anti-patterns reference loaded by super-review:run when the diff touches client-facing UI. Covers the new 2.2 criteria (Focus Appearance, Dragging, Target Size, Consistent Help, Redundant Entry, Accessible Authentication) plus the perennial misses — div-as-button, focus management on route/modal change, contrast, label/placeholder confusion, aria-hidden on focusable elements, alt-text discipline. Patterns automated axe/Lighthouse scans miss. Load when `client/`, `app/`, `src/`, `*.tsx`/`*.jsx`/`*.vue`/`*.svelte` files in diff, OR HTML templates touched./audit-selfsuper-review:audit-selfSelf-audit sub-skill for super-review. Reads past super-review comments on a PR (or across multiple PRs in a repo) and audits the audits — surfaces repeated false positives, missed-positive patterns, and proposes concrete skill-prompt edits. Use when the user says "audit super-review", "review the reviews", "what's super-review getting wrong", "/super-review:audit-self", or wants to tune the skill against this team's actual usage history./code-smellsCode-smells review referenceCode-smell catalog (Fowler / refactoring.guru) adapted for PR review. Covers Bloaters (Long Method, Large Class, Primitive Obsession, Long Parameter List, Data Clumps), OO Abusers (Switch Statements, Temporary Field, Refused Bequest), Change Preventers (Divergent Change, Shotgun Surgery), Dispensables (Duplicate Code, Dead Code, Speculative Generality, Comments-as-explanation), Couplers (Feature Envy, Inappropriate Intimacy, Message Chains, Middle Man), plus Flag Arguments, Stringly Typed, Magic Numbers. Load when the diff has a large single-file change (>150 LOC), a new class with >5 methods, function moves across files, or the user explicitly asks for a refactor review./cryptoCrypto review referenceCryptography anti-patterns reference loaded by super-review:run. Covers weak RNG, AES-GCM IV reuse, AES-CBC padding oracles, JWT alg confusion, password-hashing parameters, RSA padding, TLS verification bypass, key separation, secrets in logs. Load when the diff touches `crypto`/`jose`/`jsonwebtoken`/`bcrypt`/`argon2` or auth code paths./dockerfileDockerfile review referenceDockerfile + container-image anti-patterns reference loaded by super-review:run when the diff touches container build files. Covers root-user execution, multi-stage hygiene, build-cache layering, secret handling, base-image pinning, and reproducibility. Load when `Dockerfile`, `Dockerfile.*`, `*.dockerfile`, `docker-compose.yml`, or `.dockerignore` appears in diff./goGo review referenceGo 1.22+/1.23/1.24 anti-patterns reference loaded by super-review:run when the diff touches Go files. Covers goroutine leaks, context propagation, nil-interface traps, error-wrapping, defer-in-loop, range-over-func, weak pointers, and the per-iteration loop variable change. Load when `*.go` files in diff, or `go.mod` / `go.sum` modified.