{"data":{"slug":"discovered-b141ee93a4c6ad77f3d1a01b1b3777638fa0c102fc842802","title":"Principle Make Operations Idempotent","summary":"Design state-changing operations to converge to the correct state regardless of how many times they run or where the previous run stopped. Ensure any leftover artifacts from a failed run are recognizable as stale and can be safely cleaned up.","url":"https:\/\/skillshunter.net\/skills\/discovered-b141ee93a4c6ad77f3d1a01b1b3777638fa0c102fc842802","json_url":"https:\/\/skillshunter.net\/api\/public\/v1\/skills\/discovered-b141ee93a4c6ad77f3d1a01b1b3777638fa0c102fc842802","markdown_url":"https:\/\/skillshunter.net\/skills\/discovered-b141ee93a4c6ad77f3d1a01b1b3777638fa0c102fc842802.md","download_url":"https:\/\/skillshunter.net\/skills\/discovered-b141ee93a4c6ad77f3d1a01b1b3777638fa0c102fc842802\/download","category":{"slug":"software-development","name":"Software & Development"},"editor_note":"Operations should write to a temporary path and rename files into place to ensure idempotency. This approach helps avoid leaving stale artifacts that could interfere with subsequent runs.","instructions":"---\nname: principle-make-operations-idempotent\ndescription: For steps that retry after crashes, make every rerun reach one end state.\ndisable-model-invocation: true\n---\n\n# Make Operations Idempotent\n\nDesign every state-changing operation to converge to the correct state however many times it runs and wherever the previous run stopped.\n\nDerive 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.\n\nAnything a run leaves behind (a lock, a temporary file, a half-written record, a claimed job) must be recognizable as stale by the next run, by evidence that holds wherever the previous run could have stopped. Write to a temporary path and rename it into place.\n\nThe test: what happens if this runs twice? What if the previous run crashed at every possible point? If the answer depends on what was left behind, add a reconciliation step.\n","use_cases":["Implementing retry logic in deployment scripts","Ensuring data consistency in batch processing jobs","Designing idempotent API endpoints for safe retries"],"limitations":[],"compatibility":[],"setup_tip":null,"sample_input":null,"sample_output":null,"source_url":"https:\/\/github.com\/jueyi6\/empstack\/blob\/74181e31d2f00313f8683ba157966efcabbe109e\/skills\/principle-make-operations-idempotent\/SKILL.md","source_commit":"74181e31d2f00313f8683ba157966efcabbe109e","license":null,"version":null,"listing_approved_at":"2026-12-02","created_at":"2026-11-30T08:56:17.000000Z","updated_at":"2026-12-02T09:15:14.000000Z","seo_title":"Make Operations Idempotent for Reliable Software Development","seo_description":"Learn how to design idempotent operations that reliably converge to the correct state, even after failures or interruptions.","seo_keywords":["idempotent operations","software development best practices","retry logic","state convergence","deployment reliability"]}}