Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Custom Handlers

Each handler is a Rust function called by the gate when declarative TOML can't express the rule. The TOML declares [[custom_handlers]] with a program and handler name; the gate's Rust file implements the handler. Listed by gate.

filesystem

Path-aware logic.

ProgramHandlerWhat it does
rmcheck_rmNormalises paths (///, /./); blocks destructive targets (/, ~/); flags traversal patterns (.., ../, bare *) with ask-and-warn.
tarcheck_tarDecodes combined flags (-tvf, -xf, -cf); allows list mode, asks for extract/create.

network

Method and flag dispatch.

ProgramHandlerWhat it does
curlcheck_curlDetects HTTP method from -X/--request, presence of -d/--data, and download flags -o/-O. Routes GET to allow, mutations and downloads to ask. Also asks on GitHub content URLs (hint nudges toward gh api).
nccheck_netcatHard-blocks -e (reverse shell); asks on -l (listen mode); applies the same rules to ncat and netcat aliases.
wgetcheck_wgetAllows --spider (URL-resolves only); asks on downloads, recursive modes, post bodies.
http / xhcheck_httpieAllows GET (URL-only or GET verb); asks on POST / PUT / DELETE / PATCH.
rsynccheck_rsyncAllows --dry-run / -n; asks on actual syncs (with --delete noted in the reason).

cloud

Multi-word subcommand patterns.

ProgramHandlerWhat it does
gcloudcheck_gcloudThree-word subcommand routing (gcloud compute instances create). Allows list / describe / get actions; asks on create / delete / update / deploy.
dockercheck_dockerHandles docker compose with flags between the subcommand (e.g. docker compose -f x.yml config).

system

SQL parsing, prefix matching.

ProgramHandlerWhat it does
sudocheck_sudoExtracts the underlying command and asks with a descriptive reason naming the inner program. -l / -v / -k allow without execution.
systemctlcheck_systemctlChecks for read-only ops (status, list-units, is-active, etc.) before falling back to declarative rules.
apt / dnf / brewcheck_apt, check_dnf, check_brewEach package manager has its own handler that checks read-only subcommands (search, list, show, info) before falling back to declarative rules.
pacmancheck_pacmanPrefix matching on -S (sync), -R (remove), -U (upgrade), -D (database).
makecheck_makeAllows known-safe targets (test, check, lint, build, clean, format); asks for unknown targets with the target name in the reason.
psql / mysqlcheck_psql, check_mysqlParses -c / -e query strings; allows SELECT / SHOW / \d; asks on INSERT / UPDATE / DELETE. -f always asks (file content unknown).
kill / pkillcheck_kill, check_pkillAllows -0 (process-exists check) and -l / -L (list signals). Anything else asks.
crontabcheck_crontabAllows -l (list scheduled tasks); asks on edit or write operations.

basics, package_managers, others

Inner-command checking, wrapper resolution.

ProgramHandlerWhat it does
xargscheck_xargsAllows only when the target command is itself in safe_commands; otherwise asks. Also handles xargs sh -c '…' by parsing the inner script.
bash / sh / zshcheck_shell_cParses -c '…' arguments and runs each inner command through the gate engine.
commandcheck_command_builtinAllows command -v / -V (lookup only). Evaluates other invocations through the gate engine as transparent wrappers.
sdcheck_sdWithout file args, sd is a stdin→stdout pipe (safe). With file args, it modifies in place (ask).
npm / pnpm / yarn / buncheck_npm, etc.Handles devtool delegation (npm eslint, pnpm biome) by routing to the devtools gate. Bare yarn resolves to yarn install.
uv / poetry / pipx / misecheck_uv, etc.Routes uv run <tool> / poetry run <tool> / mise exec <tool> through the devtools gate. Mise task expansion adds another layer.
gitextract_subcommand, check_git_addStrips global flags (-C, --git-dir, -c) to find the real subcommand. check_git_add handles git add -A / --all / . / wildcard with extra care.
shortcheck_short_apiFor short api: allows GET, asks POST / PUT / PATCH / DELETE.

The generated gate function returns Skip for any program with a custom handler. The Rust wrapper file then takes over. Without that wiring the handler never fires; see the Contributing page for the pattern.

tool-gates · permission gate hook for Claude Code, Codex CLI, and Antigravity CLI, with deprecated Gemini CLI support. github.com/camjac251/tool-gates

13 gates · 400+ commands · built from rules/*.toml