backend-patterns
Skill1 starsChanged 57 days agoMITView on GitHub
Language-neutral backend service design covering idempotency keys, timeouts and capped retries, the transactional outbox, cache invalidation, pagination of large reads, and graceful shutdown with liveness and readiness. Use when you say "make this endpoint safe to retry", "our webhook fired twice", "design the job queue", "this list endpoint times out on page 900", or "we drop requests during a deploy". Not for runtime-specific code, use `node-backend-patterns` or `springboot-patterns`.
49 other projects use a version of this.
Adopted by
Most recently taken up by
- JameMy0001/antigravity-skills-hubtheir own version, first seen Oct 2, 2026
- kensaurus/skillstheir own version, first seen Oct 1, 2026
- productionx-in/Core-Skillstheir own version, first seen Sep 29, 2026
- lintangknitto/agent-skillstheir own version, first seen Sep 23, 2026
- templetongroup/radianttheir own version, first seen Sep 17, 2026
- venables/skillstheir own version, first seen Sep 12, 2026
Used with
Projects with it also use project-guidelines-example, configure-ecc and 9 more.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
WorldFlowAISkillproject-guidelines-example
Also in 20 projects that use this
saxon-ySkillconfigure-ecc
Interactive installer for Everything Claude Code — guides users through selecting and installing skills and rules to user-level or project-level directories, verifies paths, and optionally optimizes installed files.
Also in 10 projects that use this
InfopibeSkillswift-protocol-di-testing
Protocol-based dependency injection for testable Swift code — mock file system, network, and external APIs using focused protocols and Swift Testing.
Also in 9 projects that use this
FaisalAlqarniSkilldjango-verification
Verification loop for Django projects: migrations, linting, tests with coverage, security scans, and deployment readiness checks before release or PR.
Also in 13 projects that use this
FaisalAlqarniSkillspringboot-security
Spring Security best practices for authn/authz, validation, CSRF, secrets, headers, rate limiting, and dependency security in Java Spring Boot services.
Also in 14 projects that use this
InfopibeSkillcontent-hash-cache-pattern
Cache expensive file processing results using SHA-256 content hashes — path-independent, auto-invalidating, with service layer separation.
Also in 9 projects that use this
- +3 more from Infopibe
- +1 more from FaisalAlqarni
Other versions49 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 49
- WorldFlowAI/everything-claude-code★ 4ksame name
- xu-xiang/everything-claude-code-zh★ 2ksame name
- loulanyue/awesome-claude-notes★ 272same name
- cloudnative-co/claude-code-starter-kit★ 151same name
- tpavanipradeep/everything-claude-code★ 134same name
- templetongroup/radiant★ 113same name
- hellangleZ/burn-in-cceverywhere-ralph★ 112same name
- Jamkris/everything-gemini-code★ 87same name
- tranhieutt/software_development_department★ 72same name
- codelably/harmony-claude-code★ 43same name
39 more not listed
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 repository59 other files it gives its agents.
- AGENTS.mdAGENTS.md
- .claude/CLAUDE.mdCLAUDE.md
- agentic-engineeringSkill
- ai-regression-testingSkill
- angularSkill
- ansibleSkill
- api-designSkill
- architecture-decision-recordsSkill
- ascend-memorySkill
- ascend-web-hunterSkill
- audio-scribeSkill
- automation-inventorySkill
- bashSkill
- build-dependency-managementSkill
- code-formatterSkill
- code-reviewerSkill
- coding-standardsSkill
- dart-flutter-patternsSkill
- database-migrationsSkill
- deployment-patternsSkill
- design-systemSkill
- docker-patternsSkill
- e2e-runbooksSkill
- e2e-testingSkill
- embedded-c-arduinoSkill
- frontend-designSkill
- g-code-3d-printingSkill
- github-opsSkill
- git-workflowSkill
- golang-patternsSkill
- hexagonal-architectureSkill
- home-assistantSkill
- java-coding-standardsSkill
- jetbrains-ide-opsSkill
- jira-integrationSkill
- keycloak-patternsSkill
- kicadSkill
- markdown-writerSkill
- mongodb-patternsSkill
- nextjs-app-router-patternsSkill
- node-backend-patternsSkill
- observability-and-loggingSkill
- obsidianSkill
- performance-optimizationSkill
- postgres-patternsSkill
- powershellSkill
- project-trackingSkill
- python-patternsSkill
- pytorch-patternsSkill
- react-patternsSkill
- researchSkill
- review-duplicationSkill
- security-reviewSkill
- seoSkill
- soap-webservicesSkill
- springboot-patternsSkill
- tdd-workflowSkill
- unitySkill
- web-accessibilitySkill
The file
We split this skill into the rules it gives an agent
2 rules. 0 are common, 2 are distinctive, and 0 are very specific to this project.
0
Common
Most of the 15 edited versions we read keep these.
2
Distinctive
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 82
When a dependency fails persistently, stop calling it.
- Distinctive: line 186
Keep the request path split into a transport layer that parses and responds, an application layer that holds the rule, and an …
“Common” is measured: kept by at least 6 in 10 of the 15 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Backend Patterns
Design rules for backend services that hold regardless of language or framework: what makes a write safe to repeat, what a retry may and may not do, and how a service stays correct while it is being replaced. Every example is pseudocode, because the decision is the deliverable and the syntax belongs in a runtime skill.
This skill owns the design of timeouts, capped retries, circuit breakers, and graceful shutdown.
observability-and-logging owns the logs, metrics, and traces that watch them, and does not restate these rules.
Standards baseline, current as of September 2026: HTTP semantics per RFC 9110, error bodies per RFC 7807, service contracts described in OpenAPI 3.1.
When to activate
- Deciding whether an endpoint or a message handler is safe to call twice.
- Designing retries, timeouts, or a circuit breaker between two services.
- Choosing between a queue, an outbox, and a synchronous call for work that follows a write.
- Adding a cache and needing an invalidation rule rather than a TTL guess.
- Paginating a list endpoint that has outgrown offsets.
- Making a deployment or a restart invisible to callers.
When not to activate
- Runtime and framework code: use
node-backend-patterns,springboot-patterns,python-patterns, orgolang-patterns. - URL shape, status codes, versioning, and rate-limit headers: use
api-design. - Domain, port, and adapter boundaries: use
hexagonal-architecture. - Schema, index, and query-plan work: use
postgres-patternsormongodb-patterns. - Safe schema change and backfills: use
database-migrations. - Log levels, tracing, metrics, and SLOs: use
observability-and-logging.
Make every non-idempotent operation replayable
A caller that times out cannot tell a lost request from a lost response, so it retries, and the charge happens twice. Accept a client-supplied key, store it with the result inside the same transaction as the effect, and replay the stored response on a repeat.
on POST /orders with Idempotency-Key K:
begin transaction
row = select from idempotency where key = K for update
if row exists and row.request_hash == hash(body): return row.response # replay
if row exists and row.request_hash != hash(body): return 422 # key reused
result = perform the operation
insert idempotency (key = K, request_hash = hash(body), response = result)
commitFail: keying the record on the request body alone, so two genuinely distinct orders for the same amount collapse into one. The key comes from the caller and identifies the attempt, not the content.
Give every outbound call a deadline before you give it a retry
A retry on top of an unbounded wait multiplies the outage instead of absorbing it. Set the timeout first, then bound the attempts, then add jitter so every client does not wake at the same instant.
timeout = 2s per attempt
attempts = 3 maximum
backoff = min(2^n * 200ms + random(0..200ms), 10s)
retry on = timeout, connection error, 429, 502, 503, 504
never on = 400, 401, 403, 404, 409, 422
budget = total time across attempts < the caller's own deadlineFail: retrying a 422, which fails identically every time, or retrying a POST that has no idempotency key, which duplicates the effect the caller was trying to avoid.
When a dependency fails persistently, stop calling it. A circuit breaker that opens after a failure ratio, serves a fallback while open, and lets one probe through before closing turns a slow cascade into a fast, contained error.
Do the work later, but decide first whether it may be lost
Move anything the caller does not need in the response off the request path: emails, indexing, thumbnails, webhooks. Then answer one question before choosing a mechanism.
| Loss is acceptable | Loss is a defect |
| Fire and forget after the response | Durable queue, at-least-once, with a dead-letter queue |
| Metrics, cache warming | Payments, notifications, downstream state changes |
Enqueue the identifier, not the object, so the worker reads current data. Assume at-least-once delivery, which makes an idempotent handler mandatory rather than defensive.
Publish through an outbox when the job must follow a committed write
Writing a row and publishing a message are two systems, and there is no transaction across both. If the publish wins and the transaction rolls back, a consumer acts on a record that does not exist.
begin transaction
insert into orders (...)
insert into outbox (topic = 'order.created', payload = {...})
commit
relay loop:
claim a batch of unpublished outbox rows (skip rows another relay locked)
publish each to the broker
mark publishedFail: save(order) followed by broker.publish(event), which produces phantom events on rollback and lost events on a
crash between the two lines.
A cache needs an invalidation rule, not just a TTL
Decide what the cache is allowed to be wrong about before you decide how long it holds. Write the invalidation in the same function that performs the write, and treat the TTL as the backstop for the key you forgot.
read: value = cache.get(key) ?? origin.load(key) then cache.put(key, value, ttl)
write: origin.save(entity) then cache.evict(key(entity))
key: <entity>:<schema version>:<id> # bump the version to roll out a shape change
never: cache a response whose content depends on who asked, under a key that omits the askerA cache outage must degrade throughput, not availability: on a cache error, log at warn and read the origin.
Fail: a 24-hour TTL on a permission lookup, so a revoked role stays effective until tomorrow.
Paginate large reads with a cursor, and always bound the page
Offset pagination makes the database scan and discard every skipped row, and it skips or repeats rows when the data
changes between pages. Which kind fits which list, and the request parameters and response fields, are defined by
api-design in pagination-and-filtering.md. This section
covers the query behind a cursor page.
decode cursor -> (last_sort_value, last_id)
select ... where (sort_key, id) > (last_sort_value, last_id)
order by sort_key, id
limit 21 # one extra row answers has_next
next_cursor = encode(last row)Sort on an indexed, immutable, tie-broken key, and cap limit server-side so a caller cannot ask for the whole table.
Return the cursor opaque, so its encoding stays yours to change.
Separate liveness from readiness, and drain on shutdown
Liveness answers whether the process should be restarted. Readiness answers whether it should receive traffic. Merging
them makes a transient dependency failure trigger a restart loop that fixes nothing. The two paths are the ones
api-design defines.
GET /health -> 200 while the process is alive; checks nothing external
GET /ready -> 200 when dependencies are usable, 503 otherwise; body lists each check
on SIGTERM:
mark /ready as 503 # the load balancer stops sending new work
wait for the balancer to notice # one or two probe intervals
stop accepting new connections
finish in-flight requests and jobs, bounded by a hard timer
close pools and connections, then exitFail: exiting on SIGTERM immediately, which drops every in-flight request on every deploy.
Layering and contracts live in their own skills
Keep the request path split into a transport layer that parses and responds, an application layer that holds the rule, and an infrastructure layer that talks to the outside. Depend inward, and let each side effect be an interface the application owns.
hexagonal-architecture is the authority on those boundaries, on where the port interfaces live, and on the composition
root that wires the adapters. api-design is the authority on the contract itself: resource naming, status codes, error
bodies, pagination parameters, versioning, and the rate-limit headers and tiers. Do not restate either here.
Related skills
node-backend-patternsfor the Node, Express, and Next.js implementation of these rules.springboot-patternsfor the Java and Spring Boot implementation, including its JPA data access.python-patternsandgolang-patternsfor the Python and Go implementations.api-designfor the HTTP contract, andhexagonal-architecturefor the internal boundaries.observability-and-loggingfor correlation identifiers, metrics, and the readiness banner.database-migrationswhen a change to a stored shape has to survive a rolling deploy.
Checklist
- Every non-idempotent write accepts and enforces an idempotency key.
- Every outbound call has a timeout, and every retry has a cap, jitter, and a retryable-error list.
- Work that may not be lost goes through a durable queue with a dead-letter destination.
- Messages that must follow a committed write are published from an outbox, not inline.
- Every cached key has a named invalidation trigger, and cache failure degrades throughput only.
- List endpoints over unbounded data use cursor pagination with a server-side maximum page size.
/healthand/readyare separate, andSIGTERMdrains before exit.- Layering follows
hexagonal-architectureand the contract followsapi-design.
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.

