Skip to content

8.6 Idempotent scripts

Running a script or a skill twice is harmless: each step checks what is in place and skips it (SPEC.md Q-6; root CLAUDE.md (CLAUDE.md), "Rules the scripts follow"). The reason: the scripts are run again after every new repository and every token change, and a machine, sandbox or session that restarts runs its setup again (chapter 2; lessons-learned.md).

Rules

  1. A second run changes nothing. A script compares the state it wants with the state it finds and acts only on the difference, as sandboxes.sh setup does for a sandbox and its network rules (setup/linux-host.md, setup/network-allowlist.md).
  2. It says what it did. A step reports whether it found the state in place or wrote it, as the dev-env baseline's ok and written lines do (setup/claude-baseline.md).
  3. Drift is reported, not overwritten. What a script does not own—an allow rule added by hand, a branch with a later commit—is reported and left alone until the owner or a flag such as --prune-network says otherwise (setup/network-allowlist.md, sdlc/quality-gate.md).
  4. A root step skips what is in place too, so the owner can run the printed sudo command again without harm (setup/linux-host.md).
  5. A skill that copies a template never overwrites an existing file without asking (SPEC.md REQ-8).

Where it is described

Topic How-to
The host scripts and what each sets up setup/linux-host.md
The owner's workstation's scripts setup/owners-workstation.md
The environment check and its -Fix dev-env README (plugins/dev-env/README.md)