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.
npx skills add cass-2003/local-workflow-skill --skill idempotency-designgit clone --depth 1 https://github.com/cass-2003/local-workflow-skillWrote 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.
[](https://agentmods.dev/skills/cass-2003/local-workflow-skill/idempotency-design)<a href="https://agentmods.dev/skills/cass-2003/local-workflow-skill/idempotency-design"><img src="https://agentmods.dev/badge/skills/cass-2003/local-workflow-skill/idempotency-design/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.
<a href="https://agentmods.dev/skills/cass-2003/local-workflow-skill/idempotency-design"><img src="https://agentmods.dev/badge/skills/cass-2003/local-workflow-skill/idempotency-design.svg" alt="Reviewed on agentmods" width="80" height="20"></a>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.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5.1 | $0.00136 | $0.02868 |
| Opus 5 | $0.00068 | $0.01434 |
| Sonnet 5 | $0.00027 | $0.00574 |
| Haiku 4.5 | $0.00014 | $0.00287 |
Grade A, and why
idempotency-design 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 7d 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.
How it starts
The opening of the file, as written. The whole thing — 332 lines — stays where its author put it; the contents beside it link to each section on GitHub.
Idempotency Design Skill — 幂等性设计
何时使用
- 设计写操作 API(创建订单 / 扣款 / 发短信 / 转账)
- 客户端 retry 但不知道服务端是否成功
- 消息队列消费者(at-least-once 投递)
- Webhook 接收方(请求方可能重发)
- 调试"用户被扣了两次款"
一、定义
幂等:执行 N 次(N≥1)的效果与执行 1 次相同。
不是"无副作用",是"副作用合并":
DELETE /users/123第一次删除,第二次返 404 / 204 但状态一致 → 幂等 ✅POST /payments第一次扣 $10,第二次又扣 $10 → 不幂等 ❌
二、HTTP 方法幂等性(规范)
| 方法 | 幂等? | 安全? |
|---|---|---|
| GET / HEAD | ✅ | ✅(无副作用) |
| OPTIONS | ✅ | ✅ |
| PUT | ✅(替换) | ❌ |
| DELETE | ✅ | ❌ |
| POST | ❌(默认) | ❌ |
| PATCH | ❌(默认) | ❌ |
关键:HTTP 方法的幂等性是契约而不是自动保证。PUT /users/123 实现里如果每次 +1 计数器,就不幂等了——是实现错误。
三、为什么 exactly-once 是个神话
真相:在分布式系统中,at-most-once + at-least-once 才存在;exactly-once 是端到端业务层面的幻觉。
实现路径:
at-least-once 投递 + 消费端幂等 = 业务上的 exactly-once
关键设计原则:永远假设上游会重发,消费端必须幂等。
四、Idempotency Key 标准模式(Stripe 标杆)
客户端
POST /v1/charges
Idempotency-Key: 8e3a5f4c-2b3d-4f1e-9c8a-1d2e3f4a5b6c
Content-Type: application/json
{ "amount": 1000, "currency": "USD", "customer": "cus_xxx" }
客户端为每个唯一业务请求生成一个 key(UUID v4)。重试同一个请求复用同一个 key。
服务端逻辑
1. 收到请求,提取 Idempotency-Key
2. 查 idempotency 表 (key, request_hash, response, status, expires_at)
3. 找到 key:
a. 状态 = COMPLETED → 直接返回缓存的响应
b. 状态 = IN_PROGRESS → 返回 409 Conflict 或等待
c. request_hash 不匹配 → 返回 422(同 key 不同 body 是错误)
4. 没找到 key:
a. INSERT (key, request_hash, status=IN_PROGRESS) 用主键约束防并发
b. 执行业务
c. UPDATE 表 (response, status=COMPLETED)
d. 返回响应
5. 失败时:
a. 留 key 给客户端重试(24h TTL 后 GC)
b. 或 DELETE key 让重试当新请求
数据库 schema
CREATE TABLE idempotency_records (
key TEXT PRIMARY KEY,
user_id BIGINT NOT NULL, -- 配合 user 隔离
request_method TEXT NOT NULL,
request_path TEXT NOT NULL,
request_hash TEXT NOT NULL, -- SHA256(body) 防同 key 不同请求
status TEXT NOT NULL, -- 'in_progress' | 'completed'
response_code INT,
response_body JSONB,
created_at TIMESTAMPTZ DEFAULT now(),
expires_at TIMESTAMPTZ NOT NULL -- 24h 后清理
);
CREATE INDEX idx_idempotency_expires ON idempotency_records(expires_at);
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.
- 7d ago First seen · 332 lines · 136 tokens per session scan A f11cce0a165d
idempotency-design is a skill published in the GitHub repository cass-2003/local-workflow-skill (12 stars, last pushed 2mo ago), licensed MIT. It adds 136 tokens to every session and 2,868 once invoked, about $0.0007 per session on Opus 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-03.
Other skills, from other repositories
x402
Set up Browser Use Cloud payments with x402 — pay per request from a crypto wallet (USDC on Base mainnet), no signup or API key. Two setups it works out up front — "just use it" (set up a wallet so you or Claude Code can run cloud browser tasks paid from the wallet — Claude writes and runs throwaway scripts, nothing…
tushare
A Python interface for Tushare, a financial data service that provides market and company information for stocks, funds, futures, and digital assets. It returns queried data as pandas tables.
stripe-best-practices
Guides Stripe integration decisions across development and test environment planning (separate sandboxes vs the shared test mode sandbox), API selection (Checkout Sessions vs PaymentIntents), Connect platform setup (Accounts v2, controller properties), billing/subscriptions, tax and registrations (Stripe Tax…
pinme-uniwebpay
Use when generating, modifying, or reviewing PinMe Worker (Cloudflare Worker TypeScript) code that accepts payments through UniwebPay — payment links, products/prices, checkout sessions, payment status reads, refunds, subscriptions, or handling UniwebPay webhooks with @uniwebpay/sdk in a PinMe project.
erp-xpp
Finance and Operations X++ development lifecycle — scaffold models, author classes, custom services/APIs, and data entities, install matching SDKs, compile deployable packages, deploy packages, synchronize databases, and verify deployed artifacts. Use when the user wants to create, build, compile, package, deploy…
kalshi-api
Kalshi exchange mechanics — RSA-PSS auth, order schema, YES/NO orderbook convention, WebSocket, and endpoint surface. Market-type-agnostic shared layer for all Kalshi skills.