principle-make-operations-idempotent
What it does
Gives the assistant a rule for building operations that are safe to retry after a crash. It is for engineers writing commands, jobs or processing loops.
When to use it
- ✓When you design a command or job that might be run again after a failure.
- ✓When restarts, retries or crashes could leave partial state behind.
- ✓When you need a processing loop that can resume safely.
Skill link
https://github.com/cursor/plugins/blob/main/harness/pstack/claude-code/skills/principle-make-operations-idempotent/SKILL.mdCopy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.
How to use
The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.
Ready-to-paste message
For Claude Code, Codex or Cursor: run it in your project folder and the skill gets installed.
Download the SKILL.md and drop it into your agent’s skills folder.
Example of what to ask your AI
“Make our data import job safe to rerun after a crash without duplicating records.”
5 new skills a week. 1 minute to read.
How it works
The assistant derives each step from the current state and applies only the missing difference. It makes leftover markers such as locks or temporary files recognizable as stale, then checks what happens if the job runs twice or crashes at each point.
Technical content (original SKILL.md)
Original text by the author, straight from GitHub.
Make Operations Idempotent
Design operations so they converge to the correct state regardless of how many times they run or where the previous run stopped. Every state-mutating operation should answer: "What happens if this runs twice? What happens if the previous run crashed halfway?"
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.
The idea: derive 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. A step written this way is safe to repeat, because a repeat finds nothing left to do.
Anything a run leaves behind, such as a lock, a temporary file, a half-written record, or a claimed job, must be recognizable as stale by the next run. Judge staleness by evidence that stays true wherever the previous run could have stopped, not only in the common case. A marker that the next run cannot judge turns every crash into manual cleanup. For example, write to a temporary path and rename it into place, or compare artifacts by content instead of by creation order.
The test:
- What happens if this runs twice in a row?
- What happens if the previous run crashed at every possible point?
- Does re-execution converge to the same end state?
If any answer is "it depends on what state was left behind," the operation needs a reconciliation step.
FAQ
What is the key test?
Ask what happens if the operation runs twice in a row, and what happens if the last run crashed at every possible point.
How are leftover locks handled?
They must be judged stale by evidence that stays true wherever the previous run could have stopped.
Is writing to a temp file helpful?
Yes. Writing to a temporary path and renaming it into place is one way to avoid half-written results.
Details
Original description by the author
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.
repo: cursor/plugins
Popularity
- GitHub stars
- 15k
- Ranking position
- #10979
- License
- —
- Updated
- 10/31/2026
Comments
- …
More skills from this repository
advisor
15kLets your agent consult a stronger second model at key checkpoints, such as before a big decision or when stuck on an error, if you turn it on.
check-agent-compatibility
15kRuns a full check of whether AI coding agents can start, verify and document a repository, and returns one compatibility score with the main issues.
cli-for-agents
15kTeaches your agent to design or review command-line tools so AI agents can run them without prompts, with clear help text and examples.
continual-learning
15kKeeps your AGENTS.md notes up to date by handing the work of reviewing past chats to a dedicated memory updater.
Similar skills
api-connector-builder
280kHas your agent build new API connections following the existing pattern. Use when you need to add one more integration without creating a new way of doing things.
api-design
280kHelps your agent design REST APIs following best practices. It's useful for defining how APIs communicate, how errors are shown, and how to organize data.
backend-patterns
280kHelps your agent with server-side architecture patterns and database optimization. It's useful for building or reviewing code that runs on the server.