Skip to main content
reopt Handbook
reopt Handbook
Codex Command MasterLabels and command selectionHow to read a detail guideComplete command listTerminal CLI Commands and Options

Task guides

Core Command GroupSession Command GroupCustom Command GuideMCP Command and Integration GuideDesign Workflows

Conversation and context

Cmd. /archiveCmd. /copyCmd. /importCmd. /cd

Planning and execution

Cmd. /goalCmd. /app

Models and settings

Cmd. /model

Permissions and integrations

Cmd. /pluginsCmd. /hooksCmd. /mcp

Display and input

Cmd. /statuslineCmd. /tuiCmd. /worktreeCmd. /voice

Account and usage

Cmd. /usage

Verification and history

Current verification scopeHandbook updatesRelease coverage historyEarlier verification recordsCommand change history
Handbook›Codex Command Master›Cmd. /hooks
한국어KOEnglishEN

Cmd. /hooks

Review lifecycle hooks and manage trust or disabled state.

Written and reviewed by Eric Han · Co-founder & CTO, reopt

Key takeaways

  • Review lifecycle hooks and manage trust or disabled state.
  • New or changed hooks do not run until you review and trust them in /hooks. Trust is tied to the hook content hash, and managed hooks cannot be disabled by users.

Purpose

Review lifecycle hooks and manage trust or disabled state.

/hooks

Availability

FieldValue
Input surfaceRunning CLI prompt
KindBuilt-in
StatusCurrent reference
Aliases—
Documented minimumNot specified
Reviewed against2026-10-23 · Codex CLI 0.163.0

The installed command menu and account or organization settings determine availability.

Examples

/hooks

When to use it

  1. Run /hooks after adding .codex/hooks.json or inline [hooks] config to verify source and trust state.
  2. Before enabling plugin-bundled hooks, check /plugins for plugin state and /hooks for actual hook behavior.
  3. Record which hooks are managed by policy and which are local project hooks.

Choosing related commands

CommandDifferenceChoose It When
/hooksReviews hook sources and trust stateHooks may run before, during, or after turns
/pluginsShows plugin inventory and bundled hooksYou need to know where a hook came from
/debug-configExplains config layersYou need precedence and policy diagnostics

Where hooks live

LocationScope
~/.codex/hooks.json, [hooks] in ~/.codex/config.tomlAll of your sessions
<repo>/.codex/hooks.json, [hooks] in <repo>/.codex/config.tomlThat project, loaded only when the project .codex/ layer is trusted
A plugin's hooks/hooks.json or the hooks entry in .codex-plugin/plugin.jsonEnabled plugins
Managed hooks from requirements.tomlOrganization policy; users cannot disable them

Hooks from every matching source run, and matching command hooks for the same event start concurrently. One hook cannot stop another from starting.

Minimal configuration

This .codex/hooks.json routes shell commands through a policy script before they run.

{
  "hooks": {
    "PreToolUse": [
      {
        "matcher": "Bash",
        "hooks": [
          {
            "type": "command",
            "command": "python3 \"$(git rev-parse --show-toplevel)/.codex/hooks/check_command.py\"",
            "timeout": 30
          }
        ]
      }
    ]
  }
}

In config.toml, write the matcher group as [[hooks.PreToolUse]] and each handler as [[hooks.PreToolUse.hooks]]. After saving, review and trust the hook in /hooks before it runs.

Hook events

EventWhen it firesWhat it can do
SessionStartSession start, resume, clear, compact, or forkAdd stdout as developer context
SessionEndConversation archived or deleted, Codex closes, or 30 minutes idle (main thread only)Cleanup; 1 second by default, 3 seconds max
SubagentStartA subagent startsAdd stdout as context
SubagentStopA subagent stopsRequest continuation
PreToolUseBefore a supported tool runsDeny or rewrite the call
PermissionRequestBefore an approval prompt appearsAllow or deny
PostToolUseAfter a tool produces outputInspect the result
PreCompact / PostCompactBefore and after compactionPre- and post-processing
UserPromptSubmitBefore a prompt is sentBlock it, or add stdout as context
StopA turn stopsRequest continuation
InterruptThe user interrupts the main turnCleanup; 1 second by default, 3 seconds max

PreToolUse covers shell commands, apply_patch file edits, MCP tool calls, and other local function tools. Hosted tools such as WebSearch are not covered.

Input and output

  • Each hook receives one JSON object on stdin. Common fields are session_id, transcript_path, cwd, hook_event_name, and model; some events add tool_name, tool_input, prompt, or source.
  • Exit code 0 with no output means success. For events that support blocking, exit code 2 blocks the action and uses stderr as the reason.
  • Return a PreToolUse denial in hookSpecificOutput.permissionDecision and a PermissionRequest decision in hookSpecificOutput.decision.behavior (allow or deny). If any matching hook denies, the request is denied.
  • matcher is a regular expression. For tool events it filters tool names such as Bash, Edit|Write, or mcp__filesystem__.*; "*" or an empty value matches everything.
  • timeout is in seconds and defaults to 600. Output over about 2,500 tokens is saved to disk and the model receives a preview.

Effects and persistence

Shows configured hooks and their triggers. Editing a hook changes what runs when its event occurs.

/hooks opens the hook browser so you can inspect configured lifecycle hooks, trust new or changed hooks, and disable individual non-managed hooks before they run.

A startup warning points to /hooks when a hook needs review. Trust is tied to the hook's current hash, so a new or edited hook is skipped until you trust it again.

Cautions

Hooks are on by default. To turn them all off, set hooks = false under [features] in config.toml (codex_hooks is the older name). --dangerously-bypass-hook-trust runs enabled hooks without persisted trust for a single invocation, so keep it out of shared scripts.

  • Managed hooks are trusted by policy and cannot be disabled from the user hook browser.
  • Project-local hooks load only when the project .codex/ layer is trusted.
  • User approval of a project hook is tied to the exact content hash; review and trust it again after a change.
  • MCP hook handlers reuse an existing connection, run synchronously, cannot request approval, and do not trigger other hooks. Treat auth and availability failures as a separate failure path.
  • Hooks are guardrails, but they are not a complete enforcement boundary for every shell or tool path.

Official sources

  • Developer Commands
  • Hooks
  • Changelog

Complete command list · Verification scope · History for this command

Related docs

Hooks

Claude Code Complete Guide · Use Claude Code hooks for predictable automation and repository guardrails.

Cmd. /hooks

Claude Code Command Master · Inspect configured Claude Code hooks and diagnose missing runs by separating event matching, handler failures, and unexpected results.

Ch11. Schedules, State, Hooks

Enterprise Eve Agent Development · Connect Eve cron schedules, durable state, and stream-event hooks to automation, memory, and audit.

Cmd. /update-config

Claude Code Command Master · Use the Claude Code bundled skill to edit the appropriate settings.json from a requested permission, environment, or hook change.

Cmd. /batch

Claude Code Command Master · Parallelize a large change across worktree subagents (skill).

Cmd. /plugins

Browse installed and discoverable Codex plugins.

Cmd. /mcp

List configured MCP tools and inspect server diagnostics.

On this page

PurposeAvailabilityExamplesWhen to use itChoosing related commandsWhere hooks liveMinimal configurationHook eventsInput and outputEffects and persistenceCautionsOfficial sources