Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Row Level Security patterns for database operations. Use when writing any database query, creating API routes that access data, implementing webhooks that write to the database, or working with user data. Enforces withUserContext, withAdminContext, or withSystemContext helpers. NEVER use direct ORM/DB calls without RLS context wrappers.
.claude/skills/bybren-llc-rls-patterns/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-07 | ✗→✓ | ▲ Improved | -1% | 0% |
| case-08 | ✗→✓ | ▲ Improved | -18% | 0% |
| case-09 | ✗→✓ | ▲ Improved | -34% | 0% |
| case-01 | ✗→✓ | ▲ Improved | -10% | 0% |
| case-02 | ✗→✓ | ▲ Improved | -15% | 0% |
Enforce Row Level Security (RLS) patterns for all database operations. Ensures data isolation and prevents cross-user data access.
typescript// ❌ FORBIDDEN - Direct Prisma calls bypass RLS const user = await prisma.user.findUnique({ where: { user_id } });
typescriptimport { withUserContext, withAdminContext, withSystemContext } from "@/lib/rls-context"; // ✅ CORRECT - User context for user operations const user = await withUserContext(prisma, userId, async (client) => { return client.user.findUnique({ where: { user_id: userId } }); }); // ✅ CORRECT - System context for webhooks await withSystemContext(prisma, "webhook", async (client) => { return client.webhook_events.create({ data: eventData }); });
| Helper | Use For | | ------ | ------- | | withUserContext | User-facing operations (profile, payments, subscriptions) | | withAdminContext | Admin-only operations (disputes, webhook events) | | withSystemContext | Webhooks and background jobs |
typescriptexport async function GET() { const { userId } = await requireAuth(); const payments = await withUserContext(prisma, userId, async (client) => { return client.payments.findMany({ where: { user_id: userId }, orderBy: { created_at: "desc" }, }); }); return NextResponse.json(payments); }
typescript// REQUIRED for admin pages with RLS export const dynamic = "force-dynamic";
docs/database/RLS_IMPLEMENTATION_GUIDE.mddocs/database/RLS_POLICY_CATALOG.md| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-07 | fail→pass | 11,351 | 8,437 | -26% | 1 | 1 | 0% | 2,195 | 2,168 | -1% | 0 | 0 | — |
case-08 | fail→pass | 12,803 | 7,104 | -45% | 1 | 1 | 0% | 2,222 | 1,831 | -18% | 0 | 0 | — |
case-09 | fail→pass | 15,159 | 8,046 | -47% | 1 | 1 | 0% | 3,121 | 2,071 | -34% | 0 | 0 | — |
case-06 | pass→pass | 10,875 | 10,176 | -6% | 1 | 1 | 0% | 2,034 | 2,461 | +21% | 0 | 0 | — |
case-01 | fail→pass | 9,773 | 6,061 | -38% | 1 | 1 | 0% | 1,804 | 1,627 | -10% | 0 | 0 | — |
case-02 | fail→pass | 13,649 | 9,237 | -32% | 1 | 1 | 0% | 2,703 | 2,294 | -15% | 0 | 0 | — |
case-03 | fail→pass | 12,934 | 7,966 | -38% | 1 | 1 | 0% | 2,229 | 1,937 | -13% | 0 | 0 | — |
case-04 | pass→pass | 7,022 | 5,222 | -26% | 1 | 1 | 0% | 1,332 | 1,448 | +9% | 0 | 0 | — |
case-05 | pass→pass | 6,905 | 7,132 | +3% | 1 | 1 | 0% | 1,272 | 1,880 | +48% | 0 | 0 | — |
case-10 | fail→pass | 11,424 | 4,717 | -59% | 1 | 1 | 0% | 2,155 | 1,328 | -38% | 0 | 0 | — |
case-11 | fail→pass | 17,720 | 9,495 | -46% | 1 | 1 | 0% | 3,365 | 2,241 | -33% | 0 | 0 | — |
case-12 | fail→pass | 9,394 | 5,669 | -40% | 1 | 1 | 0% | 1,778 | 1,441 | -19% | 0 | 0 | — |
case-13 | fail→pass | 12,267 | 5,408 | -56% | 1 | 1 | 0% | 2,134 | 1,511 | -29% | 0 | 0 | — |
case-14 | fail→pass | 15,663 | 8,227 | -47% | 1 | 1 | 0% | 2,710 | 1,837 | -32% | 0 | 0 | — |
case-15 | fail→pass | 13,824 | 6,971 | -50% | 1 | 1 | 0% | 2,630 | 1,740 | -34% | 0 | 0 | — |
case-16 | fail→pass | 13,251 | 7,134 | -46% | 1 | 1 | 0% | 2,389 | 1,795 | -25% | 0 | 0 | — |
case-17 | fail→pass | 16,860 | 11,041 | -35% | 1 | 1 | 0% | 3,091 | 2,508 | -19% | 0 | 0 | — |
case-18 | fail→pass | 12,237 | 6,216 | -49% | 1 | 1 | 0% | 2,384 | 1,629 | -32% | 0 | 0 | — |
case-19 | fail→pass | 15,274 | 7,467 | -51% | 1 | 1 | 0% | 2,735 | 1,726 | -37% | 0 | 0 | — |
case-20 | fail→pass | 17,223 | 7,187 | -58% | 1 | 1 | 0% | 3,490 | 1,660 | -52% | 0 | 0 | — |
case-21 | fail→pass | 15,160 | 8,717 | -43% | 1 | 1 | 0% | 2,821 | 2,076 | -26% | 0 | 0 | — |
case-22 | fail→pass | 15,542 | 6,094 | -61% | 1 | 1 | 0% | 2,862 | 1,570 | -45% | 0 | 0 | — |
case-23 | fail→pass | 10,911 | 5,862 | -46% | 1 | 1 | 0% | 1,923 | 1,434 | -25% | 0 | 0 | — |
case-24 | fail→pass | 18,464 | 7,770 | -58% | 1 | 1 | 0% | 3,150 | 1,855 | -41% | 0 | 0 | — |
case-25 | fail→pass | 12,636 | 10,404 | -18% | 1 | 1 | 0% | 2,308 | 2,378 | +3% | 0 | 0 | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 25 cases were attempted. The headline lift of +88 percentage points is the difference between those two pass rates over the 25 comparable cases.
Without the skill loaded, the model failed this case. With it loaded, the same prompt on the same model passed. This is one improved case from the latest verified run; every case, including any that regressed, is in the table above.
Other measured skills in the registry, with their headline benchmark lift.