Vibe Security Rules for AI Coding Agents — Next.js + Supabas

    1

    AI coding agents write working code fast.

    Free

    Security scanned

    Works with the AI Agents you already use

    Claude CodeClaude CodeCursorCursorCodex CLICodex CLIMuseMuseDotsDots+21 more

    Vibe Security Rules for AI Coding Agents — Next.js + Supabas

    Example session with this skill installed

    Review my new orders table migration and the Stripe webhook handler for security issues. Enable RLS and make sure I'm not leaking anything.

    • Read your context and instructions
    • Compiled the vibe security rules

    I have reviewed your orders migration and the Stripe webhook handler. I found two critical issues: the RLS policy was set to USING (true) for authenticated users, which would allow any user to see all orders, and the webhook was parsing the JSON body without signature verification.

    Security Audit & Fixes

    ComponentIssue FoundFix Applied
    migrations/orders.sqlInsecure RLS PolicyRestricted access to auth.uid() = user_id
    app/api/webhook/route.tsMissing Sig VerificationAdded stripe.webhooks.constructEvent with raw body
    app/api/webhook/route.tsTrusted Client DataRemoved reliance on req.json().price; now fetching from DB

    Updated Migration

    -- migrations/20231027_create_orders.sql
    alter table public.orders enable row level security;
    
    create policy "Users can view own orders"
      on public.orders for select
      to authenticated
      using (auth.uid() = user_id);
    
    create policy "Users can insert own orders"
      on public.orders for insert
      to authenticated
      with check (auth.uid() = user_id);
    

    Secured Webhook Handler

    import { stripe } from "@/lib/stripe";
    import { headers } from "next/headers";
    
    export async function POST(req: Request) {
      const body = await req.text();
      const signature = headers().get("stripe-signature") as string;
      let event;
    
      try {
        event = stripe.webhooks.constructEvent(
          body,
          signature,
          process.env.STRIPE_WEBHOOK_SECRET!
        );
      } catch (err) {
        return new Response("Invalid signature", { status: 400 });
      }
    
      if (event.type === "checkout.session.completed") {
        const session = event.data.object;
        // Ownership check: use metadata or lookup user by session
        await fulfillOrder(session.metadata.userId, session.id);
      }
    
      return new Response("Webhook processed", { status: 200 });
    }
    

    Next steps

    1. Add STRIPE_WEBHOOK_SECRET to your .env.local file if not already present.
    2. Run supabase db push to apply the updated RLS policies.
    3. Test the webhook using the Stripe CLI to ensure signature verification passes.

    Connects securely to your tools. The creator never sees your data.

    About this skill

    AI coding agents write working code fast. Left to themselves, they also write Supabase policies like USING (true), put the service-role key in the browser bundle, make storage buckets public, and leave AI endpoints with no rate limit and no spend cap — because nobody told them not to. This skill tells them not to, in instructions they actually follow.

    Vibe Security Rules is a small, opinionated rule set for apps built with Cursor, Windsurf, Claude Code, Bolt, Lovable, or similar tools on the stack most of those apps share: Next.js + Supabase + Stripe. Once loaded, your agent holds itself to eight rules on every file it writes:

    1. Row Level Security is mandatory — RLS on every table, policies scoped to the owner or tenant, never USING (true) as a catch-all.
    2. Server secrets stay server-side — no service_role key (or any secret key) in client code or NEXT_PUBLIC_ variables.
    3. Storage is private by default — buckets are not public unless there is a stated reason.
    4. Paid-API routes are capped — auth, rate limits, input caps, and a usage ceiling on anything that calls a metered API, so a script can't run up your bill.
    5. Webhooks verify signatures — Stripe (and every other provider) events are trusted only after the signature checks out.
    6. Every route checks who's calling — identity, role, and price come from the server, never from fields the client sent.
    7. Secrets stay out of git — .env ignored, .env.example holds placeholders only, committed keys get rotated.
    8. Errors don't leak — generic messages to clients, no stack traces, no tokens in logs.

    Every rule comes with a bad/good code example, so both you and the agent can see exactly what changes. The skill also runs a final self-review before your agent calls a task done, and it can walk you through reviewing a project that already exists.

    Also included in the package:

    • references/self-check.md — the 10-minute pre-launch self-check: eight quick tests you run on your own app (open tables, keys near the browser, listable buckets, secrets in the repo, uncapped AI endpoints, unverified webhooks), each with what "good" and "bad" look like and the fix.
    • references/cursor-rules.mdc — the same rules as a drop-in Cursor / Windsurf rules file, for always-on project configuration.
    • references/claude-code-rules.md — the same rules as a drop-in CLAUDE.md template for Claude Code projects.

    Honest limits: prompt rules guard the code your agent writes next. They can't verify the policies you already configured in the Supabase dashboard, and they can't find a key that was committed to git history three weeks ago. Run the self-check before you take payments — and if something comes back "bad" and you'd rather not guess, that's exactly what a one-time human review is for.

    Free and open: the same pack lives on GitHub — use it, fork it, adapt it to your stack:

    Maintained by CapsAGI — security checkups for AI-built apps.

    Optimized for Supabase and Next.js. Cannot verify dashboard-only settings or historical git commits. Requires manual secret rotation if keys were previously exposed.

    How to use

    1. 1

      Connect your agent to the Agensi MCP

      Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup

    2. 2

      Sign in to Agensi

      Your agent shows a sign-in link. Sign in and click Allow.

    3. 3

      Ask for what you need

      Your agent loads this skill and uses it on your task. It always asks before any payment.

    Reviews

    No reviews yet

    Be one of the first to try it. Every listed skill goes through the trust checks below.

    Security scanned

    Checked by our 8-point scan before listing

    Fresh listing

    Recently published to Agensi

    Free forever

    No account required to browse

    Trust & safety

    Security scan

    Security scan passed 1 day ago

    • Free with an Agensi account

    Permissions

    Network Access
    Read Files
    Environment Variables
    Listed1 day ago

    What's inside

    Frequently Asked Questions

    This skill acts as a security guardrail for your AI agent, preventing it from generating common but dangerous mistakes like `USING (true)` RLS policies, leaking service-role keys into frontend components, or creating unmetered AI endpoints that could lead to unexpected API bills.

    The skill is purpose-built for the Next.js App Router, Supabase (Auth, Postgres, Storage), and Stripe ecosystem, and it includes pre-configured logic for popular AI providers like OpenAI and Anthropic.

    Simply add this skill to your AI agent's environment; you can then use 'Audit Mode' to scan existing migrations and route handlers for vulnerabilities or 'Build Mode' to ensure all new code follows strict security protocols from the start.

    The skill enforces owner-scoped access for all data and storage buckets, validates Stripe webhook signatures to prevent fraud, and implements mandatory rate limiting on server-side routes to protect your metered API usage.

    While this skill hardens your code and configuration files, it cannot scan your Supabase dashboard settings or scrub secrets that were already committed to your Git history prior to installation.

    New in Data & Databases