agentleFS
Masih-0x3Masih-0x3/agent-skills/skills/create-hook/SKILL.md

create-hook

Skill0 starsChanged 3 months agoMITView on GitHub

Codex hook authoring. Use when the user asks to create, update, audit, or verify Codex lifecycle hooks in global ~/.codex or project .codex scope, including hook scripts, hooks.json, matcher behavior, trust review, and smoke verification.

17 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use update-cli-config, review-bugbot and 10 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • PandelisZSkill

    update-cli-config

    View and modify Cursor CLI configuration settings in ~/.cursor/cli-config.json. Use when the user wants to change CLI settings, configure permissions, switch approval mode, enable vim mode, toggle display options, configure sandbox, or manage any CLI preferences.

    Also in 6 projects that use this

  • 0mlkrizzz655335vSkill

    review-bugbot

    缺陷导向代码审查。用 Bugbot 子代理找 bug。

    Also in 4 projects that use this

  • 32103210Skill

    migrate-to-skills

    Convert 'Applied intelligently' Cursor rules (.cursor/rules/*.mdc) and slash commands (.cursor/commands/*.md) to Agent Skills format (.cursor/skills/). Use when you want to migrate rules or commands to skills, convert .mdc rules to SKILL.md format, or consolidate commands into the skills directory.

    Also in 6 projects that use this

  • 32103210Skill

    update-cursor-settings

    Modify Cursor/VSCode user settings in settings.json. Use when you want to change editor settings, preferences, configuration, themes, font size, tab size, format on save, auto save, keybindings, or any settings.json values.

    Also in 6 projects that use this

  • Tsumugii24Skill

    split-to-prs

    Split current work into small reviewable PRs. Use when the user asks to split a chat, set of changes, branch, or PR.

    Also in 6 projects that use this

  • 0mlkrizzz655335vSkill

    sdk

    Codex SDK 集成开发。用 TypeScript/Python SDK 做 agent 生命周期、流式输出、本地/云端执行等集成。

    Also in 5 projects that use this

  • +2 more from 32103210
  • +1 more from 0mlkrizzz655335v

The file

Show its rules and text

We split this skill into the rules it gives an agent

36 rules. 0 are common, 16 are distinctive, and 20 are very specific to this project.

  • 0

    Common

    Most of the 17 edited versions we read keep these.

  • 16

    Distinctive

    This author's own choices. Worth a look.

  • 20

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Use this skill when the user wants Codex lifecycle hooks created, updated, audited, or verified.

    line 8
  2. Distinctive:

    Start read-only. Inspect existing hook sources before changing files.

    line 12
  3. Distinctive:

    Treat hooks as behavior-changing automation.

    line 13
  4. Very specific:

    Prefer hooks.json for new hook config.

    line 14
  5. Very specific:

    Use the current feature key: [features] hooks = true.

    line 15
  6. Distinctive:

    Keep hook scripts deterministic, fast, and dependency-light.

    line 16
  7. Distinctive:

    Never log secrets, raw credentials, private keys, tokens, full prompts, raw transcripts, or unredacted tool payloads unless the user …

    line 17
  8. Distinctive:

    Do not install watchers, cron jobs, daemons, background agents, or model calls inside hook runtime.

    line 18
  9. Very specific:

    Run python3 <skill>/scripts/audit_hooks.py --scope global for global hooks.

    line 23
  10. Very specific:

    Run python3 <skill>/scripts/audit_hooks.py --scope project --repo <repo-root> for project hooks.

    line 24
  11. Very specific:

    Read any reported hooks.json, inline [hooks], hook script folder, and feature flag state.

    line 25
  12. Very specific:

    If the user says global, use ~/.codex.

    line 29
  13. Very specific:

    If the user says project, resolve the repository root with git rev-parse --show-toplevel and use <repo>/.codex.

    line 30
  14. Distinctive:

    If scope is missing and the behavior is personal across repos, default to global only if that is clearly implied.

    line 31
  15. Very specific:

    If scope is still ambiguous, ask: Should this be global or project-scoped?

    line 32
  16. Distinctive:

    If the event is missing or unclear, ask which hook event they want.

    line 35
  17. Very specific:

    Ask for a matcher only for events that honor matchers: SessionStart, SubagentStart, PreToolUse, PermissionRequest, PostToolUse, PreCompact, …

    line 37
  18. Very specific:

    Do not ask for a matcher for UserPromptSubmit or Stop.

    line 38
  19. Distinctive:

    If the user wants multiple events, keep them as separate matcher groups and scripts unless shared code clearly reduces duplication.

    line 39
  20. Distinctive:

    Write the hook config and script.

    line 49
  21. Very specific:

    Use an explicit command path.

    line 52
  22. Very specific:

    Use statusMessage only for short visible signals like Checking Bash command or Recording hook event.

    line 57
  23. Distinctive:

    Use the correct output contract.

    line 59
  24. Very specific:

    Read references/hook-contracts.md before writing event-specific output.

    line 60
  25. Distinctive:

    Run the hook script with a minimal sample JSON payload for the chosen event.

    line 69
  26. Distinctive:

    If project-scoped, confirm the repo is trusted or say that project hooks will not load until the project layer is trusted.

    line 71
  27. Distinctive:

    Verify Codex trust and runtime behavior.

    line 73
  28. Distinctive:

    Do not claim live hook execution until a trusted hook has actually fired.

    line 75
  29. Distinctive:

    If live triggering is not possible in the current session, close with: standalone validation passed, Codex trust/live trigger still pending.

    line 76
  30. Very specific:

    Use PreToolUse for prevention before supported tool calls.

    line 80
  31. Very specific:

    Use PermissionRequest for approval-policy automation around escalation requests.

    line 81
  32. Very specific:

    Use PostToolUse for logging, review notes, formatting hints, or follow-up checks after supported tools.

    line 82
  33. Very specific:

    Use UserPromptSubmit for prompt shaping or context injection.

    line 83
  34. Very specific:

    Use SessionStart for startup context.

    line 84
  35. Very specific:

    Use PreCompact and PostCompact for compacting workflows.

    line 85
  36. Very specific:

    Use Stop only for narrow end-of-turn continuation checks.

    line 86

“Common” is measured: kept by at least 6 in 10 of the 17 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Create Hook

Use this skill when the user wants Codex lifecycle hooks created, updated, audited, or verified. Keep the loop tight: inspect current hook state first, write the smallest deterministic hook, validate it locally, and call out any trust or live-trigger step that remains.

Ground Rules

  • Start read-only. Inspect existing hook sources before changing files.
  • Treat hooks as behavior-changing automation. Blocking, rewriting, approval, prompt-shaping, or continuation hooks require explicit user intent.
  • Prefer hooks.json for new hook config. If a layer already uses inline [hooks] in config.toml, preserve that representation instead of mixing formats unless the user asks to migrate.
  • Use the current feature key: [features] hooks = true. Do not add codex_hooks; it is deprecated. Do not add any feature flag when hooks are already enabled or unspecified.
  • Keep hook scripts deterministic, fast, and dependency-light. Default to Python stdlib, JSON stdin parsing, explicit timeout, and no network calls.
  • Never log secrets, raw credentials, private keys, tokens, full prompts, raw transcripts, or unredacted tool payloads unless the user explicitly asks for a narrow local log and the script redacts sensitive values.
  • Do not install watchers, cron jobs, daemons, background agents, or model calls inside hook runtime.

Workflow

  1. Audit the target.
    • Run python3 <skill>/scripts/audit_hooks.py --scope global for global hooks.
    • Run python3 <skill>/scripts/audit_hooks.py --scope project --repo <repo-root> for project hooks.
    • Read any reported hooks.json, inline [hooks], hook script folder, and feature flag state.
    • Completion criterion: you know the active layer, existing hook representation, whether hooks are disabled, and whether a same-event or same-script hook already exists.
  2. Determine scope.
    • If the user says global, use ~/.codex.
    • If the user says project, resolve the repository root with git rev-parse --show-toplevel and use <repo>/.codex.
    • If scope is missing and the behavior is personal across repos, default to global only if that is clearly implied.
    • If scope is still ambiguous, ask: Should this be global or project-scoped?
  3. Determine event and matcher.
    • If the event is missing or unclear, ask which hook event they want.
    • Supported events: SessionStart, SubagentStart, PreToolUse, PermissionRequest, PostToolUse, PreCompact, PostCompact, UserPromptSubmit, SubagentStop, Stop.
    • Ask for a matcher only for events that honor matchers: SessionStart, SubagentStart, PreToolUse, PermissionRequest, PostToolUse, PreCompact, PostCompact, SubagentStop.
    • Do not ask for a matcher for UserPromptSubmit or Stop; Codex ignores matchers for those events.
    • If the user wants multiple events, keep them as separate matcher groups and scripts unless shared code clearly reduces duplication.
  4. Determine behavior and risk.
    • Logging or context-only hooks: proceed after behavior is clear.
    • Blocking or denial hooks: confirm the exact deny condition and message.
    • PermissionRequest hooks: confirm whether the hook can allow, deny, or only log approval requests.
    • Rewriting hooks with updatedInput: confirm the exact rewrite and keep it narrow.
    • Stop or SubagentStop continuation hooks: confirm the stopping condition so they cannot create a noisy loop.
    • Completion criterion: the trigger, allowed side effects, output contract, and failure mode are explicit.
  5. Write the hook config and script.
    • Global config path: ~/.codex/hooks.json; scripts under ~/.codex/hooks/.
    • Project config path: <repo>/.codex/hooks.json; scripts under <repo>/.codex/hooks/.
    • Use an explicit command path. For project hooks, prefer git-root resolution: /usr/bin/python3 "$(git rev-parse --show-toplevel)/.codex/hooks/<script>.py".
    • For global hooks, prefer an absolute home path: /usr/bin/python3 "$HOME/.codex/hooks/<script>.py".
    • Set timeout explicitly; use 10 seconds for simple log/context hooks and 30 seconds for validation hooks unless the user requests otherwise.
    • Use statusMessage only for short visible signals like Checking Bash command or Recording hook event.
  6. Use the correct output contract.
    • Read references/hook-contracts.md before writing event-specific output.
    • For PreToolUse denial, prefer hookSpecificOutput.permissionDecision = "deny" with permissionDecisionReason.
    • For PermissionRequest, use hookSpecificOutput.decision.behavior with allow or deny.
    • For UserPromptSubmit, plain stdout or hookSpecificOutput.additionalContext becomes developer context.
    • For Stop, decision: "block" means "continue the turn with this reason", not "reject the final answer".
  7. Validate locally.
    • Compile Python scripts with python3 -m py_compile <script>.
    • Parse hooks.json with python3 -m json.tool <hooks.json>.
    • Run the hook script with a minimal sample JSON payload for the chosen event.
    • Re-run the audit script and confirm the expected hook appears.
    • If project-scoped, confirm the repo is trusted or say that project hooks will not load until the project layer is trusted.
  8. Verify Codex trust and runtime behavior.
    • Non-managed hooks must be reviewed and trusted in /hooks; changed hook definitions get a new hash.
    • Do not claim live hook execution until a trusted hook has actually fired.
    • If live triggering is not possible in the current session, close with: standalone validation passed, Codex trust/live trigger still pending.

Practical Defaults

  • Use PreToolUse for prevention before supported tool calls.
  • Use PermissionRequest for approval-policy automation around escalation requests.
  • Use PostToolUse for logging, review notes, formatting hints, or follow-up checks after supported tools.
  • Use UserPromptSubmit for prompt shaping or context injection.
  • Use SessionStart for startup context.
  • Use PreCompact and PostCompact for compacting workflows.
  • Use Stop only for narrow end-of-turn continuation checks.

Closeout

Report these states explicitly:

  • Scope and paths changed.
  • Event, matcher, script command, and timeout.
  • Validation performed.
  • Whether Codex trust review is still required.
  • Whether behavior was validated live or only standalone.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.