secure-api-endpoint
Skill0 starsChanged 23 days agoMITView on GitHub
Build or fix an API route, server action or backend function so it is secure by default - authentication, ownership checks, schema validation, safe errors, rate limits and tests for the unhappy paths. Use when the user asks to add an endpoint, form handler, server action, cloud function or "backend for this button", or asks whether an existing route is safe.
1 other project uses a version of this.
Adopted by
Most recently taken up by
- DariuszDusza/agentic-workflow-foundrytheir own version, first seen Nov 22, 2026
Other versions1 project uses a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 1
- DariuszDusza/agentic-workflow-foundry★ 1same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository8 other files it gives its agents.
- AGENTS.mdAGENTS.md
- packs/AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- add-rate-limitingSkill
- database-access-rulesSkill
- launch-polishSkill
- lean-changesSkill
- stripe-webhook-setupSkill
The file
We split this skill into the rules it gives an agent
5 rules. About 0 are common, 3 are distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈3
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 22
Authenticate on the server: Use the project's existing auth helper (Auth.js auth(), Clerk, Supabase getUser(), Firebase verifyIdToken).
- Very specific: line 26
Limit abuse: If public, auth-related or paid, add a rate limit with a shared store (see add-rate-limiting).
- Distinctive: line 28
Test the unhappy paths: Add tests or a short manual script for: no session (401), other user's id (403/404), invalid body (400), over the …
- Distinctive: line 37
Never weaken an existing check (auth, CSRF, RLS, CORS) to make a test pass.
- Distinctive: line 39
Do not run migrations or call production APIs while building the endpoint.
≈ “Common” is an estimate: at least 1 in 5 of the 408,460 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
Secure API endpoint
AI tools write the happy path well. This skill makes sure the other paths exist: the stranger, the wrong user, the bad input, the script that calls it 10,000 times.
When to use
- Adding a new API route, server action, Firebase or Supabase function, Express or FastAPI handler.
- Reviewing an existing route before launch, or after "it works but is it safe?".
Steps
- Classify the endpoint. Who may call it (public, signed-in, owner, admin)? What does it read or write? Does it cost money (AI, SMS, email)? Write the answer as a one-line comment above the handler.
- Authenticate on the server. Use the project's existing auth helper (Auth.js
auth(), Clerk, SupabasegetUser(), FirebaseverifyIdToken). Return 401 if missing. Never read identity from the body. - Authorize the exact record. Load the record, compare its owner or org to the session user, return 403 (or 404 to avoid confirming it exists). For lists, filter by the user in the query itself.
- Validate input with a schema (zod, valibot, pydantic): strict object, lengths, enums, ranges. Pick fields explicitly before writing to the database.
- Access data safely. Parameterized queries or the ORM; least-privilege client; no admin key unless the operation truly needs it, and then still filter by user.
- Limit abuse. If public, auth-related or paid, add a rate limit with a shared store (see
add-rate-limiting). - Handle errors. Wrap in a boundary that logs the real error with a request id and returns a generic message. Fail closed.
- Test the unhappy paths. Add tests or a short manual script for: no session (401), other user's id (403/404), invalid body (400), over the limit (429), happy path (200).
- Summarize what the endpoint allows, for whom, and which checks you added.
Output format
The handler code, the tests, and a 5-line summary: caller, auth check, authorization rule, validation, rate limit.
Safety rules (always)
- Never weaken an existing check (auth, CSRF, RLS, CORS) to make a test pass. Ask first.
- Credentials only from environment variables. Never print, log or commit keys; use placeholders in examples.
- Do not run migrations or call production APIs while building the endpoint. Use local or staging resources, and show any command that changes data before running it.
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.

