Skip to content
Skills Library
Security · Building & coding

secure-api-endpoint

/secure-api-endpoint

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.

Licence
MIT
Last repository change
09.11.2026

Assessment and security

100/ 100Class: good
Format25 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content35 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene15 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
1
Scripts
0
HTML comments
0
URLs in SKILL.md
0
Deprecation

No signals detected. Repository changed on 09.11.2026, without references to retired models or APIs.

Licence

MIT, open: use and modify while retaining author attribution.

What it does and when to use it

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.

Triggers from the description

backend for this button
Original author description

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.

How it works

  1. When to use
  2. Steps
  3. Output format
  4. Safety rules (always)
Original SKILL.md headings · 32 lines, 387 words
SKILL.md preview
---
name: secure-api-endpoint
description: 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.
license: MIT
metadata:
  origin: BlitzHash
  pack: blitzhash-vibe-coding-rules
---

# 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

1. **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.
2. **Authenticate on the server.** Use the project's existing auth helper (Auth.js `auth()`, Clerk, Supabase `getUser()`, Firebase `verifyIdToken`). Return 401 if missing. Never read identity from the body.
3. **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.
4. **Validate input with a schema** (zod, valibot, pydantic): strict object, lengths, enums, ranges. Pick fields explicitly before writing to the database.
5. **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.
6. **Limit abuse.** If public, auth-related or paid, add a rate limit with a shared store (see `add-rate-limiting`).
7. **Handle errors.** Wrap in a boundary that logs the real error with a request id and returns a generic message. Fail closed.
8. **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).
9. **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)

1. Never weaken an existing check (auth, CSRF, RLS, CORS) to make a test pass. Ask first.
2. Credentials only from environment variables. Never print, log or commit keys; use placeholders in examples.
3. 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.

Versions

RepositoryScoreLicence
This page · blitzhash360-web/blitzhash-vibe-coding-rules100MIT
DariuszDusza/agentic-workflow-foundry100Apache-2.0

Database snapshot: 13.11.2026 · package version 10bd94d0585c (SHA-256 digest of the entire package)

Downloads in the last 30 days: 0 · ranking

Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.

Similar skills

  • 95backend-endpoint
    Create REST/GraphQL API endpoint with validation, error handling, and tests. Auto-invoke when user says "add endpoint", "create API", "new route", or "add route".
  • 100add-function
    TRIGGER when user asks to add, create, or modify an API endpoint, function, or RPC, or a route that accepts typed arguments and returns typed results.
  • 90add-api-endpoint
    Use when a ticket asks to add or extend an HTTP/API endpoint — a new route, handler, or RPC method — with request validation and a defined response. Invoke for "add a POST /things endpoint", "expose a list API", or "add a field to the X response".
  • 100quick-api
    Use when scaffolding a new API endpoint — types, test, handler, validation, route, docs
  • 100secure-api-design
    Design and implement secure APIs—authentication patterns, authorization models, input validation, secrets handling, and safe defaults. Use when designing new endpoints, auth flows, or reviewing API contracts. Triggers: "secure API", "auth design", "JWT", "OAuth", "API best practices".
  • 100add-v1-endpoint
    Add a new route under /v1/... to the AerolVM HTTP server. Walks through DTOs, handler, route registration, service-layer call, tests, and the idempotency check. Use when the user asks to "add a v1 endpoint", "add an API route", "add a new HTTP handler", or describes a new…

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.