Destructive Commands
Whisp protects you from accidentally running dangerous commands.
Destructive Commands
Whisp includes a safety layer that detects potentially dangerous commands and requires confirmation before adding them to your shell history.
Safety Confirmation
When whisp generates a potentially destructive command, it displays a warning and asks for confirmation:
, delete all files in this folder
➜ rm -rf ./*
⚠️ This command may be destructive
Command: rm -rf ./*
Add to history? [y/N]Only commands you confirm with y are added to your shell history.
Detection Methods
Whisp uses two layers of destructive command detection:
- Server-side: The AI model flags commands it recognizes as dangerous
- Client-side: Pattern matching against known dangerous commands (as a safety net)
This dual approach ensures protection even if the AI doesn't catch something.
Detected Patterns
The following patterns trigger the safety confirmation:
File Deletion
| Pattern | Description |
|---|---|
rm -rf | Recursive force delete |
rm -fr | Same as above (flag order reversed) |
rm -r | Recursive delete (without force flag) |
rm -r / | Recursive delete from root |
rm -rf / | Force recursive delete from root |
rm -rf /* | Delete all root contents |
rm -rf ~ | Delete home directory |
rm -rf * | Delete everything in current directory |
sudo rm -rf | Recursive delete with root privileges |
find .* -delete | Find and delete matching files |
Disk Operations
| Pattern | Description |
|---|---|
dd if= | Direct disk write (can overwrite entire drives) |
sudo dd | Disk write with root privileges |
mkfs | Create filesystem (formats drive) |
mkfs. | Filesystem-specific format (e.g., mkfs.ext4, mkfs.xfs) |
sudo mkfs | Format with root privileges |
wipefs | Wipe filesystem signatures |
shred | Securely overwrite files |
> /dev/sd | Write directly to disk device |
System Modification
| Pattern | Description |
|---|---|
chmod -R 777 / | Make entire system world-writable |
chmod 777 / | Make root world-writable |
mv /* | Move all root contents |
mv / | Move root directory |
Dangerous Constructs
| Pattern | Description |
|---|---|
:(){:|:&};: | Fork bomb (crashes system) |
:(){ :|:& };: | Fork bomb with spaces |
> /dev/null 2>&1 & | Background with suppressed output (suspicious) |
Understanding the Risks
Fork Bomb Explained
The pattern :(){:|:&};: is a fork bomb. It defines a function : that calls itself twice and backgrounds both calls. This creates an exponential process explosion that will freeze or crash your system.
:() # Define a function named ":"
{ # Function body starts
:|:& # Call itself, pipe to itself, background both
}; # End function definition
: # Call the functionNever run this command, even to test it.
Why rm -rf is Dangerous
The rm -rf combination is dangerous because:
-r(recursive): Deletes directories and their contents-f(force): Ignores nonexistent files, never prompts
Combined with a wrong path, this can delete your entire system in seconds:
# DANGEROUS - deletes everything from root
rm -rf /
# DANGEROUS - space before / is a common typo
rm -rf / home/user/folder
# SAFE - deletes only the specified directory
rm -rf ./my-temp-folderSafe vs Unsafe Variations
| Unsafe | Safe Alternative |
|---|---|
rm -rf * | rm -ri * (interactive) |
rm -rf /path | rm -rf ./path (explicit relative) |
dd if=/dev/zero of=/dev/sda | dd with careful target verification |
chmod -R 777 / | chmod -R 755 ./directory |
Disabling Confirmation
For automation or if you prefer to live dangerously:
Per-Command
WHISP_CONFIRM_DESTRUCTIVE=false , delete all temp filesPer-Session
export WHISP_CONFIRM_DESTRUCTIVE=falsePermanently (Not Recommended)
Add to your shell profile (~/.bashrc, ~/.zshrc, etc.):
export WHISP_CONFIRM_DESTRUCTIVE=falseBest Practices
- Keep confirmation enabled — It has probably saved you more than you realize
- Review commands carefully — Read the full command before pressing
y - Use dry-run flags — Many commands support
--dry-runto preview changes - Use the
,dshortcut — Whisp can analyze what a command will do before you run it:,d rm -rf ./build # Shows: Deletes directory ./build and all contents # Reversible: No - Prefer relative paths —
./folderis safer than/folder(typo protection) - Double-check paths with spaces —
rm -rf my folderdeletes TWO things
What's NOT Flagged
Some commands that modify data are intentionally not flagged to avoid alert fatigue:
rm file.txt— Single file deletion (no recursive flag)cp -r— Copying (non-destructive)mv file.txt newname.txt— Renaming within same directorychmod 644 file— Normal permission changesgit reset --hard— Git operations (version controlled)
The goal is to catch catastrophic mistakes, not every potentially risky operation.