← Catalog

@e4779/shell-gate

pi extension: shell command valve — bash parse check + ShellCheck before bash runs

Extension

Install

Install with PiG

pig install npm:@e4779/shell-gate

Install with Pi

pi install npm:@e4779/shell-gate
Review before installing

Packages 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

  1. bash --norc -n — parse check, always available: unbalanced quotes, broken heredocs, parse errors. The "unexpected EOF" class.
  2. ShellCheck — semantic layer (word splitting, quoting, rm -rf on empty variables). Host shellcheck binary first (BSD hosts ship it at /usr/local/bin); on a machine without it, shellcheck-wasm (this package's npm dependency), run by wasm-lint.ts in 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=SCxxxx directive lines to confirm an intentional pattern (plain bash comments; ShellCheck respects them). The block reason lists the exact codes to use.
  • PI_SHELL_GATE=off disables the gate for a session.
  • ~/.pi/agent/shell-gate.json tunes thresholds — see the header of index.ts for every key.

User !-bash (the user_bash event) is never gated.