Skip to content

Config Studio for Codex

Reference

Hooks

json · rendersdocumented

Your command (or an MCP tool) runs at a point in the session: before a tool, after a prompt, when Codex wants to stop.

Where it lives

The documentation does not say which of these wins when two of them disagree, so this page does not guess.

  1. /etc/codex/requirements.toml

    enterpriseManaged hooks; trusted automatically.

  2. ~/.codex/hooks.json

    userOr [hooks] in ~/.codex/config.toml.

  3. ./.codex/hooks.json

    projectOr [hooks] in .codex/config.toml. Only when the project is trusted.

16 keys

hooks.SessionStartarray
A session starts, resumes, is cleared or compacted. Matcher: startup, resume, clear, compact.
hooks.UserPromptSubmitarray
You send a prompt. Exit 2 or decision block stops it.
hooks.PreToolUsearray
Before a tool runs. Matcher: the tool name (Bash, apply_patch, an MCP tool). Can deny or rewrite the input.
hooks.PermissionRequestarray
Codex is about to ask you. The hook can answer allow or deny instead.
hooks.PostToolUsearray
After a tool ran. Can add context or block the turn; it cannot undo the tool.
hooks.PreCompactarray
Before the context is compacted. Matcher: manual or auto.
hooks.PostCompactarray
After a compaction.
hooks.SubagentStartarray
A subagent starts. Matcher: its agent type.
hooks.SubagentStoparray
A subagent finishes. Block to send it round again.
hooks.Stoparray
Codex is about to stop. Block with a reason to make it carry on.
hooks.Interruptarray
You interrupted a turn. Timeout 1 s by default, 3 at most.
hooks.SessionEndarray
The session ends. Timeout 1 s by default, 3 at most.
hooks[].hooks[].timeoutnumber
Seconds; 600 by default.
hooks[].hooks[].asyncboolean
Runs in the background without holding the turn.
features.hooksboolean
Hooks are on by default; false turns them off.
/hooksstring
Review and trust new or changed hooks; a hook does not run until trusted.

documented Taken from the vendor's documentation at https://learn.chatgpt.com/docs/hooks, last checked on 2026-10-11.