Hooks
Intercept and customize Tabnine CLI behavior at key lifecycle points.
What are Hooks?
Hooks are scripts that run automatically at specific points during Tabnine CLI execution, allowing you to customize behavior, add logging, enforce policies, or integrate with external tools.
Hook Types
Tabnine CLI supports hooks at various lifecycle events:
before-agent - Before agent processing starts
after-agent - After agent completes
before-model - Before model request
after-model - After model response
before-tool - Before tool execution
after-tool - After tool completes
on-error - When errors occur
Enabling Hooks
Hooks must be explicitly enabled in settings:
{
"hooks": {
"enabled": true
}
}Creating Hooks
Place executable scripts in .tabnine/hooks/:. For example, add the following file: .tabnine/hooks/before-tool.sh
In order to make it executable, run the chmod command:
Hook Context
Hooks receive context via environment variables:
TABNINE_CLI=1- Running in Tabnine CLITABNINE_TOOL_NAME- Tool being executed (for tool hooks)TABNINE_MODEL- Current model nameAdditional variables depending on hook type
Use Cases
Logging
Policy Enforcement
External Integration
Troubleshooting
There are some common problems that come up with hooks that have standard troubleshooting flows:
Hook not running
Hook blocking execution
Cause: Hook returned non-zero exit code
Solution: Fix the hook script or temporarily disable hooks (for example via /hooks disable).
Security Note:
Hooks execute with your user permissions. Only use hooks from trusted sources.
See Also
Last updated
Was this helpful?
