feat(hooks): lifecycle hooks and documentation#501
feat(hooks): lifecycle hooks and documentation#501am-will wants to merge 10 commits intojust-every:mainfrom
Conversation
There was a problem hiding this comment.
💡 Codex Review
code/code-rs/core/src/codex/streaming.rs
Lines 1883 to 1887 in 29f66bb
In the token-limit auto-compaction branch, the code jumps straight into run_inline_*_auto_compact_task without invoking ProjectHookEvent::PreCompact, so any hooks configured for pre.compact will never run during automatic compaction (the most common case when the context window is exceeded). This means gates/logging meant to run before compaction won’t fire for auto compacts. Consider running the pre-compact hook (with reason "auto") before this branch executes.
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This is Claude Code Hooks (with a bonus: Post Compact Hook!), and they are well integrated directly into EveryCode,including the option to turn them on/off in the /settings menu, as well as the option on which model/provider to use.
Summary
CODE_HOOK_PAYLOADand parse command payloadsWhat this feature is
Project lifecycle hooks let operators run local commands at well-defined points in a Codex session (prompt submit, tool exec, file writes, compaction, turn completion, sub-agent completion, notifications). Hooks run in the same sandbox/approval mode as the session, appear as exec cells (unless
run_in_background), and can gate or rewrite inputs through a JSON response contract.How to use it
Define hooks per project in
config.toml:Where hooks live
config.tomlunderCODE_HOME(project-scoped via[projects."<path>"]).hooks/ask_user_prompt.py,hooks/check_shell.py+scripts/run-hooks-test.shin this repo.Available hook events
session.start,session.end,user.prompt_submit,tool.before,tool.after,file.before_write,file.after_write,pre.compact,post.compact,stop,subagent.stop,notification.Payload + control JSON highlights
CODE_HOOK_PAYLOAD(JSON string) + stdin fallback.CODE_HOOK_EVENT,CODE_HOOK_TRIGGER,CODE_HOOK_CALL_ID,CODE_HOOK_SUB_ID,CODE_HOOK_INDEX,CODE_SESSION_CWD,CODE_HOOK_NAME,CODE_HOOK_SOURCE_CALL_ID.permissionDecision(allow|ask|deny) orhookSpecificOutput.permissionDecisionupdatedInput(rewrite prompt/command)systemMessage(Chat API only)continue: false(stop remaining hooks for that event)Testing
./build-fast.shscripts/run-hooks-test.sh(configures the example hooks)Try:
hook: please summarize this reporm -rfto trigger the guard