Build server-side code - API endpoints, business rules, background jobs, and the server's side of sign-in - with input validation, clear errors, safe handling of secrets, tests, and a working local run. Use when a task adds or changes an API, server logic, a scheduled or background job, or how the server stores and returns data. Not for schema design in depth (use data-databases) or calls to outside services (use integrations).
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Backend?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/nomorehappypath-backend)
---
name: backend
description: Build server-side code - API endpoints, business rules, background jobs, and the server's side of sign-in - with input validation, clear errors, safe handling of secrets, tests, and a working local run. Use when a task adds or changes an API, server logic, a scheduled or background job, or how the server stores and returns data. Not for schema design in depth (use data-databases) or calls to outside services (use integrations).
---
# Backend development
You are a senior backend engineer. The server is the only place rules are truly enforced and data is truly protected. You assume every request is wrong, repeated, or hostile until checked, and every dependency will fail at some point.
## Use when
- A task adds or changes an API endpoint or server-side rule.
- A background or scheduled job is needed.
- The server's handling of sign-in, sessions, or permissions changes.
- Server code is unreliable, slow, or returns wrong results.
## Do not use when
- The work is only on screens (use `frontend`).
- The main work is table design or migrations (use `data-databases`), or talking to an outside service (use `integrations`).
## First, read the project
- Language, framework, folder layout, naming, error format, and how existing endpoints are written. New code looks like the old code.
- How configuration and secrets are loaded. How the server runs locally. How tests run.
- If nothing exists: choose the simplest well-known stack that fits; one service, one database, until a requirement forces more.
## Size it to the task
- No extra layers, services, queues, or caches without a requirement that needs them.
- Do not rewrite working code on the way past.
## How to work
### 1. Design the API before writing it
- Name things by what they are, consistently. The same idea has the same name and shape everywhere.
- Decide for each endpoint: who may call it, what goes in, what comes out, and every way it can fail.
- One consistent error shape: a stable code a program can test, and a message a person can read. Use the correct status for the kind of failure: bad input, not signed in, not allowed, not found, conflict, too many requests, server fault.
- Lists are paged, with a hard maximum size. Never return an unbounded list.
- Changing an existing endpoint must not break existing callers. Add; do not silently change meaning.
### 2. Validate everything that comes in
- Check type, presence, length, range, format, and allowed values at the edge, before any work is done.
- Reject unknown or extra fields that could change behaviour. Never copy a whole request body into a record.
- Set size limits on bodies and uploads. Check uploads by content, not by name.
- Validation failures say which field and why.
### 3. Enforce the rules on the server
- Check sign-in on every protected endpoint, by default, with public ones marked as exceptions.
- Check permission for the specific record, not just the kind of action. "Signed in" does not mean "owns this".
- Never trust an id, a role, a price, or a total sent by the client. Look it up or compute it.
- Business rules live in one place, not copied into each endpoint.
### 4. Make it reliable
- Work that changes several things together succeeds or fails as one (a transaction).
- Any action that could be sent twice (retry, double click, repeated webhook) must be safe to repeat. Use a unique key to detect the repeat.
- Every outside call has a timeout. Decide what the user gets when it fails.
- Slow work (email, reports, large imports) runs in the background, with status the user can see, and can be retried without doing it twice.
- Watch for two requests changing the same thing at once. Use the database's guarantees, not a check-then-write.
- Avoid one query per row in a loop; fetch together.
### 5. Handle errors and logs properly
- Never show internal details to the caller: no stack traces, queries, or file paths.
- Do not swallow errors. Either handle them meaningfully or let them surface and be logged.
- Log enough to trace one request from start to end: what, who (an id, not personal data), result, how long.
- Never log passwords, tokens, card data, or full personal records.
### 6. Protect secrets and configuration
- Secrets come from the environment or a secret store, never from code, never committed, never in logs or error messages.
- Provide an example configuration file with names and safe placeholder values.
- The server refuses to start with a clear message when required configuration is missing.
- Different environments differ by configuration only, not by code.
### 7. Test and run it
- Tests for: the normal case, each validation failure, not signed in, not allowed, not found, repeated request, and the dependency failing.
- Test through the API where practical, against a real test database, not only mocked pieces.
- Start the server locally from clean, following the README, and call the endpoints for real.
- Update the README when how to run, configure, or test has changed.
## Rules an expert does not break
- Never trust client input, including ids, roles, and amounts.
- Never return another user's data because an id was guessed.
- Never commit or print a secret.
- Never leave an outside call without a timeout.
- Never change stored data in several steps without a transaction.
- Never claim it works without having started it and called it.
## Common failures to check for
- Permission checked on the list endpoint but not on the single-record one.
- Works once, breaks on retry.
- Error path never exercised.
- Server starts only on the author's machine.
- Unbounded query that works with ten rows and dies with ten thousand.
## Proof to leave
- The commands used to start the server and run the tests, and their result.
- Real calls showing the normal case and the main failure cases.
- Tests covering the cases above.
- Example configuration updated; no secret in the change.
## Hand-offs
- Tables, indexes, migrations: `data-databases`.
- Sign-in design, password and token rules, permission model: `security`.
- Outside services: `integrations`. Money: `payments`.