agentleFS
hidenobunagaihidenobunagai/astack/skills/principle-make-operations-idempotent/SKILL.md

principle-make-operations-idempotent

Skill1 starsChanged 13 days agoMITView on GitHub

Apply when designing a data load, backfill, export, scheduled job, or any pipeline step that may run again after a crash, retry, or partial failure. Converge to the same end state no matter how many times it runs or where the last run stopped.

47 other projects use a version of this, 44 of them edited.

Adopted by

Most recently taken up by

Used with

Projects with it also use setup-pstack, poteto-help and 4 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • bnemaSkill

    setup-pstack

    Configure which Pi models pstack uses per role. Detects available provider/model specs and writes pstack's user configuration. Use for /setup-pstack, "configure pstack models", or changing pstack model choices.

    Also in 25 projects that use this

  • ianclearySkill

    poteto-help

    Guides users through pstack setup, /poteto-mode, and picking the skill, playbook, or principle for a task. Type /poteto-help with a question.

    Also in 14 projects that use this

  • eryzerzSkill

    make-bot-ui

    Use when building a custom UI (page, dashboard, buttons) that should wake a Grok Bot over a webhook, when the user must provide a webhook sender key, or when exposing that UI on Tailscale.

    Also in 19 projects that use this

  • tristanphvnSkill

    ketchup-video

    Catch the user up like /keel:ketchup, with a short silent video of slides for what happened and the waiting calls as text under it. Use for /keel:ketchup-video.

    Also in 11 projects that use this

  • instructureSkill

    ketchup

    Rebuild context after /clear by analyzing uncommitted changes across Canvas LMS and all plugin repositories

    Also in 19 projects that use this

  • JoshueOsunaSkill

    Poteto Mode

    poteto's agent style for concise, detailed responses, deliberate subagents, unslopped prose, simple code, and verified work. Use for poteto, /poteto-mode, or requests to work in this style.

    Also in 3 projects that use this

The file

We split this skill into the rules it gives an agent

1 rule. 0 are common, 1 is distinctive, and 0 are very specific to this project.

  • 0

    Common

    Most of the 47 edited versions we read keep these.

  • 1

    Distinctive

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Write to a temporary path and rename it into place, so a crash never leaves a half-written table or file.

    line 15

“Common” is measured: kept by at least 6 in 10 of the 47 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Make Operations Idempotent

Design each operation so it converges to the correct state however many times it runs and wherever the previous run stopped. For every write, ask: what happens if this runs twice, and what happens if the previous run crashed halfway?

Pipelines run where crashes, restarts, and retries are normal. If partial state changes the next run's outcome, every restart becomes a debugging session.

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.

  • For a daily load, overwrite the partition for that date instead of appending rows. A rerun then cannot double count.
  • Write to a temporary path and rename it into place, so a crash never leaves a half-written table or file.
  • Compare artifacts by content (a hash, a row count, a key set) instead of by creation order.

Anything a run leaves behind, such as a lock, a temporary file, a half-written table, or a claimed job, must be recognizable as stale by the next run. Judge staleness by evidence that stays true wherever the run stopped, not only in the common case. A marker that the next run cannot judge turns every crash into manual cleanup.

The test has three questions. What happens if this runs twice in a row? What happens if the previous run crashed at every possible point? Does a rerun converge to the same end state? If any answer is "it depends on what state was left behind", the operation needs a reconciliation step.

Changes to a scheduled job or a shared table still need the human's confirmation before they run (see principle-never-block-on-the-human).

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.