- A hook that stops Claude Code or Codex before risky shell commands and asks you, whether or not the agent thinks to.
- A skill (or
AGENTS.mdsnippet) that teaches any coding agent when to ask and how to read the answer.
The hook: approve risky commands from your phone
finalsay-gate.sh is a PreToolUse hook for both Claude Code and Codex. When the agent is about to run a shell command
that matches a pattern, it asks in FinalSay with Allow and Block, and waits up to 10 minutes.
- Allow → the command runs.
- Block, a written answer, or no answer → the command is blocked and the agent is told why, including your written instruction.
git push, rm -r…, terraform apply|destroy, kubectl apply|delete, npm publish, and
DROP TABLE / DROP DATABASE. It needs jq.
- Claude Code
- Codex
1
Add the script
Copy
examples/agent-hook/finalsay-gate.sh from the finalsay package to .claude/hooks/ in your project,
and make it executable:2
Register the hook
Merge this into Keep the hook
.claude/settings.json:.claude/settings.json
timeout above the wait time (600 seconds by default).Tune it (optional)
The approval shows the full command and the directory, plus Claude’s own description of why it wants to run it (Codex
doesn’t send one). The push notification reads Claude Code: <command> or Codex: <command>.
A hook is a strong guardrail, not a sandbox. It sees the commands the agent runs through its shell tool, so keep
your agent’s own permission settings on as well.
The skill: teach the agent when to ask
Thefinalsay package includes:
-
skill/: an Agent Skill (SKILL.md, plus the icon andagents/openai.yamlCodex shows in its skill list). Copy the folder to your agent’s skills folder: -
AGENTS.md: the same guidance, condensed. Paste it into yourAGENTS.md(Codex reads it as is) orCLAUDE.md.
This works for any agent that runs shell commands: Claude Code, Codex, Cursor, Aider and others.
Prefer MCP?
Claude Code, Codex and other MCP clients can also call FinalSay as tools (request_human_approval,
get_approval_result). See MCP for both. The hook is the stronger guarantee: it runs
whether or not the model decides to ask.