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 Idempotency Patterns?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/adityaaatiwari-idempotency-patterns)
---
description: Make mutating APIs and workers safe to retry using Idempotency-Key locks, payload digests, and response replay
profile: standard
tags: api, distributed-systems, reliability, backend
---
# Idempotency patterns
Use when designing payment charges, order creation, provisioning endpoints, or at-least-once background job consumers.
## Key handling and conflicts
- Accept client-generated `Idempotency-Key` headers (UUIDv7/v4) scoped strictly per authenticated user/tenant and route.
- Store a canonical SHA-256 digest of the request method, path, and body alongside the key: reject replays that reuse the same key with different request parameters (`HTTP 422`/`409`).
- Guard concurrent duplicate requests cleanly using an atomic DB unique insert or lock (`in_progress` state returning `409 Conflict` / retry-after until first execution settles).
## Storage and lifecycle
- Persist the final status code and serialized response body atomically with the domain mutation (same DB transaction) or update state cleanly on failure so transient 5xx crashes can retry safely.
- Apply bounded retention TTLs (e.g., 24–72 hours) and prune expired idempotency records via scheduled cleanup.
## Verify
Fire concurrent parallel duplicate requests with identical and mismatched payloads; assert single side-effect execution and identical replayed responses.