{"id":21506,"plugin_id":"plugins_6aaeb2c568208191bd71d62167ba2ba3","kind":"skill","collection_source":null,"comparison_source":null,"observed_at":"2026-09-30T23:16:58.337Z","digest":"ffeeb6a2314a3294bc6f36760db229b8c63e792106ce5f14bfd36d7fc62ff9d9","against":null,"payload":{"description":"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.","included_files":[],"name":"principle-make-operations-idempotent","skill_md_contents":"---\r\nname: principle-make-operations-idempotent\r\ndescription: \"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.\"\r\nuser-invocable: false\r\ndisable-model-invocation: true\r\n---\r\n\r\n# Make Operations Idempotent\r\n\r\nDesign operations so they converge to the correct state regardless of how many times they run or where they start from. Every state-mutating operation should answer: \"What happens if this runs twice? What happens if the previous run crashed halfway?\"\r\n\r\n**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.\r\n\r\n**The pattern:**\r\n- Convergent startup: scan for existing state, clean stale artifacts, adopt live sessions\r\n- Content-based cleanup: compare by content equivalence, not creation order\r\n- Self-healing locks: use PID-based stale lock detection\r\n- Idempotent scheduling: failed work respawns cleanly, fresh input regenerated after each cycle\r\n\r\n**The test:**\r\n1. What happens if this runs twice in a row?\r\n2. What happens if the previous run crashed at every possible point?\r\n3. Does re-execution converge to the same end state?\r\n\r\nIf any answer is \"it depends on what state was left behind,\" the operation needs a reconciliation step.\r\n"},"changes":[],"summary":"First saved snapshot. No earlier version is available for comparison.","summary_kind":"deterministic","summary_metadata":{}}