
Idempotency Handling
This handles the tricky problem of ensuring operations don't run twice when requests get retried, which matters a lot for payments, order creation, or anything where duplicates cause real problems. The reference guides cover Redis-based storage, database implementations, and patterns modeled after Stripe's approach. You get middleware examples for Express and message queue handlers. The best practices are sensible: store the request body with the idempotency key so you can validate duplicates match, set TTLs so you're not storing this data forever, and use database constraints to handle concurrent requests atomically. If you're building any API that handles money or irreversible actions, you need something like this.
- skills.sh installs
- 467
- GitHub stars
- 379
- last updated
- Aug 21, 2026
Install
$ npx -y skills add aj-geddes/useful-ai-prompts --skill idempotency-handling --agent claude-codeInstalls into .claude/skills of the current project.
Files
Idempotency Handling
Table of Contents
Overview
Implement idempotency to ensure operations produce the same result regardless of how many times they're executed.
When to Use
- Payment processing
- API endpoints with retries
- Webhooks and callbacks
- Message queue consumers
- Distributed transactions
- Bank transfers
- Order creation
- Email sending
- Resource creation
Quick Start
Minimal working example:
import express from "express";
import Redis from "ioredis";
import crypto from "crypto";
interface IdempotentRequest {
key: string;
status: "processing" | "completed" | "failed";
response?: any;
error?: string;
createdAt: number;
completedAt?: number;
}
class IdempotencyService {
private redis: Redis;
private ttl = 86400; // 24 hours
constructor(redisUrl: string) {
this.redis = new Redis(redisUrl);
}
Sponsors
Details
- Repository
- github.com/aj-geddes/useful-ai-prompts
- Categories
- AI & Agent Building, Finance & Trading
- First seen
- Jun 3, 2026
More from aj-geddes/useful-ai-prompts
All 258- Session Management466
- Query Caching Strategies465
- Risk Assessment465
- Error Tracking463
- Spring Boot Application463
- Code Metrics Analysis462
- Health Check Endpoints461
- Serverless Architecture461
- Transaction Management461
- Webhook Integration461
- Secrets Rotation459
- Runbook Creation458
- Deployment Documentation457
- Stored Procedures457
- Autoscaling Configuration456
- Profiling Optimization456
- Cpu Profiling455
- Security Documentation455
- Frontend Routing454
- Load Balancer Setup454
- Property Based Testing454
- Aws Rds Database453
- Log Aggregation453
- Documentation Site Setup452