Skip to content

Hooks

Set AIDEV_HOOKS_PATH in .env.aidev to a path relative to the project directory or an absolute path. aidev init writes .aidev/aidev.hooks.ts and sets AIDEV_HOOKS_PATH=.aidev/aidev.hooks.ts by default.

The module should export an object (or export default) whose properties are optional async functions. Only known hook names are used; anything else is ignored. If a hook throws, the current operation stops. If a hook returns an object, it replaces the context for that step.

Hook names

HookWhenContext notes
beforeRun / afterRunStart / end of aidev runafterRun includes processed and skipped counts
beforeEachTask / afterEachTaskAround each code task implementationprompt, branchName, task; afterEachTask has success
beforeResolveConflicts / afterResolveConflictsMerge conflict resolution with AIconflictFiles, prompt; afterResolveConflicts has resolved
beforeNonCodeTask / afterNonCodeTaskNon-code tasksafterNonCodeTask includes agent output
beforeThinkingTask / afterThinkingTaskThinking-tag tasks (subtask plan)beforeThinkingTask may adjust subtasks before steps run
beforeReviewTask / afterReviewTaskReview tasks with unresolved PR commentsthreads, prompt, branchName; afterReviewTask has success, resolvedCount

Second argument: vm

Each hook receives (context, vm). The vm object exposes:

  • runAI(prompt) — runs the first available configured AI agent
  • postComment(taskId, text), updateStatus(taskId, status), getComments(taskId) — task provider operations
  • log.info / log.warn / log.error — prefixed hook logging

TypeScript hooks

.ts hook files are loaded at runtime via jiti — no TypeScript compiler or toolchain needed.

Released under the MIT License.