# How do I make OpenAI's Codex ask before risky commands?

> One command puts a fail-closed Immiscible hook in front of Codex, so a force push, a deploy or a secret leaving the machine is refused or waits for a person, by the same rules as every other coding agent.

Source: https://immiscible.fly.dev/docs/answers/codex-agent-safety

Run `npx immiscible guard --agents codex`. It puts one fail-closed hook in front of Codex: a `PreToolUse` hook for `Bash`, `apply_patch` (each file of a patch is checked) and MCP tools, in `~/.codex/hooks.json`, or for everyone on the machine in Codex's managed `requirements.toml` with `allow_managed_hooks_only = true`. With no account the hook decides on your machine and sends nothing; `--connect` sends the questions to your workspace, so approvals reach Slack, Teams, email or your phone. `guard` and these hooks are in the next CLI release, 0.3.0, not yet on npm; until then, run it from a checkout of the repository.

## What does it stop?

The same rules as for Claude Code and the other agents: a force push to `main` or a release branch, `rm -rf` of the root or home directory and a secrets file sent off the machine are refused; publishing a package, `terraform apply`, `kubectl` against production and the network after a secret was read are asked about. Codex hooks can only allow or block, so a call that needs a person is held while someone answers in Slack, Teams, email or on the phone (up to four minutes), then goes ahead or is refused with the approval link.

## What if Immiscible cannot be reached?

The call is refused, with the reason. A missing hook file, a missing `node` or a crash refuses it too: the hook fails closed, so an outage never lets a call through unchecked.

## Anything specific to Codex?

Codex runs a hook from a person's own settings only after they trust it under `/hooks`; hooks in the managed file need no trust step. The details, and every file each agent reads, are in [hooks for other coding agents](https://immiscible.fly.dev/docs/guides/coding-agent-hooks.md).

## What does it not do?

- It governs the calls the hook sees: shell commands, file writes and MCP tools. Model inference Codex runs on its vendor's own servers does not pass through it.
- It does not read or change your code. `immiscible scan` (from 0.3.0) shows what the agents already did, from the history they keep on your machine.
