Hook Lifecycle Propagation Across All AI Tools
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.
Why This Matters
When multiple AI tools (Claude Code, Codex, Cursor, Gemini, Kimi, Desktop Commander, Cline) are used in parallel or in sequence within the same workflow:
- A bug-mitigation hook (e.g., confabulation detection, evidence-validation checks) implemented in one tool leaves others exposed
- Divergent hook implementations create hidden dependencies and make reasoning harder to audit
- Asymmetric enforcement creates false confidence in safety: one tool appears "hardened" while others follow the same failure mode
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.
Propagation Framework
Tool Categories by Hook Support
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:
- Primary: Hook must propagate in the same session. Treat as a blocking requirement.
- Best-effort: Propagate when the tool supports an equivalent event and the hook is semantically applicable. Document gaps in handoff documentation.
Semantic Event Mapping
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.
Operational Flow
When a hook is created, modified, or removed:
- Identify primary tool — where is the hook being initially developed? (Claude Code, Codex, etc.)
- Same session: propagate to other primary tool — if you added a hook in Claude Code, port it to Codex in the same session. No "I'll do it later."
- Map events to secondary tools — check Cursor, Gemini, Kimi, etc. If an equivalent event exists and the hook's purpose applies, implement it.
- Document gaps — if Tool X has no equivalent event (e.g., Claude's
PreCompact doesn't exist in Codex), record this in your handoff documentation with the reason.
- Update instruction files — add propagation notes to your global instruction sets (e.g., CLAUDE.md for Claude Code, AGENTS.md for Codex, etc.).
- Smoke test each tool — before finalizing, run the hook in each tool and verify expected behavior.
Example: Implementing a Cross-Tool Validation Hook
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 Code: Write hook in
~/.claude/hooks/pre-tool-use.js that intercepts tool calls and validates claim structure.
- Codex CLI (same session): Implement equivalent logic in
~/.codex/hooks/pre-tool-use.js using Codex's hook API.
- Cursor: If Cursor's ToolExecution hook supports inspection, add validation there; if not, document "Unsourced-claim validation not available in Cursor (no equivalent event)."
- Gemini: Gemini lacks a pre-tool-execution hook → document gap; Gemini only validates at Startup or BeforeAgent, so adapt logic to run early or skip.
- Update CLAUDE.md / AGENTS.md with note: "Unsourced-claim validation hook propagated to Claude Code + Codex CLI (primary); Cursor best-effort via custom rule; Gemini gap documented."
- Test: Run the same prompt in Claude Code, Codex, and Cursor; verify hook fires in all three.
Anti-Patterns to Avoid
Prohibited:
- Creating a hook in Claude Code and deferring propagation to Codex: "I'll port it later." → Port in the same session.
- Ignoring tool gaps silently: "Tool X doesn't support this hook, so I'll just leave it." → Document the gap explicitly; don't let divergence hide.
- Implementing divergent logic across tools without justification: Different regex, thresholds, or behavior in Claude vs. Codex without a recorded reason. → Divergence only when tool shape genuinely requires it (e.g., transcript format differs); logic should be semantically identical.
- Using different environment variables to disable hooks across tools when behavior is symmetric:
HOOK_DISABLE for Claude, DISABLE_HOOK for Codex. → Consolidate to one disable switch (e.g., AUDIT_HOOKS_DISABLED=1 disables the same hook everywhere).
Handoff Documentation
Maintain a hook-parity audit trail in your handoff documentation. Example:
## 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
When Hook Parity is Not Required
Hook parity is a safety/consistency requirement for behavioral enforcement hooks (validation, claim-checking, guardrails, error-handling). Conversely:
- Logging/observability hooks that are tool-specific may stay in one tool only (e.g., Claude's SessionStart writes to Claude's log only).
- UI-only hooks (e.g., Cursor plugin displaying a status bar) don't need propagation; Cursor-specific is fine.
- Experimental hooks in alpha/beta may be single-tool only, documented as "Pending propagation."
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).
1---2name: hooks-multi-tool-parity3description: 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.4---56## Hook Lifecycle Propagation Across All AI Tools78When 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.910### Why This Matters1112When multiple AI tools (Claude Code, Codex, Cursor, Gemini, Kimi, Desktop Commander, Cline) are used in parallel or in sequence within the same workflow:1314- A bug-mitigation hook (e.g., confabulation detection, evidence-validation checks) implemented in one tool leaves others exposed15- Divergent hook implementations create hidden dependencies and make reasoning harder to audit16- Asymmetric enforcement creates false confidence in safety: one tool appears "hardened" while others follow the same failure mode1718**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.1920### Propagation Framework2122#### Tool Categories by Hook Support2324Different tools have varying hook lifecycle maturity. Organize propagation as **tiers**:2526| Tool | Hook Events | Propagation Tier | Configuration |27|---|---|---|---|28| **Claude Code** | SessionStart, UserPromptSubmit, PreToolUse, PostToolUse, PreCompact, Stop | **Primary** | `~/.claude/hooks/` + settings.json |29| **Codex CLI** | SessionStart, UserPromptSubmit, PreToolUse, PostToolUse, Stop, SessionEnd | **Primary** | `~/.codex/hooks/` + config file |30| **Cursor** | Startup, ToolExecution, FileEdit, Completion, Shutdown | **Best-effort** | IDE plugin config + rules directory |31| **Gemini CLI** | Startup, Shutdown, BeforeAgent | **Best-effort** | Settings file |32| **Kimi Desktop / CLI** | Tool-specific hooks | **Best-effort** | App config |33| **Desktop Commander** | Tool-specific hooks | **Best-effort** | Application config |34| **Cline** | BeforeToolExecution, AfterToolExecution, OnNotification | **Best-effort** | SDK hook configuration |3536**Definitions:**37- **Primary:** Hook must propagate in the same session. Treat as a blocking requirement.38- **Best-effort:** Propagate when the tool supports an equivalent event and the hook is semantically applicable. Document gaps in handoff documentation.3940#### Semantic Event Mapping4142Events are not always 1:1 between tools. Map by semantic meaning:4344| Semantic Intent | Claude Code | Codex | Cursor | Gemini | Action |45|---|---|---|---|---|---|46| Before execution starts | SessionStart | SessionStart | Startup | Startup | ✅ All supported |47| User submits prompt | UserPromptSubmit | UserPromptSubmit | (via Completion) | BeforeAgent | ✅ Propagate |48| Pre-tool invocation | PreToolUse | PreToolUse | ToolExecution | (no equivalent) | ✅ Propagate where available |49| Post-tool result | PostToolUse | PostToolUse | ToolExecution | (no equivalent) | ✅ Propagate where available |50| Session ends | Stop / SessionEnd | Stop / SessionEnd | Shutdown | Shutdown | ✅ All supported |51| Before cleanup | PreCompact | (no equivalent) | (no equivalent) | (no equivalent) | ⚠️ Claude-only; document gap |5253**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.5455### Operational Flow5657When a hook is created, modified, or removed:58591. **Identify primary tool** — where is the hook being initially developed? (Claude Code, Codex, etc.)602. **Same session: propagate to other primary tool** — if you added a hook in Claude Code, port it to Codex in the same session. No "I'll do it later."613. **Map events to secondary tools** — check Cursor, Gemini, Kimi, etc. If an equivalent event exists and the hook's purpose applies, implement it.624. **Document gaps** — if Tool X has no equivalent event (e.g., Claude's `PreCompact` doesn't exist in Codex), record this in your handoff documentation with the reason.635. **Update instruction files** — add propagation notes to your global instruction sets (e.g., CLAUDE.md for Claude Code, AGENTS.md for Codex, etc.).646. **Smoke test each tool** — before finalizing, run the hook in each tool and verify expected behavior.6566### Example: Implementing a Cross-Tool Validation Hook6768**Scenario:** You need a hook to prevent "unsourced claims" — any time an AI tool generates a factual assertion, the hook checks for inline evidence.6970**Steps:**71721. **Claude Code:** Write hook in `~/.claude/hooks/pre-tool-use.js` that intercepts tool calls and validates claim structure.732. **Codex CLI** (same session): Implement equivalent logic in `~/.codex/hooks/pre-tool-use.js` using Codex's hook API.743. **Cursor:** If Cursor's ToolExecution hook supports inspection, add validation there; if not, document "Unsourced-claim validation not available in Cursor (no equivalent event)."754. **Gemini:** Gemini lacks a pre-tool-execution hook → document gap; Gemini only validates at Startup or BeforeAgent, so adapt logic to run early or skip.765. **Update CLAUDE.md / AGENTS.md** with note: "Unsourced-claim validation hook propagated to Claude Code + Codex CLI (primary); Cursor best-effort via custom rule; Gemini gap documented."776. **Test:** Run the same prompt in Claude Code, Codex, and Cursor; verify hook fires in all three.7879### Anti-Patterns to Avoid8081**Prohibited:**82- Creating a hook in Claude Code and deferring propagation to Codex: "I'll port it later." → Port in the same session.83- Ignoring tool gaps silently: "Tool X doesn't support this hook, so I'll just leave it." → Document the gap explicitly; don't let divergence hide.84- Implementing divergent logic across tools without justification: Different regex, thresholds, or behavior in Claude vs. Codex without a recorded reason. → Divergence only when tool shape genuinely requires it (e.g., transcript format differs); logic should be semantically identical.85- Using different environment variables to disable hooks across tools when behavior is symmetric: `HOOK_DISABLE` for Claude, `DISABLE_HOOK` for Codex. → Consolidate to one disable switch (e.g., `AUDIT_HOOKS_DISABLED=1` disables the same hook everywhere).8687### Handoff Documentation8889Maintain a hook-parity audit trail in your handoff documentation. Example:9091```markdown92## Hook Propagation Status (Current Session)9394### Hooks Modified95- **unsourced-claim-validation** (YYYY-MM-DD)96 - Claude Code: ✅ Implemented in hook directory97 - Codex CLI: ✅ Ported to equivalent hook location98 - Cursor: ✅ Adapted as custom rule in IDE config99 - Gemini: ⚠️ Gap — no pre-tool event; skipped100 - Kimi: ⚠️ Unknown tool support; best-effort pending testing101102### Propagation Debt103- (None currently)104105### Known Gaps106- Cursor lacks pre-tool-use lifecycle event; validation fires post-execution only107- Gemini Hook API limited to Startup/Shutdown/BeforeAgent; no mid-execution hooks108```109110### When Hook Parity is Not Required111112Hook parity is a safety/consistency requirement for **behavioral enforcement hooks** (validation, claim-checking, guardrails, error-handling). Conversely:113114- **Logging/observability hooks** that are tool-specific may stay in one tool only (e.g., Claude's SessionStart writes to Claude's log only).115- **UI-only hooks** (e.g., Cursor plugin displaying a status bar) don't need propagation; Cursor-specific is fine.116- **Experimental hooks** in alpha/beta may be single-tool only, documented as "Pending propagation."117118If 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.119120---121122**See also:** `agent-runtime-parity` (broader sync for rules, skills, MCPs, APIs, credentials, and memory across all AI surfaces).