principle-make-operations-idempotent

Designs state-mutating operations that converge to the same end state after crashes and retries.

Updated Jul 29, 2026
One-click install
npx skills add https://github.com/mmdmcy/fluttAIrbar --skill principle-make-operations-idempotent-mmdmcy
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: principle-make-operations-idempotent
Source: https://github.com/mmdmcy/fluttAIrbar/tree/main/plugins/pstack/skills/principle-make-operations-idempotent
Command: npx skills add https://github.com/mmdmcy/fluttAIrbar --skill principle-make-operations-idempotent-mmdmcy

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Commands, lifecycle steps, and processing loops that run amid crashes, restarts, and retries often leave partial state behind, turning every restart into a debugging session. This Skill provides a design principle for making operations converge to the correct end state regardless of how many times they run or where they start from. ## Core Features & Use Cases - Convergent Startup Pattern: Scan for existing state, clean stale artifacts, and adopt live sessions instead of assuming a clean slate. - Content-Based Cleanup: Compare artifacts by content equivalence rather than creation order to avoid duplicate or orphaned resources. - Self-Healing Locks and Scheduling: Use PID-based stale lock detection and respawn failed work cleanly with fresh input regenerated after each cycle. - Use Case: When writing a CLI command that provisions resources or a worker loop that processes a queue, apply the three-question test (runs twice, crashed midway, converges?) to identify where reconciliation steps are needed. ## Quick Start Ask the AI to review your command or processing loop using the principle-make-operations-idempotent skill to check whether it converges after crashes and retries.

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 a command or script idempotent?▼

Make a command idempotent by having it scan for existing state at startup, clean stale artifacts, and adopt live sessions rather than assuming a clean slate. Verify it by asking what happens if it runs twice or crashes at every possible point.

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 whether re-execution converges to the same end state. If any answer depends on leftover state, add a reconciliation step.

How do I handle stale lock files after a crash?▼

Use PID-based stale lock detection: record the owning process ID in the lock and check whether that process is still alive before treating the lock as held. Dead PIDs indicate stale locks that can be safely reclaimed.

When should cleanup compare by content instead of creation order?▼

Compare by content equivalence whenever artifacts may be recreated in a different order across runs, such as after retries or partial failures. Creation-order comparison misidentifies duplicates when a previous run crashed midway.

When does idempotency design not apply?▼

Idempotency design matters for state-mutating operations that run amid crashes, restarts, and retries. Pure read-only operations or single-run scripts in controlled environments do not need reconciliation steps.