server-input-validation
Skill10 starsChanged 6 months agoMITView on GitHub
Use when validating request bodies in edge functions, RPC payloads, or any server endpoint — Zod (or similar) on the server, never trusting the client. Not for client-only forms (use typed-api-hooks-forms).
In this repository56 other files it gives its agents.
- accessibility-passSkill
- analytics-eventsSkill
- api-error-handlingSkill
- audit-logging-backendSkill
- background-jobs-and-cronSkill
- dark-mode-and-themingSkill
- dashboard-charts-rechartsSkill
- edge-functions-and-webhooksSkill
- email-and-notificationsSkill
- error-states-and-empty-uiSkill
- feature-flags-and-togglesSkill
- file-upload-storageSkill
- i18n-multi-languageSkill
- lovable-prompting-playbookSkill
- lovable-ship-checklistSkill
- migration-playbookSkill
- multi-tenant-backendSkill
- onboarding-copySkill
- optimistic-updatesSkill
- payment-failed-and-recoverySkill
- payment-webhook-idempotencySkill
- payment-webhook-testingSkill
- performance-budgetSkill
- pg-cron-recipesSkill
- pg-cron-scheduled-jobsSkill
- pg-cron-with-pg-net-edgeSkill
- postgres-full-text-searchSkill
- postgres-triggers-and-functionsSkill
- pricing-and-billingSkill
- programmatic-seo-content-qualitySkill
- programmatic-seo-pagesSkill
- rate-limiting-edgeSkill
- realtime-and-subscriptionsSkill
- refactor-safe-diffSkill
- release-notesSkill
- seo-core-web-vitalsSkill
- seo-landing-pageSkill
- seo-meta-tags-spaSkill
- seo-sitemap-generationSkill
- seo-ssr-and-prerenderingSkill
- seo-structured-dataSkill
- shadcn-patternsSkill
- soft-delete-and-archivingSkill
- stripe-one-time-payment-webhooksSkill
- stripe-payment-webhooksSkill
- supabase-auth-flowsSkill
- supabase-database-designSkill
- supabase-rls-and-authSkill
- support-replySkill
- tanstack-infinite-queriesSkill
- tanstack-mutations-and-invalidationSkill
- tanstack-prefetch-and-hydrationSkill
- tanstack-query-alternativeSkill
- tanstack-router-data-loadersSkill
- tanstack-start-server-routesSkill
- typed-api-hooks-formsSkill
The file
We split this skill into the rules it gives an agent
2 rules. About 0 are common, 2 are distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 42
Verify JWT / webhook signature.
- Distinctive: line 50
Never import server secrets into shared files.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Server input validation
Client Zod (typed-api-hooks-forms) improves UX; server validation is mandatory for security.
Edge function pattern
import { z } from "npm:zod@3";
const createProjectSchema = z.object({
name: z.string().min(1).max(80),
organization_id: z.string().uuid(),
});
let body: unknown;
try {
body = await req.json();
} catch {
return jsonError(400, "invalid_input", "Body must be valid JSON");
}
const parsed = createProjectSchema.safeParse(body);
if (!parsed.success) {
return new Response(
JSON.stringify({ error: "invalid_input", details: parsed.error.flatten() }),
{ status: 400, headers: { "Content-Type": "application/json" } },
);
}
const { name, organization_id } = parsed.data;Auth + validation order
- Verify JWT / webhook signature.
- Parse and validate body with Zod.
- Authorize (membership, RLS via user-scoped client, or explicit check).
- Execute mutation.
Share schemas (optional)
shared/schemas/project.tsimported by Vite + edge via duplicate or npm workspace — keep shapes identical.- Never import server secrets into shared files.
RPC arguments
Validate inside SQL function with raise exception or validate in edge before rpc().
Avoid
const { name } = await req.json()without schema.- Trusting
user_idfrom body — useauth.uid()from JWT. - Returning stack traces to clients in production.
Checklist
- Every edge POST/PATCH has a Zod schema
- 400 on validation failure with stable
errorcode - Authorization after validation
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

