- Home
- Skills
- Data & Databases
- Vibe Security Rules for AI Coding Agents — Next.js + Supabas
Vibe Security Rules for AI Coding Agents — Next.js + Supabas
AI coding agents write working code fast.
Free
Works with the AI Agents you already use
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
| Component | Issue Found | Fix Applied |
|---|---|---|
migrations/orders.sql | Insecure RLS Policy | Restricted access to auth.uid() = user_id |
app/api/webhook/route.ts | Missing Sig Verification | Added stripe.webhooks.constructEvent with raw body |
app/api/webhook/route.ts | Trusted Client Data | Removed 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
- Add
STRIPE_WEBHOOK_SECRETto your.env.localfile if not already present. - Run
supabase db pushto apply the updated RLS policies. - 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:
- Row Level Security is mandatory — RLS on every table, policies scoped to the owner or tenant, never USING (true) as a catch-all.
- Server secrets stay server-side — no service_role key (or any secret key) in client code or NEXT_PUBLIC_ variables.
- Storage is private by default — buckets are not public unless there is a stated reason.
- 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.
- Webhooks verify signatures — Stripe (and every other provider) events are trusted only after the signature checks out.
- Every route checks who's calling — identity, role, and price come from the server, never from fields the client sent.
- Secrets stay out of git — .env ignored, .env.example holds placeholders only, committed keys get rotated.
- 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:
- GitHub repository: https://github.com/shisanyue950901-beep/vibe-security-rules
- The service behind the pack — Go-Live Security & Cost-Cap Check (fixed-price human review of your Next.js / Supabase / Firebase app, 24h): https://shisanyue950901-beep.github.io/security-checkup/
- Read a full sample report first: https://shisanyue950901-beep.github.io/security-checkup/sample-report.html
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
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
Sign in to Agensi
Your agent shows a sign-in link. Sign in and click Allow.
- 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