agentsclimarketplace

Codex hook json sessionstart

Skill whyy9527/codexception/examples/codex-hook-json-sessionstart

Fix Codex SessionStart hooks that print plain text, invalid JSON, or reminders that do not enter model-visible context. Use when editing ~/.codex/hooks.json, ~/.codex/hooks/*.sh, or a skill-bundled hook script for Codex.From its SKILL.md

Install
npx -y skills add whyy9527/codexception --skill codex-hook-json-sessionstart

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

SKILL.md

2.0 KB, 433 tokens by cl100k_base, as published. Nobody here has run it

Codex Hook JSON SessionStart

Use When

  • A Codex hook is meant to inject reminder context at session start.
  • The hook prints plain text copied from a Claude hook.
  • hooks.json points at a shell script but Codex does not receive the reminder.
  • You are renaming or replacing a hook under ~/.codex/hooks/.

Failure Mechanism

Claude hooks can inject visible plain text. Codex SessionStart hooks should emit structured JSON so Codex can place the reminder in additionalContext. A copied Claude hook may execute successfully while providing no usable Codex context.

Procedure

  1. Read ~/.codex/hooks.json and the referenced hook script.
  2. Make the command point at a real executable under ~/.codex/hooks/.
  3. Have the script emit JSON with:
    • hookSpecificOutput.hookEventName set to SessionStart
    • reminder text in hookSpecificOutput.additionalContext
  4. Keep the hook output short. It should remind Codex to evaluate a skill, not duplicate the whole skill.

Example hook body:

#!/bin/bash
cat << 'EOF'
{
  "hookSpecificOutput": {
    "hookEventName": "SessionStart",
    "additionalContext": "[codexception]\nAfter completing this user request, evaluate whether the work produced reusable knowledge worth preserving as a Codex skill."
  }
}
EOF

Verification

  • ruby -rjson -e 'JSON.parse(File.read(File.expand_path("~/.codex/hooks.json")))'
  • ruby -rjson -e 'JSON.parse(~/.codex/hooks/codexception-activator.sh)'
  • ~/.codex/claude-bridge/validate.sh still passes if bridge-managed files are present.

High-Risk Actions

  • Do not paste the full skill into the hook output.
  • Do not leave stale hook paths after renaming a skill or script.
  • Do not use a Claude plain-text activation banner as the Codex hook body.

What ships with it

Read from the repository

Just SKILL.md. No reference files, no scripts.

Keep looking

Skills are one crate of 325,949. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.