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

Glossary

Vocabulary that recurs across the docs. Grouped by where the term first appears in the pipeline.

Tool names

What each client calls each tool type.

TermMeaning
BashClaude Code's shell-command tool. The dominant input to tool-gates.
MonitorClaude Code's long-running command tool (background tail, watch loops). Gated by the same rules as Bash.
Read / Write / EditClaude Code's file-operation tools. Write and Edit pass through the security-reminders scanner; Read is checked against file guards.
Glob / GrepClaude Code's file-search tools. Default tool-blocks redirect to fd / rg.
Skill / activate_skillSlash-command activation. Auto-approved via [[auto_approve_skills]] with project-directory conditions.
apply_patchCodex CLI's canonical edit tool. Payload is a unified diff in tool_input.command; tool-gates parses out each *** Add/Update/Delete File: header.
run_command / view_file / write_to_file / replace_file_contentAntigravity CLI (agy) tool names for shell, read, write, and edit. tool-gates maps them onto its Bash / Read / Write / Edit engine.
run_shell_commandGemini CLI's shell tool (deprecated). Same engine as Bash on Claude.
mcp__<server>__<tool>MCP tool name. Double underscore separator on Claude / Codex; single on Gemini (mcp_*).

Hook events

When tool-gates fires.

TermMeaning
PreToolUseClaude Code's primary gate. Decides allow / ask / deny before the call executes.
PermissionRequestClaude Code's subagent gate. Subagents ignore PreToolUse's allow; this hook re-applies the same policy.
PermissionDeniedAuto-mode classifier denied a command; tool-gates checks if its own engine would have allowed it, returns retry: true if so.
PostToolUseFires after execution. Tracks successful asks into the pending queue; scans Write/Edit bodies for Tier 2 anti-patterns.
Antigravity PreToolUseAntigravity CLI's single gate hook. No PermissionRequest event and no usable post payload, so PreToolUse runs the whole gate. Selected via --client antigravity.
BeforeToolGemini CLI's single installed hook (deprecated). It covers the main gate path; tool-gates does not install an AfterTool hook because Gemini post output is unused.

Permission modes

What the assistant is allowed to do without prompting.

TermMeaning
defaultNormal gate flow. Known-safe commands can allow, dangerous commands deny, and unknown or mutating commands ask or defer; Codex prompt visibility also depends on approval_policy.
planRead-only planning mode. tool-gates allows read-only exploration but denies Write/Edit/apply_patch and mutating shell asks, defers, unknowns, and unapproved Claude acceptEdits bases.
acceptEditsPath-safe file-editing commands can auto-allow inside allowed directories. tool-gates extends this to scoped MCP tools via [[accept_edits_mcp]]; Codex does not currently emit this mode and uses [codex] accept_project_edits separately.
autoClaude Code's classifier-driven mode. Asks are decided silently by a server-side classifier instead of prompting. tool-gates promotes hard-asks to deny and emits retry hints when classifier denials disagree with the gate engine.
bypassPermissionsClient-specific bypass mode. If the client still invokes hooks, tool-gates hard denies and configured block rules remain the floor.
approval_policy (Codex)Codex's own axis for whether a tool-gates ask surfaces a prompt: untrusted prompts for every non-safe command, on-request and on-failure lean on the sandbox and mostly don't, never never asks. See the Codex approval model.

Decisions

What tool-gates returns.

TermMeaning
AllowRun without prompting. Read-only and known-safe operations.
AskPause for approval (Yes / No, two buttons). Mutations and unknown commands.
BlockDeny outright regardless of settings.
DeferOmits permissionDecision entirely. Lets the client's own resolver run, which lights up the third "don't ask again for X" button on Claude Code.
warnMarker on an ask rule (warn = true) flagging a dangerous-but-recoverable operation (git push --force, git reset --hard). Surfaces in the Security floor cross-cut.

Pipeline

How the engine works.

TermMeaning
Raw-string passPre-AST security checks for pipe-to-shell, eval, head/tail pipe, etc. Runs before tree-sitter; catches patterns the parser would treat as syntactically valid.
Hard-askAn ask the raw-string pass promotes to deny when permission_mode == auto. No legitimate use case in autonomous operation.
Hard-denyPatterns gated by features.head_tail_pipe_block (and similar). Block before the gate engine runs.
tree-sitterThe Bash AST parser. tree-sitter-bash extracts CommandInfo with program + args + raw form; handles compound commands.
CommandInfoThe internal struct each gate handler receives: program, args, raw.
GateOne of 13 specialised handlers. Most logic is declarative TOML; complex cases use a Rust check_* function.
Custom handlerA Rust function in gates/<gate>.rs registered via TOML's [[custom_handlers]]. Handles logic TOML can't express (path normalisation, method-aware HTTP, SQL parsing).
Strictest winsFor compound commands (&&, ||, |, ;) the harshest per-segment decision becomes the whole-command decision. block > ask > allow > skip.

Storage and state

Where state lives.

TermMeaning
~/.claude/settings.jsonClaude Code permission rules. tool-gates respects every explicit allow / deny / ask before applying its own gate decision.
~/.codex/hooks.jsonCodex CLI hook configuration.
~/.gemini/config/hooks.jsonAntigravity CLI (agy) shared user hook configuration. Keyed by hook name; tool-gates owns the tool-gates entry. Project scope writes .agents/hooks.json.
~/.gemini/antigravity-cli/settings.jsonAntigravity CLI native settings, including the permissions.allow list. tool-gates agy allowlist --apply merges command(<prog>) rules here to stop prompts for read-only commands (a hook allow cannot). Distinct from the hooks file.
~/.gemini/settings.jsonGemini CLI hook configuration (deprecated).
~/.config/tool-gates/config.tomlUser configuration for feature toggles, tool blocking, MCP / Skill auto-approval, file guards, hints, cache, git aliases.
~/.cache/tool-gates/pending.jsonlThe pending-approval queue. Successful asks land here for promotion via tool-gates review.
~/.cache/tool-gates/tracking.jsonPreToolUse → PostToolUse correlation (24h TTL).
~/.cache/tool-gates/available-tools.jsonModern-CLI tool detection cache (7-day TTL).
~/.cache/tool-gates/hint-tracker.jsonSession-scoped deduplication state for modern-CLI hints and security warnings.
tool_use_idClaude Code's per-call identifier used to correlate PreToolUse with PostToolUse. Gemini doesn't provide one (so tracking is Claude-only).

Other

Less common but worth knowing.

TermMeaning
SubagentA delegated Claude Code agent. Ignores PreToolUse's allow; the PermissionRequest hook re-applies policy.
WorktreeA .claude/worktrees/<id> directory used for subagent isolation. tool-gates auto-approves Edit/Write inside the worktree's cwd.
Pattern specificityLength of the non-wildcard prefix in a settings.json pattern. When ask and allow both match, the longer wins; ties go to ask.
$HOME expansionSettings patterns containing $HOME are expanded to the actual home directory before matching.
Drift gateA CI step that runs git diff --exit-code on generated files. Fails the build if a TOML edit didn't trigger a re-run of the generator.
Tier 1 / 2 / 3The three security-reminder severities. T1 denies source writes before they land and warns on doc-file secrets after write; T2 nudges after via system-reminder; T3 informs via additionalContext. See the Security reminders page.

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