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
Hook Lifecycle
Hooks fire at deterministic points in the agent's execution cycle:
TaskStart / TaskResumeUserPromptSubmitPreToolUse— (tool runs) —PostToolUsePreCompactTaskComplete / TaskCancelAll Hook Events
TaskStartWhen a new task beginsInject project context, run setup scripts, greet the agent with repo info
TaskResumeWhen an interrupted task is resumedRe-inject context that may have been lost, check for environment changes
UserPromptSubmitEvery time the user sends a messageLog prompts, validate inputs, block certain keywords
PreToolUseBefore the agent executes any toolValidate operations, enforce policies, block .js writes in TS projects
PostToolUseAfter the agent executes any toolLog tool usage, trigger external notifications, run linters after file saves
PreCompactBefore context history is summarized/compactedSave important state before truncation, archive conversation data
TaskCompleteWhen a task finishes successfullyPost-task cleanup, send notifications, trigger CI pipelines
TaskCancelWhen a task is cancelled by the userRollback 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
- 1Open the Hooks tab in the DevcoreAI sidebar
- 2Click + New Hook and select the event to listen to
- 3Write your shell script or Node.js script
- 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