Skip to main content
Hooks let you run custom logic in response to events in the agent’s lifecycle. You can use hooks to enforce policies, add context, log actions, modify permissions, or integrate with external systems. Hooks are configured with a JSON format. Place them in your project’s .devin/ directory (or a user-level config) and Devin CLI runs them at the matching lifecycle events. Existing hooks in .claude/ directories are also picked up automatically — see Where Hooks Live.

What Can Hooks Do?

Enforce policies

Block dangerous commands, require confirmation for specific actions, or restrict file access.

Add context

Inject additional instructions or information when specific tools are called.

Run side effects

Execute scripts, send notifications, or log events when things happen.

Modify permissions

Dynamically grant or restrict permissions based on the situation.

Quick Example

Create .devin/hooks.v1.json in your project:
This runs ./scripts/check-command.sh before every shell command execution. The script receives event data on stdin and can block the action by returning a non-zero exit code.

Hook Events

Hooks can respond to these lifecycle events: See Lifecycle Hooks for details on each event and its available data.

Hook Format

Each hook has a type (command or prompt), an optional matcher (regex on the hook event’s tool_name), and configuration:

Command Hooks

Command hooks run a shell command. Event data is passed as JSON on stdin, and the command can return JSON on stdout to control the outcome (see Output format below). Input (stdin):
The DEVIN_PROJECT_DIR environment variable is automatically set to the project root directory. See Using the Matcher for the built-in tool names and MCP tool name format you can match.

Output format

A command hook can print a JSON object to stdout to control the outcome. To approve or block an action, return a top-level decision (with an optional reason):
To inject text into the agent’s context, return additionalContext inside a hookSpecificOutput object tagged with the event name:
To transparently rewrite a tool’s input before it executes, return updatedInput inside a PreToolUse hookSpecificOutput. Fields in updatedInput are merged into the tool’s arguments, so you can update a subset (e.g. just command):

Exit Codes


Where Hooks Live

Devin CLI reads hooks from the following locations. All use the same JSON format.

Project-Level

User-Level (Global)

In .devin/hooks.v1.json, the hooks object is the entire file (no wrapper key needed). In all other locations, hooks are nested under the "hooks" key in a settings file.
Hooks from .claude/ paths are loaded when read_config_from.claude is enabled (the default). You can disable this in your user config if needed.

Verifying Hooks

Use the /hooks slash command to see all currently loaded hooks and their source files:

Next Steps

Lifecycle Hooks

Deep dive into each event type and what data is available.

Configuration

Control which config locations Devin CLI reads hooks from.