Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Enforce hook lifecycle synchronization across all AI agent tools. When creating, modifying, or removing hooks in any AI tool (Claude Code, Codex CLI, Cursor, Gemini, Kimi, etc.), propagate changes to all equivalent tools in the same session. Use when implementing cross-tool runtime enforcement.
| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-02 | ✗→✓ | ▲ Improved | 38% | 0% |
| case-04 | ✗→✓ | ▲ Improved | 34% | 0% |
| case-05 | ✗→✓ | ▲ Improved | -9% | 0% |
| case-07 | ✗→✓ | ▲ Improved | 85% | 0% |
| case-09 | ✗→✓ | ▲ Improved | 46% | 0% |
When you manage hooks in a multi-AI environment, hook definitions must propagate across all AI tools that have equivalent lifecycle support. This prevents gaps where a behavioral rule is enforced in one tool but leaves others unprotected.
When multiple AI tools (Claude Code, Codex, Cursor, Gemini, Kimi, Desktop Commander, Cline) are used in parallel or in sequence within the same workflow:
Example failure scenario: You implement a validation hook in Claude Code that prevents certain classes of faulty claims. Codex, used in parallel, lacks this hook. Both tools can produce the same error, but you've only patched half your stack.
Different tools have varying hook lifecycle maturity. Organize propagation as tiers:
| Tool | Hook Events | Propagation Tier | Configuration | |---|---|---|---| | Claude Code | SessionStart, UserPromptSubmit, PreToolUse, PostToolUse, PreCompact, Stop | Primary | ~/.claude/hooks/ + settings.json | | Codex CLI | SessionStart, UserPromptSubmit, PreToolUse, PostToolUse, Stop, SessionEnd | Primary | ~/.codex/hooks/ + config file | | Cursor | Startup, ToolExecution, FileEdit, Completion, Shutdown | Best-effort | IDE plugin config + rules directory | | Gemini CLI | Startup, Shutdown, BeforeAgent | Best-effort | Settings file | | Kimi Desktop / CLI | Tool-specific hooks | Best-effort | App config | | Desktop Commander | Tool-specific hooks | Best-effort | Application config | | Cline | BeforeToolExecution, AfterToolExecution, OnNotification | Best-effort | SDK hook configuration |
Definitions:
Events are not always 1:1 between tools. Map by semantic meaning:
| Semantic Intent | Claude Code | Codex | Cursor | Gemini | Action | |---|---|---|---|---|---| | Before execution starts | SessionStart | SessionStart | Startup | Startup | ✅ All supported | | User submits prompt | UserPromptSubmit | UserPromptSubmit | (via Completion) | BeforeAgent | ✅ Propagate | | Pre-tool invocation | PreToolUse | PreToolUse | ToolExecution | (no equivalent) | ✅ Propagate where available | | Post-tool result | PostToolUse | PostToolUse | ToolExecution | (no equivalent) | ✅ Propagate where available | | Session ends | Stop / SessionEnd | Stop / SessionEnd | Shutdown | Shutdown | ✅ All supported | | Before cleanup | PreCompact | (no equivalent) | (no equivalent) | (no equivalent) | ⚠️ Claude-only; document gap |
Apply the rule: if a hook's purpose is tool-agnostic (e.g., "validate all claims before tool use"), it belongs in every tool that fires the equivalent event.
When a hook is created, modified, or removed:
PreCompact doesn't exist in Codex), record this in your handoff documentation with the reason.Scenario: You need a hook to prevent "unsourced claims" — any time an AI tool generates a factual assertion, the hook checks for inline evidence.
Steps:
~/.claude/hooks/pre-tool-use.js that intercepts tool calls and validates claim structure.~/.codex/hooks/pre-tool-use.js using Codex's hook API.Prohibited:
HOOK_DISABLE for Claude, DISABLE_HOOK for Codex. → Consolidate to one disable switch (e.g., AUDIT_HOOKS_DISABLED=1 disables the same hook everywhere).Maintain a hook-parity audit trail in your handoff documentation. Example:
markdown## Hook Propagation Status (Current Session) ### Hooks Modified - **unsourced-claim-validation** (YYYY-MM-DD) - Claude Code: ✅ Implemented in hook directory - Codex CLI: ✅ Ported to equivalent hook location - Cursor: ✅ Adapted as custom rule in IDE config - Gemini: ⚠️ Gap — no pre-tool event; skipped - Kimi: ⚠️ Unknown tool support; best-effort pending testing ### Propagation Debt - (None currently) ### Known Gaps - Cursor lacks pre-tool-use lifecycle event; validation fires post-execution only - Gemini Hook API limited to Startup/Shutdown/BeforeAgent; no mid-execution hooks
Hook parity is a safety/consistency requirement for behavioral enforcement hooks (validation, claim-checking, guardrails, error-handling). Conversely:
If unsure, ask: "Would a user expect this behavior to apply consistently across all my AI tools?" If yes → propagate. If no → document as tool-specific.
See also: agent-runtime-parity (broader sync for rules, skills, MCPs, APIs, credentials, and memory across all AI surfaces).
Other measured skills in the registry, with their headline benchmark lift.