Idempotency Handling
Reusable idempotency patterns for API mutations, using Redis caching or database constraints to block duplicate processing.
- CCM score
- 58 of 100
- skills.sh installs
- 424
- GitHub stars
- 257
- last updated
- Aug 21, 2026
Own this skill? Claim it
What it does
- Covers idempotency keys for API mutations, with a Redis middleware variant and a PostgreSQL-backed variant for payment flows
- Includes a
processing,completed, andfailedstatus lifecycle plus a SHA-256 request hash that rejects reused keys with different payloads - Enforces 24-hour key expiry and uses atomic
INSERT ... ON CONFLICTso only one concurrent request executes the operation - Designed for payment processing, order creation, webhook handling, and email sending, with TTL cleanup jobs in SQL, Node.js, and Python
Install
$ npx -y skills add secondsky/claude-skills --skill idempotency-handling -yInstalls into .agents/skills for every agent it finds here, and .claude/skills for Claude Code.
Files
Idempotency Handling
Ensure operations produce identical results regardless of execution count.
Idempotency Key Pattern
const redis = require('redis');
const client = redis.createClient();
async function idempotencyMiddleware(req, res, next) {
const key = req.headers['idempotency-key'];
if (!key) return next();
const cached = await client.get(`idempotency:${key}`);
if (cached) {
const { status, body } = JSON.parse(cached);
return res.status(status).json(body);
}
// Store original send
const originalSend = res.json.bind(res);
res.json = async (body) => {
await client.setEx(
`idempotency:${key}`,
86400, // 24 hours
JSON.stringify({ status: res.statusCode, body })
);
return originalSend(body);
};
next();
}
Database-Backed Idempotency
CREATE TABLE idempotency_keys (
key VARCHAR(255) PRIMARY KEY,
request_hash VARCHAR(64) NOT NULL,
response JSONB,
status VARCHAR(20) DEFAULT 'processing',
created_at TIMESTAMP DEFAULT NOW(),
expires_at TIMESTAMP DEFAULT NOW() + INTERVAL '24 hours'
);
CREATE INDEX idx_idempotency_expires ON idempotency_keys(expires_at);
Details
- Repository
- github.com/secondsky/claude-skills
- Categories
- Backend & APIs, Databases
- First seen
- Jun 3, 2026
Questions
What does the idempotency-handling skill do?
The idempotency-handling skill makes API operations produce identical results no matter how many times they run. It covers idempotency keys with Redis caching, database-backed key storage with constraints, and cleanup of expired keys.
When should I use idempotency-handling?
Use idempotency-handling for payment systems, order creation, webhook handling, email sending, and safe retries. It also helps when you run into duplicate processing, race conditions, or idempotency key expiry errors.
Where does idempotency-handling sit in the Backend & APIs category?
idempotency-handling is listed in the Backend & APIs category alongside entra-app-registration, neon, firebase-basics, firebase-auth-basics and workers-best-practices. Its focus on duplicate-safe mutations sets it apart from those skills.
How do I install the idempotency-handling skill?
Run npx -y skills add secondsky/claude-skills --skill idempotency-handling -y in your project. The idempotency-handling skill then lets your agent add idempotency keys, Redis caching and database constraints to your API.
More from secondsky/claude-skills
All 116- Bun Http Server423
- Bun Bundler422
- Turborepo422
- Recommendation System420
- Api Versioning Strategy419
- Bun Hot Reloading417
- Claude Hook Writer417
- Logging Best Practices417
- Claude Code Bash Patterns416
- Bun React Ssr415
- Bun Shell415
- Plan Interview415
- Bun Websocket Server413
- Bun Redis411
- Ml Pipeline Automation411
- Nuxt Core410
- Nuxt Data410
- Bun Ffi408
- Bun Nuxt408
- Bun Jest Migration407
- Bun Macros406
- Multi Ai Consultant406
- Graphql Implementation402
- Model Deployment402
Similar to Idempotency Handling
More Backend & APIspayment-idempotencyvtex/skills1.2K installsIdempotency guard for payment connector endpoints covering paymentId keys, state transitions, and retry semantics.
session-managementsecondsky/claude-skills438 installsSecure session management guide covering JWT access and refresh tokens, Redis storage, and cookie hardening.
redis-patternsaffaan-m/ecc9.1K installsPractical reference for Redis caching, rate limiting, distributed locks, pub/sub, and key design in production backends.
redis-state-managementmanutej/luxor-claude-marketplace491 installsRedis state management guide covering caching, sessions, pub/sub, distributed locks, and data structures with redis-py.
backend-patternsaffaan-m/ecc17.8K installsBackend architecture patterns covering API design, repositories, caching, and error handling for Node.js, Express, and Next.js routes.