principle-make-operations-idempotent

Designs state-mutating operations to converge to the same end state across crashes, restarts, and retries.

1|Updated Aug 26, 2026
One-click install
npx skills add https://github.com/edivad1999/stuc-stack --skill principle-make-operations-idempotent-edivad1999
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: principle-make-operations-idempotent
Source: https://github.com/edivad1999/stuc-stack/tree/main/skills/principle-make-operations-idempotent
Command: npx skills add https://github.com/edivad1999/stuc-stack --skill principle-make-operations-idempotent-edivad1999

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Commands, lifecycle steps, and processing loops that run amid crashes and retries often leave partial state behind, turning every restart into a debugging session. This Skill provides a design principle for making those operations safe to re-run. ## Core Features & Use Cases - Convergent Startup Design: Scan for existing state, clean stale artifacts, and adopt live sessions instead of assuming a clean slate. - Self-Healing Mechanisms: Apply PID-based stale lock detection, content-based cleanup, and idempotent scheduling that respawns failed work cleanly. - Use Case: When writing a deployment command or a background processing loop, apply the three-question test (runs twice, crashed halfway, converges to same state) to identify where a reconciliation step is needed before shipping. ## Quick Start Ask the AI to review your command or processing loop for idempotency using the make-operations-idempotent principle and identify where partial state could break re-execution.

Frequently Asked Questions about principle-make-operations-idempotent

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I make an operation idempotent?▼

Make an operation idempotent by designing it to converge to the correct end state no matter how many times it runs. Scan for existing state at startup, clean stale artifacts by content equivalence, and add reconciliation steps wherever partial state would change the next run's outcome.

How to handle stale locks after a process crash?▼

Handle stale locks with PID-based stale lock detection: record the owning process ID in the lock and check whether that process is still alive before honoring it. If the PID is dead, the lock is reclaimed automatically instead of blocking forever.

What is the test for whether an operation is idempotent?▼

Ask three questions: what happens if it runs twice in a row, what happens if the previous run crashed at every possible point, and does re-execution converge to the same end state. If any answer depends on leftover state, add a reconciliation step.

When should I not rely on idempotent retries?▼

Idempotent design fits state-mutating commands, lifecycle operations, and processing loops where crashes and retries are normal. It does not replace transactional guarantees for operations requiring strict atomicity across external systems you do not control.