Coding Agent Hooks Compared: Claude Code to Devin
Coding agent hooks are commands an agent runs at fixed points in its loop, usually before a tool call, after a tool call, when a prompt is submitted and when a turn ends. Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI and Devin all have them, and they look alike: JSON on stdin, JSON on stdout, exit code 2 to block. The details differ enough to break a script copied from one to another. This comparison puts the six side by side, from each vendor's own documentation read on 27 Nov 2026, and ends with how to run one hook script across all of them.
Why hooks matter for teams of agents
A hook is the only place where you can act inside an agent you did not write. For a single agent it is a convenience: run the formatter after each edit, block rm -rf. For several agents in one repository it is the whole coordination surface:
- Refuse an edit to a file another agent is changing.
- Report what the agent changed, so people and other agents can see it.
- Hand over text: a message from another agent, a correction from a person.
- Hold the end of a turn until the work merges with a peer's.
- Answer a permission prompt from somewhere other than the agent's terminal.
Which of these each agent allows decides what a coordination layer can do for it.
The coding agent hooks comparison table
| Claude Code | Codex | Cursor | Copilot (CLI and cloud agent) | Gemini CLI | Devin CLI | |
|---|---|---|---|---|---|---|
| Config | ~/.claude/settings.json, .claude/settings.json, managed, plugins |
$CODEX_HOME/hooks.json, .codex/hooks.json (trusted projects), [hooks] in config.toml |
~/.cursor/hooks.json, .cursor/hooks.json, enterprise |
~/.copilot/hooks/*.json, .github/hooks/*.json, settings files |
~/.gemini/settings.json, .gemini/settings.json, system |
.devin/hooks.v1.json, .devin/config.json, plus Claude Code's files |
| Before tool | PreToolUse |
PreToolUse |
preToolUse, beforeShellExecution |
preToolUse |
BeforeTool |
PreToolUse |
| How to deny | permissionDecision: "deny" |
permissionDecision: "deny" (old decision: "block" accepted) |
permission: "deny" |
permissionDecision: "deny" with a reason |
decision: "deny" with a reason |
decision: "block" |
| After tool | PostToolUse |
PostToolUse |
postToolUse, afterFileEdit |
postToolUse |
AfterTool |
PostToolUse |
| Inject context | additionalContext |
additionalContext (about 2,500 tokens by default) |
additional_context |
additionalContext (capped at 10 KB) |
additionalContext |
additionalContext |
| Turn end | Stop, decision: "block" |
Stop, decision: "block" |
stop, followup_message |
agentStop, decision: "block" |
AfterAgent, decision: "deny" |
Stop, decision: "block" |
| Permission request | PermissionRequest |
PermissionRequest |
None | permissionRequest (CLI only) |
None (observe only) | PermissionRequest |
| Exit 2 | Blocks | Blocks | Blocks | Denies on preToolUse |
Blocks | Blocks |
| Trust step | Workspace trust | /hooks review, by hash |
Trusted workspace for project hooks | "Workspace admission" | Fingerprint, warn on change | Not described in the CLI hooks overview |
A few notes the table cannot hold:
- Codex turns hooks on by default;
hooks = falseunder[features]switches them off. "Non-managed hooks must be reviewed and trusted before they run", through/hooks, and trust is tied to each hook's hash, so a changed hook is reviewed again. Edits arrive astool_name: "apply_patch". - Claude Code caps Stop continuations: after eight in a row, it overrides the next block. Copilot CLI does the same after 8 consecutive blocks. Cursor's
loop_limitdefaults to 5. - Gemini CLI timeouts are milliseconds; Cursor, Copilot and Claude Code use seconds.
- Copilot timeouts always fail open, even on
preToolUse; other non-zero exits onpreToolUsefail closed. - Cursor accepts
askonpreToolUsebut says it is "not enforced for preToolUse today".
Three agents run Claude Code's hooks too
This is the fact most teams miss. Hooks written for Claude Code are loaded by other agents:
- Cursor imports
.claude/settings.local.json,.claude/settings.jsonand~/.claude/settings.jsonthrough "Third-Party Imports", on by default, mapping event and tool names. - Devin CLI loads hooks from
.claude/paths "whenread_config_from.claudeis enabled (the default)". - Copilot CLI: "Cross-tool
.claude/settings.jsonand.claude/settings.local.jsonfiles in the repository are also read." (The cloud agent does not read them.)
Two consequences. First, a script installed for Claude Code may already be running inside Cursor, Devin or Copilot and believe it is Claude Code, recording the wrong source. Second, if you also install the agent's native hooks, one event can run the script twice. A cross-agent hook script has to work out which agent called it before it does anything else.
Copilot's cloud agent is a special case
GitHub's hooks reference says that for the cloud agent "Hook configuration is loaded from .github/hooks/*.json files in the cloned repository", and nothing else. Only the bash field is honoured, the working directory is /workspace, permissionRequest "either does not fire or has no effect" because tools are pre-approved, and ask becomes a deny. The cloud agent's network is also behind GitHub's firewall, so a hook that calls an outside service needs that host allowed.
The gaps
- Permission requests. Only Claude Code, Codex, Devin and Copilot CLI have a hook that fires when the agent is about to ask a person. Cursor and Gemini CLI do not, so nobody can answer their prompts from elsewhere; you can only allow or deny in the before-tool hook.
- No hooks at all. Aider has none: its options page offers
--notifications-command,--lint-cmdand--test-cmd, but no lifecycle events. - Plugins instead of hooks. OpenCode, Amp and Cline extend through plugin systems with their own APIs, and Antigravity CLI uses a separate
hooks.jsonformat. These need their own adapter, or a supervisor that works from outside the agent.
One hook script for all of them
If you want the same rules for every agent, write one script with three steps:
- Detect the calling agent from fields only it sends.
- Normalise its payload into one shape (event, tool, path, command).
- Translate your answer into the agent's own fields.
That is how Forkit's hook script works. Its Claude Code and Codex paths have been run with real agents (Claude Code and Codex 0.160.1 in production on 17 Nov 2026, one run, with Codex's trust step bypassed by its flag, so /hooks itself is untested). On 26 Nov 2026 it gained the other four:
- Detection: Cursor by
cursor_versionorCURSOR_VERSION; Devin byDEVIN_PROJECT_DIR, or byprompt_idwithout Claude Code'stranscript_path(Claude Code now sendsprompt_idtoo, which an earlier version mistook for Devin); Copilot by its camelCasesessionId; Gemini CLI byGEMINI_*variables. - Answers in each agent's words: Cursor
permission,additional_context,followup_message; Geminidecision: deny; CopilotpermissionDecision,additionalContextandbehavior; Devin in both shapes. - Native files:
forkit initwrites~/.cursor/hooks.json,~/.gemini/settings.jsonand~/.copilot/hooks/forkit.jsonwhen it finds those agents;forkit init --sandbox --project --agents cursor,gemini,copilotwrites.cursor/hooks.json,.gemini/settings.jsonand.github/hooks/forkit.jsonto commit. Devin runs the Claude Code hook file. - No double reporting: a call through
.claude/settings.jsonis skipped when the agent's own hook file already has Forkit.
The Cursor, Gemini CLI, Copilot and Devin support has been tested with each agent's documented payloads, not yet run against the real agents. Use it as a preview until it has been.
For agents with no hooks, forkit run -- <agent> supervises the checkout instead: it reports changed files, makes files another agent claimed read-only, and writes messages to a file the agent can read. That is weaker than a hook, as coordinating agents that have no hooks explains.
Which agent's hooks fit which job
| Job | Best supported by |
|---|---|
| Answer approvals remotely | Claude Code, Codex, Devin, Copilot CLI |
| Refuse edits to claimed files | All six |
| Deliver a message mid-turn | All six (after-tool context) |
| Hold the end of a turn | All six, each with its own loop cap |
| Committed, team-wide hooks in a cloud agent | Copilot cloud agent (.github/hooks/ only) |
If you only run Claude Code, its own hooks plus the PermissionRequest hook are all you need, and a cross-agent layer adds little. The layer earns its place once a team mixes vendors. See also Claude Code hooks vs MCP and the Codex hooks guide.
Forkit has a Free plan; Pro is $20 a month and Team $40 per seat a month, billed per person, never per agent. More at forkit-mcp.com.
Sources
Read on 27 Nov 2026:
- Claude Code, Hooks reference: https://code.claude.com/docs/en/hooks
- Codex, Hooks (developers.openai.com/codex/hooks, which now redirects to): https://learn.chatgpt.com/docs/hooks
- GitHub Docs, Hooks reference: https://docs.github.com/en/copilot/reference/hooks-reference
- Devin, Hooks overview: https://docs.devin.ai/cli/extensibility/hooks/overview
- GitHub Docs, Copilot CLI hooks reference: https://docs.github.com/en/copilot/reference/copilot-cli-reference/cli-hooks-reference
- Cursor, Hooks: https://cursor.com/docs/agent/hooks
- Cursor, Third-party hooks: https://cursor.com/docs/reference/third-party-hooks
- Gemini CLI, Hooks reference: https://geminicli.com/docs/hooks/reference/
- Aider, Options reference: https://aider.chat/docs/config/options.html