MyNixOS website logo

Lifecycle hook events written to CODEX_HOME/hooks.json.

This option can either be a hook event attribute set, a path to a complete hooks JSON file, or a path to a hook bundle directory containing hooks.json and supporting hook scripts.

Attribute set values use the same event structure as programs.codex.settings.hooks and are written under the top-level hooks key expected by Codex's JSON hooks file.

Directory values install hooks.json to CODEX_HOME/hooks.json and install the full directory to the active Codex home hooks directory. In the default layout, commands can reference bundled scripts with paths such as $HOME/.codex/hooks/my-hook. When home.preferXdgDirectories is enabled, use $CODEX_HOME/hooks/my-hook.

Hooks can also be configured inline through programs.codex.settings.hooks; prefer using only one hook representation per layer.

Declarations
Type
JSON value or absolute path
Default
{ }
Example
{
  PreToolUse = [
    {
      matcher = "^Bash$";
      hooks = [
        {
          type = "command";
          command = "/usr/local/bin/codex-pre-tool-use";
          timeout = 30;
          statusMessage = "Checking Bash command";
        }
      ];
    }
  ];
}