D
DevcoreAI

Customization

Hooks

Inject custom logic at key points in the agent lifecycle — validate operations, enforce policies, log everything, or trigger external tools.

What You Can Build

Stop operations before they cause problems (e.g. block .js files in a TypeScript project)
Run linters or validators before files get saved
Enforce security policies — prevent writes to sensitive paths
Track everything for analytics or compliance auditing
Trigger external services (Slack, webhooks, CI) at the right moments
Add contextual information to the conversation based on what the agent is doing

Hook Lifecycle

Hooks fire at deterministic points in the agent's execution cycle:

Task beginsTaskStart / TaskResume
User sends messageUserPromptSubmit
Before any toolPreToolUse
Tool executes— (tool runs) —
After any toolPostToolUse
Context fullPreCompact
Task endsTaskComplete / TaskCancel

All Hook Events

TaskStartWhen a new task begins

Inject project context, run setup scripts, greet the agent with repo info

TaskResumeWhen an interrupted task is resumed

Re-inject context that may have been lost, check for environment changes

UserPromptSubmitEvery time the user sends a message

Log prompts, validate inputs, block certain keywords

PreToolUseBefore the agent executes any tool

Validate operations, enforce policies, block .js writes in TS projects

PostToolUseAfter the agent executes any tool

Log tool usage, trigger external notifications, run linters after file saves

PreCompactBefore context history is summarized/compacted

Save important state before truncation, archive conversation data

TaskCompleteWhen a task finishes successfully

Post-task cleanup, send notifications, trigger CI pipelines

TaskCancelWhen a task is cancelled by the user

Rollback side-effects, clean up temp files

Where Hooks Live

Project hooks

.clinerules/hooks/

Committed to version control. Applied to all team members working in this repo.

Global hooks

~/Documents/DevcoreAI/Hooks/

Applied to all projects on your machine. Good for personal enforcement rules.

Creating a Hook

  1. 1Open the Hooks tab in the DevcoreAI sidebar
  2. 2Click + New Hook and select the event to listen to
  3. 3Write your shell script or Node.js script
  4. 4Enable the hook — it activates immediately for new tasks

Example — block .js files in TypeScript projects (PreToolUse)

#!/bin/bash
# Hook: PreToolUse — block write_file calls targeting .js files
# Input is passed as JSON on stdin

TOOL_NAME=$(echo "$CLINE_TOOL_INPUT" | jq -r '.tool_name')
FILE_PATH=$(echo "$CLINE_TOOL_INPUT" | jq -r '.params.path // ""')

if [[ "$TOOL_NAME" == "write_file" && "$FILE_PATH" == *.js ]]; then
  echo '{"cancel": true, "message": "This project uses TypeScript. Use .ts instead of .js"}'
  exit 0
fi