Script Lifecycle
Every script follows four stages: /tmp/ (disposable) → staging/ (proving ground) → scripts/ or codex (permanent) → ~/.local/bin/ (cross-repo). No script starts in ~/.local/bin/.
Script Lifecycle
Every script follows four stages. No script starts in ~/.local/bin/.
The Four Stages
Stage 0: /tmp/ ← tee << 'EOF', iterate, disposable (dies on reboot)
Stage 1: scripts/staging/ ← version-controlled proving ground
Stage 2: Permanent home ← two parallel tracks:
2a: <repo>/scripts/ repo-specific automation
2b: examples/codex/ educational documentation of techniques
Stage 3: ~/.local/bin/ ← proven, cross-repo, stowed from dots-quantum
Stage 0 — Write in /tmp/
tee /tmp/safe-delete.sh << 'EOF'
#!/usr/bin/env bash
set -euo pipefail
for f in tobe*.adoc; do
echo "Found: $f ($(wc -c < "$f") bytes)"
head -1 "$f"
read -p "Delete $f? [y/N] " reply
[[ "$reply" == "y" ]] && rm "$f" && echo "Deleted." || echo "Kept."
done
EOF
cat /tmp/safe-delete.sh # inspect
bash /tmp/safe-delete.sh # execute after review
Zero commitment. Iterate until it works. Dies on reboot.
Stage 1 — Promote to Staging
cp /tmp/safe-delete.sh scripts/staging/
chmod +x scripts/staging/safe-delete.sh
git add scripts/staging/safe-delete.sh
Review weekly: promote or delete. Graduation criteria: used 3+ times.
Stage 2a — Repo-Specific Automation
mv scripts/staging/sync-worklog-nav.sh scripts/sync-worklog-nav.sh
# Wire into Makefile:
# sync-nav: ./scripts/sync-worklog-nav.sh
Stage 2b — Document in Codex
# The safe-delete loop's interesting PATTERN becomes a codex entry
# Not the whole script — the teachable technique
# examples/codex/bash/safe-workflows.adoc
2a and 2b are parallel tracks, not sequential. A script can be operational AND documented.
Stage 3 — Cross-Repo Promotion
cp scripts/staging/validate-adoc.sh \
~/atelier/_projects/personal/dots-quantum/bin/.local/bin/lib/domus/validate-adoc.sh
chmod +x ~/atelier/_projects/personal/dots-quantum/bin/.local/bin/lib/domus/validate-adoc.sh
# Re-stow to create symlinks
cd ~/atelier/_projects/personal/dots-quantum && stow -R -t ~ bin
# Verify
which domus-check # Should resolve to ~/.local/bin/domus-check
What Goes Where
| Script Type | Home | Example |
|---|---|---|
Personal utilities (any machine) |
|
backup, vault, gopass |
Cross-repo domus tooling |
|
validate-adoc, project-check, codex-inventory |
Repo-specific automation |
|
sync-nav, update-monthly-index |
Learning / experimentation |
|
safe-delete loop, ETL drills |
See Also
-
Safe Workflows — the validate-before-act patterns that scripts use
-
Heredocs — the
tee << 'EOF'capture pattern -
Exit Codes —
set -euo pipefailscript header -
Traps — cleanup on exit for temp files