pi-restrict-bash
Opinionated bash tool restrictions for Pi
Package details
Install pi-restrict-bash from npm and Pi will load the resources declared by the package manifest.
$ pi install npm:pi-restrict-bash- Package
pi-restrict-bash- Version
2.0.0- Published
- Apr 1, 2026
- Downloads
- 116/mo · 7/wk
- Author
- kotarac
- License
- GPL-2.0-only
- Types
- extension
- Size
- 21.1 KB
- Dependencies
- 0 dependencies · 1 peer
Pi manifest JSON
{
"extensions": [
"./extensions/restrict-bash.ts"
]
}Security note
Pi packages can execute code and influence agent behavior. Review the source before installing third-party packages.
README
pi-restrict-bash
Opinionated restrictions for Pi’s built-in bash tool.
The extension blocks common “escape hatches”, risky shell features, and context-exploding commands, nudging the agent toward Pi’s structured tools (read, edit, write) and toward using rg (via bash) for searching/listing.
What it does
The extension intercepts tool calls and blocks:
- Tool calls to
grep,find, andls bashcommands that use unsafe shell features (for example command substitution, variable expansion, redirects, background execution, subshell syntax, and control-flow keywords)bashcommands that invoke disallowed programs (for examplesudo, nested shells likebash/sh/zsh,cat,tee,xargs,nl,fd/find/grep/ls/tree)bashwrapper commands likeeval,exec,nohup,timeout,time,watch, andstdbuf- command-runner launchers like
npx,uvx,bunx,pnpx,pnpm dlx,yarn dlx,npm exec,bun x,uv tool run, and scaffolding launchers likenpm create/npm init/yarn create/pnpm create/bun create(pnpm execandyarn execare intentionally allowed) gitsubcommands that can mutate the working tree or repository (andgit grep, sincergis preferred)sed -i/sed --in-place
When a command is blocked, Pi shows a reason string explaining what was denied.
Install
This repo is a Pi package (see package.json#pi.extensions). Once installed, Pi auto-discovers and loads the extension.
Global install (writes to ~/.pi/agent/settings.json):
- From GitHub:
pi install git:github.com/kotarac/pi-restrict-bash
- From npm:
pi install npm:pi-restrict-bash
Project-local install (writes to .pi/settings.json in your project):
- From GitHub:
pi install -l git:github.com/kotarac/pi-restrict-bash
- From npm:
pi install -l npm:pi-restrict-bash
Try without installing
Try the package for a single run:
- From GitHub:
pi -e git:github.com/kotarac/pi-restrict-bash
- From npm:
pi -e npm:pi-restrict-bash
Notes
- This is not a replacement for proper sandboxing. It only applies guardrails to Pi tool usage and serves as guidance for LLMs; it does not make executing untrusted code safe.
- You’ll likely want to pair this with system instructions that strongly prefer Pi’s structured tools (
read,edit,write), and for searching/listing preferrg(for examplerg,rg --glob,rg --files,rg --files --glob) invoked via thebashtool. - Many restrictions are about keeping tool output and shell behavior predictable so it doesn’t explode the LLM context (for example
find/ls/tree, pipelines, redirects, and wrapper commands). - This extension is intentionally strict. If you need to loosen rules, fork and adjust
forbiddenRules/blockedToolsinextensions/restrict-bash.ts. - Extensions execute with full system permissions. Only install code you trust.
License
GPL-2.0-only