Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Implement idempotency keys and handling to ensure operations can be safely retried without duplicate effects. Use when building payment systems, APIs with retries, or distributed transactions.
.claude/skills/asymmetric-al-idempotency-handling/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-01 | ✗→✓ | ▲ Improved | 42% | 0% |
| case-05 | ✗→✓ | ▲ Improved | -20% | 0% |
| case-14 | ✗→✓ | ▲ Improved | -21% | 0% |
| case-15 | ✗→✓ | ▲ Improved | -43% | 0% |
| case-18 | ✗→✓ | ▲ Improved | -23% | 0% |
Subordinate to docs/ai/rules/backend.md and docs/guides/architecture/data-access-boundary.md. Pair with Stripe/payment work using ecosystem skills under .agents/skills/ when installed.
Repo touchpoints:
packages/api/src/donate/idempotency.ts (idempotency-key / x-idempotency-key).Refresh: references/upstream.md.
Implement idempotency to ensure operations produce the same result regardless of how many times they're executed.
Minimal working example:
typescriptimport 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); } async getRequest(key: string): Promise<IdempotentRequest | null> { const data = await this.redis.get(`idempotency:${key}`); return data ? JSON.parse(data) : null; } // ... (see reference guides for full implementation)
Detailed implementations in the references/ directory:
| Guide | Contents | | ------------------------------------------------------------------------------ | ------------------------------ | | Express Idempotency Middleware | Express Idempotency Middleware | | Database-Based Idempotency | Database-Based Idempotency | | Stripe-Style Idempotency | Stripe-Style Idempotency | | Message Queue Idempotency | Message Queue Idempotency |
| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-03 | fail→fail | 19,434 | 16,415 | -16% | 1 | 1 | 0% | 3,436 | 4,531 | +32% | 0 | 0 | — |
case-08 | fail→fail | 39,862 | 15,738 | -61% | 1 | 1 | 0% | 3,224 | 3,627 | +13% | 0 | 0 | — |
case-09 | pass→pass | 13,607 | 13,017 | -4% | 1 | 1 | 0% | 2,195 | 2,957 | +35% | 0 | 0 | — |
case-01 | fail→pass | 13,106 | 14,838 | +13% | 1 | 1 | 0% | 3,052 | 4,334 | +42% | 0 | 0 | — |
case-02 | fail→fail | 19,587 | 6,669 | -66% | 1 | 1 | 0% | 4,198 | 1,182 | -72% | 0 | 0 | — |
case-04 | pass→pass | 7,415 | 1,782 | -76% | 1 | 1 | 0% | 1,350 | 1,080 | -20% | 0 | 0 | — |
case-05 | fail→pass | 8,275 | 1,855 | -78% | 1 | 1 | 0% | 1,319 | 1,057 | -20% | 0 | 0 | — |
case-06 | pass→pass | 12,453 | 6,014 | -52% | 1 | 1 | 0% | 2,123 | 1,907 | -10% | 0 | 0 | — |
case-07 | pass→pass | 13,009 | 6,088 | -53% | 1 | 1 | 0% | 2,282 | 1,803 | -21% | 0 | 0 | — |
case-10 | pass→pass | 13,046 | 10,942 | -16% | 1 | 1 | 0% | 2,047 | 2,465 | +20% | 0 | 0 | — |
case-11 | pass→pass | 5,996 | 5,551 | -7% | 1 | 1 | 0% | 1,021 | 1,763 | +73% | 0 | 0 | — |
case-12 | pass→pass | 10,107 | 4,880 | -52% | 1 | 1 | 0% | 1,771 | 1,582 | -11% | 0 | 0 | — |
case-13 | pass→pass | 15,312 | 9,853 | -36% | 1 | 1 | 0% | 2,677 | 2,614 | -2% | 0 | 0 | — |
case-14 | fail→pass | 11,618 | 4,252 | -63% | 1 | 1 | 0% | 1,853 | 1,466 | -21% | 0 | 0 | — |
case-15 | fail→pass | 12,925 | 2,866 | -78% | 1 | 1 | 0% | 2,233 | 1,262 | -43% | 0 | 0 | — |
case-16 | pass→pass | 16,180 | 11,783 | -27% | 1 | 1 | 0% | 2,431 | 2,576 | +6% | 0 | 0 | — |
case-17 | pass→pass | 17,074 | 14,425 | -16% | 1 | 1 | 0% | 2,784 | 3,293 | +18% | 0 | 0 | — |
case-18 | fail→pass | 16,168 | 7,549 | -53% | 1 | 1 | 0% | 2,827 | 2,190 | -23% | 0 | 0 | — |
case-19 | pass→pass | 10,866 | 5,460 | -50% | 1 | 1 | 0% | 1,805 | 1,722 | -5% | 0 | 0 | — |
case-20 | fail→pass | 14,361 | 11,800 | -18% | 1 | 1 | 0% | 2,077 | 2,764 | +33% | 0 | 0 | — |
case-21 | fail→pass | 5,268 | 1,637 | -69% | 1 | 1 | 0% | 795 | 1,010 | +27% | 0 | 0 | — |
case-22 | fail→pass | 11,643 | 3,176 | -73% | 1 | 1 | 0% | 1,847 | 1,300 | -30% | 0 | 0 | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 22 cases were attempted, and 21 counted toward the lift figure. The other 1 produced results that are not comparable between the two arms, so they are excluded from the headline rather than averaged into it. The headline lift of +36 percentage points is the difference between those two pass rates over the 21 comparable cases.
Without the skill loaded, the model failed this case. With it loaded, the same prompt on the same model passed. This is one improved case from the latest verified run; every case, including any that regressed, is in the table above.
Other measured skills in the registry, with their headline benchmark lift.