Skip to content
Back to skills

Idempotency Patterns

ASecurity

Make mutating APIs and workers safe to retry using Idempotency-Key locks, payload digests, and response replay

  • 5 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added November 30, 2026
ai-agentsapi

Works with

  • cli
  • api

Security analysis

A100/100

Scanned November 30, 2026

npx -y skills add AdityaaaTiwari/ANVIL --skill idempotency-patterns --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Idempotency Patterns?

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

Security grade badge for Idempotency Patterns
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/adityaaatiwari-idempotency-patterns-anvil/badge)](https://www.skillsdirectory.com/skills/adityaaatiwari-idempotency-patterns-anvil)

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: idempotency-patterns
description: Make mutating APIs and workers safe to retry using Idempotency-Key locks, payload digests, and response replay
---

<!-- Generated by `anvil plugin build` from catalog/. Edit the catalog, not this file. -->

# 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.

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 ai-agents →

Comments

Loading comments…

Newsletter

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