本文へスキップ
Skillpedia
APIとサーバー(バックエンド)15k · #10979

principle-make-operations-idempotent

できること

このスキルは、クラッシュ後に安全に再試行できる操作を作るための規則を、アシスタントに与えます。コマンド、ジョブ、処理ループを書くエンジニア向けです。

使う場面

  • ✓失敗後に再実行されるかもしれないコマンドやジョブを設計するとき。
  • ✓再起動、再試行、クラッシュで部分的な状態が残りうるとき。
  • ✓途中から安全に再開できる処理ループが必要なとき。

スキルのリンク

https://github.com/cursor/plugins/blob/main/harness/pstack/claude-code/skills/principle-make-operations-idempotent/SKILL.md

コピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。

使い方

いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。

貼り付け用メッセージ

このスキルを使って手伝ってください:https://github.com/cursor/plugins/blob/main/harness/pstack/claude-code/skills/principle-make-operations-idempotent/SKILL.md このリンクのSKILL.mdファイルを読んで、私の作業でその指示に従ってください。
こういうスキルを、AIが自分で見つけてくれたら?無料のSkillpedia MCPをインストール。1行で、作業の前に15,000+のスキルから探してくれます。1分でインストール →

AIへの頼み方の例

“データのインポートのジョブが、クラッシュ後に、レコードを重複させずに安全に再実行できるようにしてください。”

毎週5つの新しいスキル。1分で読めます。

仕組み

アシスタントは、各ステップを現在の状態から導き、不足している差分だけを適用します。ロックや一時ファイルなどの残骸が古いものだと分かるようにし、各地点で二度実行したりクラッシュしたりした場合に何が起きるかを確認します。

技術的な内容(元のSKILL.md)

作者による元のテキスト(英語)をGitHubからそのまま表示しています。

Make Operations Idempotent

Design operations so they converge to the correct state regardless of how many times they run or where the previous run stopped. Every state-mutating operation should answer: "What happens if this runs twice? What happens if the previous run crashed halfway?"

Why: Commands, lifecycle operations, and processing loops run where crashes, restarts, and retries are normal. If partial state changes the next run's outcome, every restart becomes a debugging session.

The idea: derive each step from the state that exists, not from what the previous run meant to do. Read the current state, compare it to the goal, and apply only the difference. A step written this way is safe to repeat, because a repeat finds nothing left to do.

Anything a run leaves behind, such as a lock, a temporary file, a half-written record, or a claimed job, must be recognizable as stale by the next run. Judge staleness by evidence that stays true wherever the previous run could have stopped, not only in the common case. A marker that the next run cannot judge turns every crash into manual cleanup. For example, write to a temporary path and rename it into place, or compare artifacts by content instead of by creation order.

The test:

  1. What happens if this runs twice in a row?
  2. What happens if the previous run crashed at every possible point?
  3. Does re-execution converge to the same end state?

If any answer is "it depends on what state was left behind," the operation needs a reconciliation step.

よくある質問

重要なテストは何ですか?

その操作を続けて2回実行したら何が起きるか、そして前回の実行が各時点でクラッシュしたら何が起きるかを問うことです。

残ったロックはどう扱いますか?

前回の実行がどこで止まっていても成り立つ証拠によって、古いと判断しなければなりません。

一時ファイルに書くのは役立ちますか?

はい。一時的なパスに書いてから所定の場所にリネームすると、書きかけの結果を避けられます。

詳細

作者による元の説明

Apply when designing commands, lifecycle steps, or processing loops that run amid crashes, restarts, and retries. Converge to the same end state regardless of partial prior runs.

repo: cursor/plugins

人気

GitHubのスター
15k
ランキング
#10979
ライセンス
—
更新日
2026/10/31

このスキルは役に立ちますか?

0

ログイン して投票しましょう。

コメント

  • …

このリポジトリの他のスキル

似ているスキル