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.5 | $0.00054 | $0.01147 |
| Sonnet 5.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 3mo 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.
- 3mo 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 4mo ago), licensed MIT. It adds 136 tokens to every session and 2,868 once invoked, about $0.0005 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-03.
idempotency-design compared with skills from other repositories
| Mod | Type | Stars | Last push | Licence | Scan | Tokens | Works with |
|---|---|---|---|---|---|---|---|
| idempotency-designcass-2003/local-workflow-skill | Skill | 12 | 4mo ago | MIT | A | 136 | Claude Code, Codex |
| x402browser-use/browser-use | Skill | 123k | today | MIT | A | 166 | Claude Code |
| tushareHKUDS/Vibe-Trading | Skill | 40k | today | MIT | A | 79 | Claude Code, Codex |
| hyperliquid-websocketgalleonlabs/hypergrok-trading-desk | Skill | 652 | yesterday | MIT | A | 89 | Claude Code |
| wechatpay-payment-integrationwechatpay-apiv3/wechatpay-skills | Skill | 380 | 15d ago | MIT | A | 330 | Claude Code, Codex |
| build-a-stripe-integrationsuperset-sh/superset | Skill | 17k | 5d ago | MIT | A | 74 | Claude Code |
| freee-api-skillfreee/freee-mcp | Skill | 528 | today | Apache-2.0 | A | 407 | Claude Code |