hooks-multi-tool-parity
Skill2 starsChanged 6 months agoMITView on GitHub
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.
In this repository30 other files it gives its agents.
- adr-spec-gateSkill
- agent-continuity-loopSkill
- agent-flywheelSkill
- agent-runtime-paritySkill
- business-guardrailsSkill
- compact-instructionsSkill
- debug-protocolSkill
- dns-and-whois-toolsSkill
- docs-as-codeSkill
- engineering-standardsSkill
- excellence-no-intermediatesSkill
- git-pr-rulesSkill
- hooks-for-enforcementSkill
- iac-first-commitSkill
- impact-metrics-gateSkill
- large-payload-completenessSkill
- ledger-auto-updatesSkill
- llm-model-selectionSkill
- local-service-autostartSkill
- multi-phase-sessionSkill
- new-projectSkill
- notion-apiSkill
- notion-batch-patternSkill
- observability-when-to-addSkill
- permanent-learning-protocolSkill
- progress-md-businessSkill
- reactive-integration-designSkill
- secure-secret-inputSkill
- tokens-taxonomySkill
- version-bump-rulesSkill
The file
We split this skill into the rules it gives an agent
8 rules. About 0 are common, 7 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈7
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 8
When you manage hooks in a multi-AI environment, hook definitions must propagate across all AI tools that have equivalent lifecycle support.
- Distinctive: line 12
When multiple AI tools (Claude Code, Codex, Cursor, Gemini, Kimi, Desktop Commander, Cline) are used in parallel or in sequence within the …
- Distinctive: line 53
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 …
- Distinctive: line 57
When a hook is created, modified, or removed:
- Very specific: line 72
Claude Code: Write hook in ~/.claude/hooks/pre-tool-use.js that intercepts tool calls and validates claim structure.
- Distinctive: line 74
Cursor: If Cursor's ToolExecution hook supports inspection, add validation there.
- Distinctive: line 77
Test: Run the same prompt in Claude Code, Codex, and Cursor.
- Distinctive: line 118
If unsure, ask: *"Would a user expect this behavior to apply consistently across all my AI tools?"* If yes → propagate.
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
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
PreCompactdoesn'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.jsthat intercepts tool calls and validates claim structure. - Codex CLI (same session): Implement equivalent logic in
~/.codex/hooks/pre-tool-use.jsusing 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_DISABLEfor Claude,DISABLE_HOOKfor Codex. → Consolidate to one disable switch (e.g.,AUDIT_HOOKS_DISABLED=1disables 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 hooksWhen 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).
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
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.

