smithery/bybren-llc

rls-patterns

Row Level Security patterns for database operations. Use when writing Prisma/database code, creating API routes that access data, or implementing webhooks. Enforces withUserContext, withAdminContext, or withSystemContext helpers. NEVER use direct prisma calls.

Installation

$ npx skills add smithery/bybren-llc --skill rls-patterns

Similar popular skills

Related neighbors and high-traction skills in the same topics — useful to compare before installing.

Also in this package

Other skills from smithery/bybren-llc · top by installs.

npx skills add smithery/bybren-llc

Browse all from smithery/bybren-llc

More details

Agent compatibility

Declared targets from SKILL.md / docs. Unmarked agents are not listed — the skill may still install via the CLI.

Claude Code Not declared
Cursor Not declared
Codex Not declared
GitHub Copilot Not declared
Windsurf Not declared
Gemini CLI Not declared
Cline Not declared
OpenCode Not declared

Package contents

Files included with this skill beyond the listing page.

  • skill md SKILL.md 2,287 B
  • docs SUMMARY.md 280 B

History

  1. First recorded snapshot · 0 installs

SKILL.md

RLS Patterns Skill

Purpose

Enforce Row Level Security (RLS) patterns for all database operations. Ensures data isolation and prevents cross-user data access.

When This Skill Applies

  • Writing any Prisma database query
  • Creating or modifying API routes that access the database
  • Implementing webhook handlers
  • Working with user data, payments, subscriptions

Critical Rules

NEVER Do This

// ❌ FORBIDDEN - Direct Prisma calls bypass RLS
const user = await prisma.user.findUnique({ where: { user_id } });

ALWAYS Do This

import { 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 });
});

Context Helper Reference

Helper Use For
withUserContext User-facing operations (profile, payments, subscriptions)
withAdminContext Admin-only operations (disputes, webhook events)
withSystemContext Webhooks and background jobs

Common Patterns

API Route with User Context

export 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);
}

Admin Pages: Force Dynamic

// REQUIRED for admin pages with RLS
export const dynamic = "force-dynamic";

Reference

  • Implementation Guide: docs/database/RLSIMPLEMENTATIONGUIDE.md
  • Policy Catalog: docs/database/RLSPOLICYCATALOG.md