Install
Install with PiG
pig install npm:@e4779/shell-gateInstall with Pi
pi install npm:@e4779/shell-gatePackages run code with your permissions and influence agent behavior. Catalog inclusion is not a security audit. Review the source before installing a third-party package.
Pi manifest JSON
The pi field of package.json.
{
"extensions": [
"./index.ts"
]
}README
Written by the package's publisher, shown as published in version 0.2.0 (README.md). PiG does not review it.
shell-gate
Pre-execution shell hygiene gate for agent shell commands and .sh writes.
Why
Agents write shell fast and sloppy, then burn turns debugging quotes character by character. The gate blocks the sloppy command BEFORE execution and hands diagnostics back to the model as the block reason — the fix loop is one turn, with SC codes in hand.
Layers
bash --norc -n— parse check, always available: unbalanced quotes, broken heredocs, parse errors. The "unexpected EOF" class.- ShellCheck — semantic layer (word splitting, quoting,
rm -rfon empty variables). Hostshellcheckbinary first (BSD hosts ship it at /usr/local/bin); on a machine without it,shellcheck-wasm(this package's npm dependency), run bywasm-lint.tsin a child process, one per lint. In-process that runtime crashed after a run of back-to-back lints and its crash could end the agent process; in its own process every crash dies with the lint that caused it, which alone is skipped, silently.
Both layers fail open: any internal error passes the command through.
Bash commands start from a wider suppression list than .sh writes: the
notes that fire on correct one-off commands (unused variables, bare globs,
ls | grep, single-quoted $x, a && b || c) do not block a command,
while word splitting, rm -rf on an unquoted variable and cd x; … (a
failed cd runs the next command in the wrong directory) still do. The list is
DEFAULT_CMD_SUPPRESSED in index.ts; commandSuppressedCodes in the
config replaces it.
What it does NOT catch
Syntactically clean but operationally dangerous commands (git clean -fd,
pkill -f self-matches, blind send-keys). Shell hygiene is not operational
safety — that is a different gate.
Escape hatches
- The model may prepend
# shellcheck disable=SCxxxxdirective lines to confirm an intentional pattern (plain bash comments; ShellCheck respects them). The block reason lists the exact codes to use. PI_SHELL_GATE=offdisables the gate for a session.~/.pi/agent/shell-gate.jsontunes thresholds — see the header ofindex.tsfor every key.
User !-bash (the user_bash event) is never gated.