idempotency-and-retries

idempotency-and-retries is a skill for Claude Code, Codex from tmj-90/gaffer. It costs 93 tokens per session (1,601 once invoked), scanned A, original, Apache-2.0.

A workflow for making an operation safe to repeat and for retrying failed network work. Idempotency means repeating the same request produces the same effect instead of creating duplicates.

In plain words
What is it for?
It helps protect payments, order creation, webhook handling, background jobs, and client calls with stable keys, stored outcomes, bounded retries, and backoff.
Why use it?
Networks can deliver a request zero times, once, or several times, so retries can otherwise double-create orders, send duplicate messages, or charge twice.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit It helps protect payments, order creation, webhook handling, background jobs, and client calls with stable keys, stored outcomes, bounded retries, and backoff.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/tmj-90/gaffer/idempotency-and-retries
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add tmj-90/gaffer --skill idempotency-and-retries
Clone the repo
git clone --depth 1 https://github.com/tmj-90/gaffer

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for idempotency-and-retries

README.md
[![agentmods](https://agentmods.dev/badge/skills/tmj-90/gaffer/idempotency-and-retries/github.svg)](https://agentmods.dev/skills/tmj-90/gaffer/idempotency-and-retries)
Your own site
<a href="https://agentmods.dev/skills/tmj-90/gaffer/idempotency-and-retries"><img src="https://agentmods.dev/badge/skills/tmj-90/gaffer/idempotency-and-retries/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for idempotency-and-retries

Your own site · 80×15
<a href="https://agentmods.dev/skills/tmj-90/gaffer/idempotency-and-retries"><img src="https://agentmods.dev/badge/skills/tmj-90/gaffer/idempotency-and-retries.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 93 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,601 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00093 $0.01601
Opus 5.5 $0.00037 $0.00640
Sonnet 5.5 $0.00019 $0.00320
Haiku 4.5 $0.00009 $0.00160

Measured 16d ago against content hash 0d29a05d7c35, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

idempotency-and-retries scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 16d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

runner/skills/idempotency-and-retries/SKILL.md · 97 lines

How it starts

The opening of the file, as written. The whole thing — 97 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Make operations idempotent and retries safe

Networks deliver at least once or not at all. Exactly-once effect comes only from an idempotent operation plus retries. The hard part is not the happy path; it is two copies of the same request arriving at once, and a crash between "did it" and "wrote it down". Sources: IETF draft-ietf-httpapi-idempotency-key-header; Stripe's idempotency design (Brandur Leach, "Implementing Stripe-like idempotency keys in Postgres"); AWS Builders' Library "Timeouts, retries, and backoff with jitter".

Steps

  1. Classify the operation. Naturally idempotent (PUT that sets state, DELETE), idempotent with a key (create order, send email, charge card), or deliberately non-idempotent (say why). Call search_lore for the repo's key header and retry policy.
  2. Choose the key. API creates: client-supplied Idempotency-Key header (a string, UUID recommended). Webhooks and queue consumers: the event/message id. Internal jobs: a natural key (order id + step). Scope it to the caller: the store key is (caller, key) so two tenants cannot collide.
  3. Store the outcome with a fingerprint. A table with a UNIQUE constraint on (caller, key) holding a request fingerprint (hash of method, path and canonical body), a status (in_progress, completed), the stored response (status + body), and locked_until/created_at. Replay rules (IETF draft semantics):
    • key missing on an endpoint that requires it → 400;
    • same key, different fingerprint → 422, never a silent success;
    • same key while the first is still in_progress → 409 (client retries later);
    • same key, completed → return the stored response byte-for-byte, including stored errors from after execution began (Stripe stores 500s too). Validation errors raised before execution are not stored, so a corrected retry works.
  4. Claim the key atomically, never check-then-insert. INSERT … ON CONFLICT DO NOTHING RETURNING (Postgres) / INSERT IGNORE + affected-rows (MySQL) / a unique index violation you catch. Whoever inserts owns the execution; everyone else reads the row. A SELECT followed by INSERT is a race that double-executes under load.
  5. Make local effects atomic with the record. When the effect is a database write, do it in the same transaction that sets completed and stores the response.
  6. Bracket external effects with recovery points. For a charge, email or third-party call you cannot enlist in the transaction: commit in_progress with the downstream idempotency key first, call out passing that key, then commit completed. A crash leaves in_progress past its locked_until; a reconciler (or the next retry) resumes by re-calling the dependency with the same downstream key, which collapses to one effect. Taking over a stale in_progress row is a time lease, so fence it: the takeover bumps an attempt counter, and the final completed write is conditional on it (… WHERE key = ? AND attempt = ?, 0 rows → roll back and stop), so a paused original holder cannot overwrite the recovered result (the concurrency-and-async skill, step 5). Emit follow-on messages through a transactional outbox, not directly.
  7. Retry only what is safe, at one layer. Retry idempotent or keyed calls on transient failures only: timeouts, connection resets, 502/503/504, and 429/503 honouring Retry-After. Never retry other 4xx. Backoff with full jitter: sleep = random(0, min(cap, base * 2^attempt)); cap attempts and set a total deadline. Retry at a single layer of the stack (3 retries at each of 5 layers is 243× load) and bound retries with a retry budget or token bucket so an outage is not amplified. Timeouts come from measured latency (e.g. above p99.9), never infinite.
  8. Expire keys deliberately. Keep records at least as long as clients retry (Stripe: 24 h), sweep them with a job (the scheduled-jobs skill), and document the window in the API contract (the openapi-contract skill).

Read the full file on GitHub · 97 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 16d ago Changed · +33 lines 0d29a05d7c35
  2. 19d ago First seen · 64 lines · 93 tokens per session scan A 772616c5ba60

Subscribe to this mod's changes

idempotency-and-retries is a skill published in the GitHub repository tmj-90/gaffer (2 stars, last pushed 17d ago), licensed Apache-2.0. It adds 93 tokens to every session and 1,601 once invoked, about $0.0004 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-28.

Related

Other skills, from other repositories

bulwark-brainstorm

Role-based brainstorming with dual modes: --scoped (sequential Task tool, 5 roles) and --exploratory (Agent Teams peer debate, 4 roles). Use for feasibility assessment and idea validation.

QBall-Inc/the-bulwark · 50 tokens

plan-creation

Create structured implementation plans via a 4-role scrum team (Product Owner, Architect, Eng/Delivery Lead, QA/Critic) with optional Agent Teams peer debate mode.

QBall-Inc/the-bulwark · 38 tokens

anthropic-validator

Validates Claude Code assets (skills, hooks, agents, commands, MCP servers, plugins) against official Anthropic standards. Fetches latest docs dynamically and produces structured validation reports.

QBall-Inc/the-bulwark · 40 tokens

create-subagent

Generates single-purpose Claude Code sub-agents for use via the Task tool. Use when creating dedicated sub-agents, scaffolding agent definitions, or generating agents with diagnostics and permissions setup.

QBall-Inc/the-bulwark · 42 tokens

test-audit

Audit test suites for T1-T4 violations using AST analysis, mock detection, and multi-stage synthesis. Invoke when user asks to audit tests, check test quality, find mock violations, review test effectiveness, or inspect test suites for over-mocking. Triggers automatic rewrites when quality gates fail.

QBall-Inc/the-bulwark · 0 tokens

code-review

Comprehensive code review with distinct aspect based sections. Use when reviewing code, checking for security issues, finding type safety problems, auditing code quality, or when user asks to review code, PRs or changes. Three-phase workflow runs static tools, LLM judgment, and writes diagnostic log.

QBall-Inc/the-bulwark · 61 tokens