- Home
- Skills
- Data & Databases
- Vibe Security Rules — Next.js + Supabase + Stripe
Vibe Security Rules — Next.js + Supabase + Stripe
by 高潮辉
Left to themselves, they also write Supabase policies like `USING (true)`, bury service_role keys in client code, and leave storage buckets public.
Free
Works with the AI Agents you already use
Vibe Security Rules — Next.js + Supabase + Stripe
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), bury service_role keys in client code, and leave storage buckets public.
Vibe Security Rules is a small, opinionated rule set for apps built with Cursor, Windsurf, Claude Code, or any other AI coding tool. It covers the Next.js + Supabase + Stripe stack — the stack AI-built SaaS apps most often ship with.
The pack has twelve rules, each one covering a mistake real AI-built apps have shipped:
- Row Level Security is mandatory — RLS on every table, policies scoped to the owner or tenant, never
USING (true). - 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 paid API.
- Webhooks verify signatures — Stripe (and every other provider) events are trusted only after their signature is verified.
- Every route checks who's calling — identity, role, and price come from the server, never from fields the client sends.
- 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.
- Sessions are revalidated server-side — sensitive actions re-check the session on the server instead of trusting what the client claims.
- Views and SECURITY DEFINER functions don't bypass RLS — views and SECURITY DEFINER functions are written so they can't silently bypass row-level security.
- Uploads are validated by content — uploaded files are checked by their actual content and type, not just by filename or extension.
- Dependencies are checked — third-party packages are screened for known vulnerabilities and supply-chain risks before they ship.
Every rule comes with a bad/good code example, so both you and the agent can see exactly what changed and why.
Also included in the package:
- references/self-check.md — the 10-minute pre-launch self-check: twelve quick tests you run on your own app before you ship.
- references/cursor-rules.mdc — the same rules as a drop-in Cursor / Windsurf rules file, for always-on protection.
- references/claude-code-rules.md — the same rules as a drop-in CLAUDE.md template for Claude Code projects.
- EVALS.md — the verification test suite (evals) that checks the rules hold against real examples.
- RUNBOOK.md — the eval runbook: how to run the verification suite and read the results.
- CHANGELOG.md — what changed in each version of the pack.
Honest limits: prompt rules guard the code your agent writes next. They can't verify the policies you already shipped — that needs a real review of your live app. That's what the human check below 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 + Stripe app, checking RLS policies, storage buckets, webhook signatures, and API cost caps before you launch): 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.
Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse Claude Skills for Data & Databases.
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 buying a skill.
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
1 use
Times used to date
Free to use
No account required to browse
Trust & safety
Security scan
Security scan passed today
- Free with an Agensi account
Permissions
What's inside
Creator
高潮辉