@firstpick/pi-extension-safety-guard
Interactive guardrails for dangerous bash commands and protected file edits in Pi.
Package details
Install @firstpick/pi-extension-safety-guard from npm and Pi will load the resources declared by the package manifest.
$ pi install npm:@firstpick/pi-extension-safety-guard- Package
@firstpick/pi-extension-safety-guard- Version
0.1.9- Published
- May 22, 2026
- Downloads
- 1,416/mo · 207/wk
- Author
- firstpick
- License
- MIT
- Types
- extension
- Size
- 29.7 KB
- Dependencies
- 0 dependencies · 1 peer
Pi manifest JSON
{
"extensions": [
"./index.ts"
]
}Security note
Pi packages can execute code and influence agent behavior. Review the source before installing third-party packages.
README
pi-extension-safety-guard
Interactive safety prompts for high-risk operations in Pi.
What it does
- Intercepts risky
bashcommands and requires confirmation. - Intercepts
write/editon protected paths and requires confirmation. - In non-interactive mode, blocks risky operations with explicit reasons.
- Can be toggled per session with
/safety-guard on|off|status. - Supports exact allow entries for the current session or permanently per cwd.
Guarded command categories
Git destruction / history rewriting
Examples:
git reset --hardgit reset --soft,git reset --mixed,git reset --merge,git reset --keepgit reset HEAD~...,git reset HEAD^...,git reset <commit>git clean -f, includinggit clean -fd/git clean -xdfgit checkout -- <path>,git switch ..., andgit restore ...git branch -d/-D,git tag -dgit push --force,git push --force-with-leasegit push --delete,git push :refs/heads/...git rebase, including interactive rebasesgit commit --amend,git commit --fixup,git commit --squashgit filter-branch,git filter-repogit replace,git update-refgit notes remove,git notes prunegit reflog expire,git gc --prune,git prune
Filesystem deletion / overwrite
Examples:
- recursive or force
rm rmtargeting/,~,$HOME,., or globsfind ... -deletefind ... -exec rm ...xargs ... rmtruncate -s 0shredddmkfs,wipefs,parted,fdisk,sfdisk,sgdisk
Docker / Podman destruction
Examples:
docker rm,docker rmidocker volume rm,docker volume prunedocker system prunedocker compose down -v/--volumesdocker-compose down -v/--volumespodman rm,podman rmi,podman system prune
Package removal
Examples:
npm uninstall/remove/rm/prunepnpm remove/pruneyarn remove/autocleanbun removepip uninstall,uv remove,cargo removepacman -R,paru -R,yay -Rapt remove/purge/autoremove,dnf remove
System state / permissions
Examples:
sudoshutdown,reboot,poweroffsystemctl stop/disable/mask/restartkillall,pkill,kill -9mount,umount,swapon,swapoff- recursive
chmod/chown chmod 777setfacl- common fork-bomb signature
Dangerous SQL
Examples:
DROP DATABASE,DROP SCHEMADROP TABLE,DROP INDEXTRUNCATE/TRUNCATE TABLEDELETE FROM ...withoutWHEREUPDATE ... SET ...withoutWHEREALTER TABLE ... DROP COLUMN/CONSTRAINT
SQL rules are matched against the full bash command, including heredoc bodies, so database client calls like psql <<SQL ... SQL can still be guarded.
Secret file access
Examples of commands that may reveal or copy secrets are prompted when targeting sensitive files:
cat,grep,rg,awk,sed,cp.env,.env.*,.git-credentials,auth.jsonid_rsa,id_ed25519.npmrc,.pypirc,.netrc.aws/credentials,.aws/config,.kube/config.config/gh/hosts.yml,.config/gcloud/...*.pem,*.key,*.p12,*.kdbx
Protected paths
write and edit prompts are triggered for sensitive paths including:
.ssh/.git-credentialsauth.jsonid_rsa,id_ed25519, and matching.pubfiles.env,.env.*,.envrc.npmrc,.pypirc,.netrc.kube/config.aws/credentials,.aws/config.config/gh/hosts.yml.config/gcloud/*.pem,*.key,*.p12,*.kdbx
Install
pi install npm:@firstpick/pi-extension-safety-guard
Configuration
No required configuration.
Permanent allows are stored in:
~/.pi/agent/safety-guard-allow.json
Allow entries are exact matches scoped to the current working directory:
- bash: exact command string + cwd
- write/edit: resolved protected path + cwd
When a guard prompt appears, choose one of:
BlockAllow onceAllow for this sessionAlways allow in this cwd
Commands
/safety-guard status
/safety-guard on
/safety-guard off
/safety-guard allow-list
/safety-guard allow-clear-session
/safety-guard allow-clear-permanent
When disabled, the status bar shows 🔓!.
allow-list shows both session and permanent entries. allow-clear-session clears only the in-memory list. allow-clear-permanent empties the persisted allow file.
Tools
None.
Example view
!git reset --hard
Safety guard: high-risk git command detected
Allow this command? No / Yes
edit .env
Safety guard: protected path detected (.env)
Allow edit? No / Yes
The guard adds a pause before risky shell commands or sensitive file edits, while still letting you proceed intentionally.