Revision: 1 Last modified: 2026-12-04T18:15:21Z
This is a DATA FILE, not a script. It has no shebang, is never executed, and is mode rw-rw-r--.
scripts/lib/protected_paths.list is the list of protected deletion targets for §11.4.287. It is read at run
time by scripts/lib/safe_rm.sh, which refuses to delete anything that resolves to an entry in it.
Important scope note, stated in the file itself: the PreToolUse guard
scripts/hooks/guard-destructive-paths.py does NOT read this file. The guard carries its own hardcoded,
independent protected set which is a superset of this list, and
scripts/hooks/test_guard_bypasses.py fails if any entry here is missing from the guard (and if the guard fails
to block any entry). So editing here is only half a change: the guard's sets must be updated too.
One entry per line:
- Blank lines and lines whose first non-space character is
#are ignored. - Leading and trailing whitespace is trimmed. No inline comments.
- An entry starting with
/is an absolute protected path. A delete target whose fully resolved path (readlink -m) equals it is refused./itself is refused by the consumer unconditionally and need not be listed. - An entry starting with
~/is a home-relative protected child. The part after~/is a single path component, optionally a shell glob (*,?,[...]), matched against the first component below every home directory the consumer treats as a home ($HOME,SAFE_RM_EXTRA_HOMES). A target that resolves exactly to<home>/<matching component>is refused. Paths deeper inside it are not refused by this list — for example<home>/Projects/app/buildstays deletable. - Any other line is a format error, and consumers MUST fail closed on it.
- A consumer that cannot read this file, or finds no absolute entry in it, MUST refuse every delete (fail closed) — never fall back to "nothing is protected".
- Read by
scripts/lib/safe_rm.sh, which requires it to exist beside that library (the library resolves its own real path first, so a symlinked or renamed copy of the library does not find it and refuses). - No environment variables of its own; the consumer's
SAFE_RM_*variables affect how entries are applied.
You do not run this file. You either rely on safe_rm.sh (which loads it) or extend it:
# inspect the effective list
grep -vE '^[[:space:]]*(#|$)' scripts/lib/protected_paths.list
# prove the library refuses a listed absolute path
bash -c '. scripts/lib/safe_rm.sh; safe_rm_rf /etc; echo "rc=$?"'
# prove the library refuses a listed home-relative child
bash -c '. scripts/lib/safe_rm.sh; safe_rm_rf "$HOME/.ssh"; echo "rc=$?"'None — it is data. The behaviour it causes is in safe_rm_rf: a refused target returns 2 and deletes
nothing. A malformed line makes every call refuse with 2 (message naming the line number).
Two sections, separated by comments:
System directories (absolute): /bin, /boot, /dev, /etc, /lib, /lib32, /lib64, /libx32,
/opt, /proc, /root, /run, /sbin, /srv, /sys, /usr, /var, /mnt, /media, /snap, /home,
/tmp, /Users.
Home-relative protected children: ~/scripts, ~/Projects, ~/.ssh, ~/.gnupg, ~/.claude*, ~/.config,
~/.local, ~/vasic, ~/ytdlp, ~/backups, ~/.cache.
- Absolute entries match exactly, not as subtrees.
/varis refused;/var/tmp/foois not, and is guarded only by the depth rule and bySAFE_RM_ALLOWED_ROOTSif the consumer set it. This is stated in the file and in the library header rather than left to be discovered. - A
~/entry protects only the top-level component.~/.cacheis refused;~/.cache/pipis deletable. - An unlisted direct child of a home is not protected here. The guard protects
Documents,Desktop,Downloads,Pictures,Music,Videos,Obsidian,bin,go,opt,Android,.git,.aws,.kube,.docker,.password-store, but those are absent from this list — a tracked gap recorded on 2026-10-26. /home,/tmpand/Usersare listed so the roots themselves are refused; the children of/homeand/Usersare refused by the library's separate home-root rule, and anything below the temp root gets the depth bonus.- Adding a fifth entry form is a format error by design — the closed set (absolute, or single-component
~/pattern) is what lets consumers fail closed with confidence.
safe_rm.shresolves its own real path and derives this file's path beside it._safe_rm_load_listreads line by line, trims, skips blanks and#comments.- For an absolute entry it strips trailing slashes and records both the entry and its
readlink -mresolution, so a symlinked protected path is also covered. - For a
~/entry it records the component (rejecting empty,/-containing,.and..), keeping any glob metacharacters for matching. - Any other shape, or zero absolute entries, aborts the load with a line-numbered error, and every
safe_rm_rfcall then refuses.
scripts/lib/safe_rm.sh— the only in-repo consumer; seedocs/scripts/safe_rm.md.scripts/hooks/guard-destructive-paths.py— the PreToolUse guard with its own superset set.scripts/hooks/test_guard_bypasses.py— asserts every entry here is also blocked by the guard.scripts/lib/test_safe_rm.sh— the library's suite, including the fail-closed list cases.
2026-12-04 — the file exists, is readable, and parses to 23 absolute entries and 11 home-relative entries:
grep -cE '^[[:space:]]*/' scripts/lib/protected_paths.list; \
grep -cE '^~/' scripts/lib/protected_paths.listExpected: 23 then 11. (Counting is content-only; the authoritative behavioural check is
bash scripts/lib/test_safe_rm.sh, which reports total: PASS n FAIL 0.)