skills/codex-cli-hooks/SKILL.md
Use when designing, implementing, reviewing, or debugging Codex CLI hooks, including `hooks.json`, `.codex/hooks.json`, feature-flag setup, matcher behavior, event-specific stdin/stdout payloads, and hook scripts for `SessionStart`, `PreToolUse`, `PostToolUse`, `UserPromptSubmit`, or `Stop`.
npx skillsauth add narumiruna/agent-skills codex-cli-hooksInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Design Codex hooks from the current workspace outward: enable the feature flag, choose the right config layer, then implement the smallest hook that proves the event contract before adding policy logic.
Treat hooks as workflow guardrails, not absolute enforcement. Current runtime support is intentionally partial, especially for shell interception.
config.toml for:
[features]
codex_hooks = true
Remember hooks are currently disabled on Windows.~/.codex/hooks.json for personal defaults and <repo>/.codex/hooks.json for repo-specific behavior. Matching hooks from multiple files all run; higher-precedence config does not replace lower-precedence hooks.SessionStart for startup or resume context, PreToolUse for pre-Bash checks, PostToolUse for post-Bash review, UserPromptSubmit for prompt gating or augmentation, and Stop for continue-or-stop logic at the end of a turn./usr/bin/python3 "$(git rev-parse --show-toplevel)/.codex/hooks/pre_tool_use.py"
Do not assume Codex started from the repo root.codhc.
Write a custom hook script when the hook must inspect payload fields, branch on runtime state, or emit event-specific JSON. Prefer uvx codhc <command...> when the hook only needs to run an existing CLI check and map its exit status into a Codex-compatible response, especially for Stop.SessionStart: inject startup or resume context.PreToolUse: inspect an upcoming Bash command and optionally deny it.PostToolUse: review Bash output after the command already ran.UserPromptSubmit: inspect or block the prompt before it is sent.Stop: stop the turn or force one more continuation pass.Read references/events.md before implementing event-specific stdout formats or blocker behavior.
matcher only where runtime honors it.PreToolUse and PostToolUse, current tool_name is only Bash.SessionStart, matcher applies to startup or resume.UserPromptSubmit and Stop, matcher is currently ignored."*", "", or omit matcher to match everything supported by that event.hooks.json small and explicit. Favor one matcher group per intent.stdin.Stop requires JSON.uvx codhc <command...> for simple Stop-hook validation commands such as ruff, pytest, or project-specific check scripts.codhc when the hook must read payload fields, compute custom continuation reasons, or produce non-Stop event shapes.codhc commands as argv, not a single shell string. Use uvx codhc ruff check --fix, not uvx codhc "ruff check --fix".systemMessage or hook-specific structured output over ad hoc print debugging.PreToolUse and PostToolUse currently only support Bash payloads.PostToolUse cannot undo side effects from a command that already ran.PreToolUse is useful for policy guardrails, not a hard security boundary.codhc is a thin command wrapper, not a general hook framework or policy engine.codhc is most useful for Stop hooks that wrap an existing command; do not treat it as the default solution for every hook event.cwd.references/events.md: event matrix, supported fields, and fail-open notes.references/examples.md: minimal hooks.json and hook script output examples.development
Maintains concise repository MEMORY.md notes for gotchas, stale memory corrections, and durable user preferences. Use at the start of repository conversations, when the user mentions MEMORY.md, when an error should be remembered to avoid repeating it, or when MEMORY.md content may be wrong.
testing
Use only when the user explicitly names the work-log-writer skill; never auto-activate from generic work log, daily log, EOD summary, status update, or date-range summary requests.
development
Use when implementing non-trivial code changes that should follow TDD (write a failing test first, make the smallest passing change, then refactor safely).
tools
Use when designing, implementing, reviewing, or debugging Codex CLI hooks, including `hooks.json`, `.codex/hooks.json`, feature-flag setup, matcher behavior, event-specific stdin/stdout payloads, and hook scripts for `SessionStart`, `PreToolUse`, `PostToolUse`, `UserPromptSubmit`, or `Stop`.