Skip to content

codex-destructive-shell-guard

Block critical destructive shell commands in Codex.

hook PreToolUse codex mode: enforce

Block critical destructive shell commands in Codex.

FieldValue
idcodex-destructive-shell-guard
status_messageChecking shell safety
modeenforce
logical_eventPreToolUse
matcherBash|bash|run_shell_command|shell|terminal
commandpython3 {repo_root}/hooks/wagents-hook.py codex-destructive-shell-guard --harness {harness}
timeout5
harnesses["codex"]
Full hook config + command reference
config/hook-registry.json (entry)
{
"id": "codex-destructive-shell-guard",
"description": "Block critical destructive shell commands in Codex.",
"status_message": "Checking shell safety",
"mode": "enforce",
"logical_event": "PreToolUse",
"matcher": "Bash|bash|run_shell_command|shell|terminal",
"command": "python3 {repo_root}/hooks/wagents-hook.py codex-destructive-shell-guard --harness {harness}",
"timeout": 5,
"harnesses": [
"codex"
]
}
hooks/wagents-hook.py (policy)
def _policy_codex_destructive_shell_guard(payload: NormalizedPayload) -> int:
if _tool_name(payload) not in SHELL_TOOL_NAMES and not payload.command:
return 0
reason = _destructive_shell_reason(payload.command)
if reason:
return _deny(payload, reason, policy_id="codex-destructive-shell-guard")
return 0

Command: python3 .../wagents-hook.py codex-destructive-shell-guard --harness codex


View source on GitHub