Skip to content
Back to skills

Backend Engineering

ASecurity

Backend and server-side engineering — service layering, domain modelling, validation at the boundary, authentication and authorisation wiring, error handling, idempotency, background jobs and queues, scheduling, caching, file storage, email and notifications, payments and third-party integrations, webhooks, configuration, timeouts and retries, graceful shutdown, health checks, audit logging and multi-tenancy. Use when the user says "backend", "server", "API implementation", "business logic", ...

  • 3 stars
  • 0 votes
  • 0 copies
  • 5 views
  • Added December 1, 2026
securityrustgosqlnodeexpressfastapidjangorailsspringtesting

Works with

  • cli
  • api

Security analysis

A100/100

Pro scans all 4 files and shows the line behind each finding

Scanned December 1, 2026

npx -y skills add Kin9Zeus/senior-engineer-skills --skill backend-engineering --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Backend Engineering?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Backend Engineering
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/kin9zeus-backend-engineering/badge)](https://www.skillsdirectory.com/skills/kin9zeus-backend-engineering)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: backend-engineering
description: Backend and server-side engineering — service layering, domain modelling, validation at the boundary, authentication and authorisation wiring, error handling, idempotency, background jobs and queues, scheduling, caching, file storage, email and notifications, payments and third-party integrations, webhooks, configuration, timeouts and retries, graceful shutdown, health checks, audit logging and multi-tenancy. Use when the user says "backend", "server", "API implementation", "business logic", "Node", "Django", "Rails", "Laravel", "Spring", ".NET", "Go", "FastAPI", "Express", "background jobs", "queue", "cron", "send emails", "file uploads", "payments", "Stripe", "webhooks", "integrate with", "retry", "idempotent", "caching", "rate limiting", "servidor", "lógica de negocio" or "tareas en segundo plano"; when implementing a feature end to end; and in phase 5 of any new project. By Devleck.
license: MIT
---

# Backend Engineering

The backend is where rules live and where mistakes are expensive: money moves, data is
stored, permissions are decided. Most serious backend incidents come from the same
short list — **missing authorisation on one object, unvalidated input, a retried
request that does it twice, a job that silently dies, a dependency that hangs, and a
secret in the wrong place.**

**Scope:** the user's own system. Language/framework names are examples; versions and
APIs change — **check current documentation** and the project's lockfile. This skill
sits on top of `database-engineering` (schema, queries), `api-contracts` (the contract),
`security-hardening` (controls), `testing-strategy` and `observability-slo`; it covers the
code in between.

---

## The order of work (per slice)

```
 1  CONTRACT    acceptance criteria + API shape (api-contracts) before code
 2  MODEL       entities, invariants, states, who owns what (database-engineering)
 3  BOUNDARY    validate input with a schema; authenticate; authorise THIS object
 4  RULE        the business logic, in a place with no HTTP or SQL in it
 5  PERSIST     one transaction per use case; constraints in the database
 6  SIDE EFFECTS email, webhooks, jobs — after commit, idempotent, retried safely
 7  FAIL        every dependency can fail: timeouts, retries, fallbacks, clear errors
 8  PROVE       tests for the rule and the failure; cross-user test
 9  OBSERVE     structured log with correlation id, metric, alert if it matters
```

The first vertical slice (phase 4) sets the pattern every later feature copies. Make it
exemplary: it should contain **every** step above.

---

## 1. Layering that stays honest

```
HTTP/CLI/queue handler   parse + validate + authenticate  → calls ↓
Application service      one use case, one transaction, orchestrates ↓
Domain (rules)           pure logic and invariants — no I/O, easy to test
Repositories / gateways  database and external services behind interfaces
```

- Handlers are thin. **No business rules in controllers, no SQL in handlers.**
- A **use case** is a function: `createInvoice(actor, input)`. It receives the *actor*
  (who is acting) explicitly so authorisation cannot be forgotten.
- Keep the **domain pure**: money, state transitions, pricing, eligibility — unit-test
  these heavily; they are your product.
- A **modular monolith** by default (`project-blueprint/references/architecture-patterns.md`):
  modules with clear public interfaces, not microservices.
- Dependency direction points inward; frameworks are details.

Details and patterns: `references/service-design.md`.

## 2. Validate, authenticate, authorise — in that order, every time

- **Validate at the boundary** with one schema library; reject unknown fields; coerce and
  bound sizes, lengths, ranges, enumerations; normalise (trim, case, unicode) once.
- **Authenticate** with the chosen mechanism (session cookie or short-lived token); one
  middleware; deny by default.
- **Authorise the specific object**: "may *this actor* do *this action* on *this
  resource*?" Enforce it in the use case (policy function) **and** scope queries by
  tenant/owner. A route-level "is logged in" check is not authorisation.
- **Mass assignment:** map input fields explicitly; never pass a request body straight
  into a model.
- Prove with a **cross-user test** for every route that touches user-owned data
  (`security-hardening`).

## 3. Errors, idempotency and transactions

- A small **error taxonomy** (validation, unauthenticated, forbidden, not found,
  conflict, rate-limited, dependency failure, internal) mapped to status codes and a
  consistent envelope (`api-contracts`). Never leak stack traces or internals; log them
  with a correlation id.
- **Idempotency:** any operation a client or queue may retry (payments, webhooks, "create
  order") accepts an **idempotency key** and returns the same result on repeat; store
  keys with a unique constraint.
- **Transactions:** one per use case; keep them short; no network calls inside a
  database transaction; understand isolation (`database-engineering`); handle
  serialisation failures with retry.
- **Concurrency:** optimistic locking (version column) or row locks for contended rows;
  unique constraints as the final arbiter; avoid check-then-act races.
- **Money:** integer minor units or decimal, never float; currency stored with amount;
  rounding rule decided and tested.
- **Time:** store UTC; convert at the edge; use injected clocks in tests.

## 4. Side effects: after the commit, never inside it

Send emails, call webhooks, enqueue jobs **only after** the transaction commits. Use the
**outbox pattern** (write the event in the same transaction, publish asynchronously) when
losing or duplicating a message is unacceptable. Consumers must be **idempotent**
because delivery is at-least-once.

## 5. Background jobs, queues and schedules

- Use a durable queue/job library; jobs carry ids not blobs; **idempotent**, **retried
  with backoff and a cap**, with a **dead-letter** destination and an alert.
- Set **timeouts** and concurrency limits; avoid unbounded fan-out.
- **Scheduled jobs:** exactly-once is a myth — make them idempotent and guard with a lock
  or unique key so two instances do not both run; log start/end/outcome; alert on missed
  runs.
- Long work returns **202 + status resource**; show progress.
- Graceful shutdown: finish or requeue in-flight jobs.
- Queue depth and age are metrics with alerts.

## 6. Integrations and external dependencies

Wrap every third party behind your own interface; set **timeouts** (connect and total);
**retry** only idempotent calls with exponential backoff and jitter; add a **circuit
breaker** or at least a failure budget; define a **fallback or graceful degradation**;
verify inbound **webhook signatures** (HMAC over the raw body, constant-time compare,
timestamp window, replay protection, dedupe by event id); respect rate limits and
quotas; **store provider ids** to reconcile; never log secrets or full payloads with
personal data; contract-test against the provider's sandbox; plan for **provider
outage and policy change**. Payments, email, SMS, storage, auth, maps and AI providers
are detailed in `references/integrations.md`.

## 7. Files, email and notifications

- **Uploads:** validate type by content, cap size, random server-side names, store in
  object storage (not the app disk), private by default with short-lived signed URLs,
  scan where the threat model needs it, set content-disposition and nosniff.
- **Email:** a transactional provider; verified sending domain (SPF, DKIM, DMARC);
  bounce/complaint handling; suppression list; unsubscribe for non-transactional mail;
  templates tested in major clients; **links for sensitive actions are single-use and
  short-lived**; queue sending, never block the request.
- **Notifications:** preferences, quiet hours, batching; no sensitive content in push
  payloads.

## 8. Configuration, secrets and environments

Config from environment, **validated at boot** (fail fast with a clear message);
separate secrets per environment; secrets from a manager at runtime where available
(`cloud-security`); `.env.example` documents every key; no secrets in logs, errors or
analytics; feature flags with owners and expiry; one artefact promoted through
environments.

## 9. Reliability and operations

Health endpoints (liveness, readiness distinct); graceful shutdown (stop accepting,
drain, close pools); connection-pool sizing; timeouts everywhere; backpressure and
rate limits (per user/key/IP); request size limits; pagination caps; **caching** with
explicit keys, TTLs, invalidation and a plan for stampedes; **structured logs** with
correlation id, user id (pseudonymous), no personal data; metrics (RED); traces for
cross-service calls; **audit log** for sensitive actions (who, what, when, from where,
before/after) stored append-only. Details: `references/reliability-and-operations.md`.

## 10. Multi-tenancy and data lifecycle

Decide tenancy in phase 3; scope **every** query by tenant (a repository base class or
row-level security makes it hard to forget); never trust a tenant id from the client;
background jobs carry tenant context; tenant isolation tests in CI. Build **export and
deletion** from the start (`privacy-compliance`); soft-delete with retention, hard-delete
by schedule; propagate deletions to processors, search and caches.

---

## What people get wrong

- **Authorisation by obscurity** — "the UI doesn't show that button."
- **Doing side effects inside the transaction** (email sent, then rollback).
- **No idempotency**, then double charges on a mobile network retry.
- **Fire-and-forget async** with no retry, no dead-letter, no alert.
- **No timeouts** — one slow dependency exhausts the worker pool.
- **N+1 queries and unbounded lists** in "just one endpoint".
- **Business rules in the controller**, untestable and duplicated.
- **Float money; local time in the database.**
- **Cron on every instance**, so the job runs N times.
- **Logging request bodies** (passwords, tokens, personal data).
- **"We'll add rate limits later"** — after the credential-stuffing run.
- **One giant function per endpoint**, 400 lines, no seams.

## Report format

Findings: **location → problem → consequence → fix → verification** (a test, a load
check, a log/metric to observe). End with **What I could not verify** (production load,
provider behaviour, concurrency under real traffic).

---

## References

- `references/service-design.md` — layering patterns, domain modelling, validation, errors, idempotency, transactions, concurrency, jobs, caching, pagination, search
- `references/reliability-and-operations.md` — timeouts/retries/breakers, shutdown, health, migrations on deploy, limits, observability hooks, audit log, configuration
- `references/integrations.md` — payments, email deliverability, SMS/chat, auth providers, storage, AI APIs, webhooks, provider failure
- Related: `database-engineering`, `api-contracts`, `security-hardening`, `testing-strategy`, `observability-slo`, `devops-platform`, `privacy-compliance`

Files in this skill

  • SKILL.md10.9 KB
  • references/integrations.md6.9 KB
  • references/reliability-and-operations.md5.6 KB
  • references/service-design.md7.5 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in security →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.