Agent Skills
› aiming-lab/MetaClaw
› idempotent-script-design
idempotent-script-design
GitHub指导编写幂等脚本、定时任务和数据管道,确保多次运行无副作用。涵盖创建前检查、Upsert、原子写入和进度追踪等技术,避免重复数据处理错误。
Trigger Scenarios
编写需要重复执行的自动化脚本
设计数据管道或Cron作业
处理可能重复运行的任务
Install
npx skills add aiming-lab/MetaClaw --skill idempotent-script-design -g -y
SKILL.md
Frontmatter
{
"name": "idempotent-script-design",
"category": "automation",
"description": "Use this skill when writing scripts, cron jobs, data pipelines, or any automated process that may be run multiple times. Design every operation to be safely re-runnable without side effects."
}
Idempotent Script Design
An idempotent operation produces the same result whether run once or ten times.
Techniques:
- Check before create:
CREATE TABLE IF NOT EXISTS,mkdir -p, check file existence before writing. - Upsert instead of insert: Use
INSERT ... ON CONFLICT DO UPDATEin SQL. - Atomic writes: Write to a temp file, then rename — prevents corrupt partial output.
- Track progress: Write a completion marker or checkpoint so reruns skip done work.
Testing idempotency: Run your script twice on the same input and verify the output is identical.
Anti-patterns:
- Appending to a file without checking if the data is already there.
- Inserting rows without checking for duplicates.
Version History
- 922caf3 Current 2026-07-25 11:08


