Search⌘ K
AI Features

Idempotent Script Contracts: Exit Codes, Logs, and Dry-Run

Explore how to design and defend an idempotent release script contract. Learn to validate inputs, use meaningful exit codes, emit structured logs, support dry runs, check durable state, and verify that a failed run can be safely retried without duplicating completed work.

How a script behaves after a partial failure tells us a lot about how safe it is, and interviewers often explore this in detail. A safe release script has a contract that answers two questions: can it run again without duplicating a change, and can an operator determine what happened from its evidence?

Idempotence means that repeated runs with the same inputs reach the same intended end state. The first run may stop after creating part of the desired state. When we run the script again, it checks what has already been completed and handles only the remaining work. It does not repeat actions that have already ...