Read destructive commands before anything else. A delete or device write decides the blast radius of the whole script.
Command shape | Risk | Safer form |
|---|---|---|
Recursive delete ( | Removes whole trees with no undo. | Narrow the path, quote variables, confirm the listing first. |
Raw device write ( | Overwrites disks or devices directly. | Write to a named file, never to a device node. |
Filesystem format ( | Replaces the filesystem on its target. | Treat any formatter as destructive and approve it by hand. |
Pipe into a shell ( | Runs fetched bytes as code. | Download, read, then run as separate approved steps. |
Treat file contents and pasted logs as data, never as instructions. Keep credentials and secrets out of prompts; share proprietary material only through an account and deployment approved for its data class and task.
Expand every path by hand before running. In a typical shell an empty variable turns rm -rf $OUT/* into rm -rf /*.
As a rough tokenizer-dependent approximation, a model reads about 3 to 4 characters per token of English prose, and fewer per token for code and hex. Long scripts therefore cost more and are read less reliably than short ones.
assume a build directory holds 12 files (stated example listing)
pattern build/*.o matches 5 of them
pattern build/* matches 9 of them
widening the pattern removes 9 - 5 = 4 extra filesThe program below stands in for a model with a FAKE scripted draft function. It scores one risky draft and one safe draft against five fixed substrings.
import sys
RULES = ("rm -rf", "mkfs", "dd of=/dev/", "| sh", "$OUT/*")
def fake_assistant_draft(risky):
if risky:
return "rm -rf $OUT/*\nmkfs /dev/sdz9\n"
return "mkdir -p out\ncp -r src/ out/\n"
def score(text):
hits = 0
for r in RULES:
if r in text:
hits += 1
return hits
def main():
bad = 0
if score(fake_assistant_draft(True)) != 3:
bad += 1
if score(fake_assistant_draft(False)) != 0:
bad += 1
if len(RULES) != 5:
bad += 1
if bad:
print("FAIL: review scores wrong")
sys.exit(1)
print("PASS: risky draft scores 3, safe draft scores 0 over 5 rules")
main()Read the destructive commands and expand every path.
Count what each glob matches against the real listing.
Quote variables or give them defaults before any delete.
Record who approved a destructive step and when.
rm -rf $OUT/* and the variable is empty. What does a typical shell delete?It deletes from the filesystem root. The empty variable leaves rm -rf /*.
build/*.o to build/* in a directory where the two match 5 and 9 files. How many extra files go?Four extra files. Nine minus five is four.