idempotency-handling

Prevent duplicate API request processing using Redis caching and database-backed idempotency keys.

204|30|Updated Nov 8, 2025
One-click install
npx skills add https://github.com/secondsky/claude-skills --skill idempotency-handling
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: idempotency-handling
Source: https://github.com/secondsky/claude-skills/tree/main/plugins/idempotency-handling/skills/idempotency-handling
Command: npx skills add https://github.com/secondsky/claude-skills --skill idempotency-handling

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires redis, and includes references (resource) components.

What problem does it solve?

Ensures operations produce identical results across retries, preventing duplicates and race conditions in distributed systems.

Core Features & Use Cases

  • Idempotency key pattern with Redis caching and DB constraints
  • Safe retries for critical mutations (payments, webhook handling, etc.)
  • Deterministic responses for repeated requests
  • Clear TTL guidance and cleanup strategies

Quick Start

Implement middleware that reads an idempotency-key from request headers, checks a cache/store for a prior response, and returns the cached response if found, or stores the new response for future retries.

Frequently Asked Questions about idempotency-handling

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I prevent duplicate API requests from being processed twice?

Idempotency-key handling prevents duplicate processing by intercepting requests with a unique key, caching responses in Redis, and checking the cache before executing mutations. If the key exists, the cached response is returned; otherwise, the operation executes and the response is stored for future retries.

Can I use idempotency keys for payment processing and webhook handling?

Yes. Idempotency keys are designed for critical mutations like payments and webhook handling where duplicate processing causes issues. The pattern uses Redis caching with a 24-hour TTL and a durable database table to ensure deterministic responses and prevent race conditions across retries.

How do idempotency keys work with Redis and database constraints?

The workflow reads an idempotency-key from request headers, checks Redis for a prior response, and returns the cached result if found. If not cached, the operation executes, the response stores in Redis, and state records in a relational table with atomic processing to prevent race conditions.

What happens if an API request fails—can I safely retry with an idempotency key?

Yes. Idempotency keys enable safe retries by recording operation state in both Redis and a database table. Status updates upon success or failure, so repeated requests with the same key return the cached outcome without re-executing the mutation.

Do I need to manage Redis TTL cleanup for idempotency keys?

Redis caching uses a 24-hour TTL by default for idempotency keys. The Skill provides clear TTL guidance and cleanup strategies; the durable database-backed key table persists state independently, ensuring atomicity even after cache expiration.

What's the difference between Redis caching and database storage in idempotency handling?

Redis provides fast response caching with a 24-hour TTL for frequent retries, while the relational database table durably records operation state and keys. Together they ensure both performance and atomicity, preventing duplicates across distributed system retries.