Irreversible Action Gate
Some commands are one-way doors. Treat them differently from reversible ones: stop, enumerate what cannot be recovered, shrink the scope, and confirm before the command runs.
Procedure
- Name the action and its irreversibility class: file destruction, history rewrite, data loss, external communication, publication, or money movement.
- Enumerate blast radius in writing: which paths/rows/recipients/targets are hit, and which are outside the blast. Example:
rm -rf build/* hits build/, not src/.
- Take a recoverable copy where possible:
tar czf /tmp/pre-delete-$(date +%s).tgz <paths>; for a DB, a dump; for a branch, git branch backup/$(date +%Y%m%d) HEAD.
- Replace destructive wildcards with an explicit enumerated list. Run the dry variant to print targets first:
find build -maxdepth 1 -type f -print before deleting.
- Run the smallest-scope version first (one file, one row, one recipient), verify the effect, then widen only if the task truly needs it.
- Require confirmation for anything with external or irrecoverable effect. State exactly what will happen: "This will delete 214 files under build/ and force-push origin/main, discarding 2 remote commits."
- Never use
--force/-rf as a reflex. Justify the flag: git push --force-with-lease only after git fetch shows no one else moved the branch.
- Execute the single scoped command, then immediately verify the target state (see
silent-failure-detection).
- For an irreversible side effect that already left the machine (an email, a webhook), record its timestamp and content-hash in the handoff so a duplicate is detectable.
- Prefer a recoverable mechanism over an irreversible one: a
git branch backup over git branch -D, soft-delete over hard-delete.
- For bulk deletion, move to a quarantine directory first (
mkdir -p .trash && mv <glob> .trash/) and delete after verification.
- If confirmation is unavailable, downgrade the action to its reversible form and tell the user what was deferred.
Pitfalls
rm -rf $VAR/ with an empty or unset VAR, expanding to rm -rf /.
git push --force without --force-with-lease, overwriting a colleague's commits.
- Dropping a table before the dump finished, or before checking the dump is non-empty.
- Sending a batch email/campaign to the full list to "test" rather than to one address.
- Deleting a branch, tag, or file that is not backed by a remote and cannot be recovered.
- Running the widened command because the one-file test "worked", without checking the full blast-radius count.
- Treating
git reset --hard as reversible because the commit is in the reflog, when it may already be pruned.
Verification
ls -l /tmp/pre-delete-*.tgz && git branch --list 'backup/*'
# passes when the recoverable copy exists and the dry-run target list matched the actual scope
Report to the user: the exact command, the blast radius count, the recovery copy path, and the confirmation that authorized it.
1---2name: "0xklen-irreversible-action-gate"3description: "Use when about to take an action that cannot be undone: delete, force-push, drop, deploy, publish, send, or spend. Forces an explicit checkpoint, minimal scope, and confirmation so one command cannot destroy irreplaceable state."4metadata:5 source: https://skillmd.com/skills/jiayaoqijia/0xklen-irreversible-action-gate6---78# Irreversible Action Gate910Some commands are one-way doors. Treat them differently from reversible ones: stop, enumerate what cannot be recovered, shrink the scope, and confirm before the command runs.1112## Procedure13141. Name the action and its irreversibility class: file destruction, history rewrite, data loss, external communication, publication, or money movement.152. Enumerate blast radius in writing: which paths/rows/recipients/targets are hit, and which are outside the blast. Example: `rm -rf build/*` hits `build/`, not `src/`.163. Take a recoverable copy where possible: `tar czf /tmp/pre-delete-$(date +%s).tgz <paths>`; for a DB, a dump; for a branch, `git branch backup/$(date +%Y%m%d) HEAD`.174. Replace destructive wildcards with an explicit enumerated list. Run the dry variant to print targets first: `find build -maxdepth 1 -type f -print` before deleting.185. Run the smallest-scope version first (one file, one row, one recipient), verify the effect, then widen only if the task truly needs it.196. Require confirmation for anything with external or irrecoverable effect. State exactly what will happen: "This will delete 214 files under build/ and force-push origin/main, discarding 2 remote commits."207. Never use `--force`/`-rf` as a reflex. Justify the flag: `git push --force-with-lease` only after `git fetch` shows no one else moved the branch.218. Execute the single scoped command, then immediately verify the target state (see `silent-failure-detection`).229. For an irreversible side effect that already left the machine (an email, a webhook), record its timestamp and content-hash in the handoff so a duplicate is detectable.2310. Prefer a recoverable mechanism over an irreversible one: a `git branch` backup over `git branch -D`, soft-delete over hard-delete.2411. For bulk deletion, move to a quarantine directory first (`mkdir -p .trash && mv <glob> .trash/`) and delete after verification.2512. If confirmation is unavailable, downgrade the action to its reversible form and tell the user what was deferred.2627## Pitfalls2829- `rm -rf $VAR/` with an empty or unset `VAR`, expanding to `rm -rf /`.30- `git push --force` without `--force-with-lease`, overwriting a colleague's commits.31- Dropping a table before the dump finished, or before checking the dump is non-empty.32- Sending a batch email/campaign to the full list to "test" rather than to one address.33- Deleting a branch, tag, or file that is not backed by a remote and cannot be recovered.34- Running the widened command because the one-file test "worked", without checking the full blast-radius count.35- Treating `git reset --hard` as reversible because the commit is in the reflog, when it may already be pruned.3637## Verification3839 ls -l /tmp/pre-delete-*.tgz && git branch --list 'backup/*'40 # passes when the recoverable copy exists and the dry-run target list matched the actual scope4142Report to the user: the exact command, the blast radius count, the recovery copy path, and the confirmation that authorized it.