Use when designing or modifying API endpoints, backend services, or database queries. Ensures endpoints handle concurrent multi-user traffic safely without race conditions or resource exhaustion.
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Is that skill safe to install?
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
Are you the author of Multi User Api Design?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/ganesh-dark-multi-user-api-design)
---
name: multi-user-api-design
description: Use when designing or modifying API endpoints, backend services, or database queries. Ensures endpoints handle concurrent multi-user traffic safely without race conditions or resource exhaustion.
---
# Multi-User API Design
Code that works for one developer testing locally often breaks or crashes when hundreds of users hit the same endpoint at once. Design every API assuming concurrent traffic and untrusted callers.
## Rules
- Prevent race conditions on shared state. Never do read-then-write in application memory for balances, quotas, or inventory; use atomic database updates, transactions, or unique constraints.
- Make write endpoints safe against retries and double-clicks. Use idempotency keys or conflict checks for payments, orders, and state-changing requests.
- Bound every query and payload. Enforce pagination (`limit`/`offset` or cursor), request size limits, and timeouts on all database and external HTTP calls.
- Avoid N+1 queries inside loops. Batch lookups with `IN` clauses, joins, or eager loading, and reuse connection pools instead of opening new connections per request.
- Protect shared capacity and tenant isolation. Add rate limiting on public/expensive endpoints, scope every query to the authenticated user or tenant, and avoid global mutable state in server memory.
## Example
Bad:
`GET /orders` loads all rows from the database with no limit, loops over each order to query the user table one by one, and `POST /redeem` checks `if coupon.used == False` before updating it in a separate query.
Good:
`GET /orders` scopes by `user_id` with cursor pagination and a single joined query, and `POST /redeem` uses an atomic `UPDATE ... WHERE used = false` inside a transaction with rate limiting.