Skip to main content
Hooks let you inject custom logic into Cline’s workflow at key moments. Think of them as automated checkpoints where you can validate operations before they execute, monitor tool usage as it happens, and shape how Cline makes decisions. Hooks run automatically when specific events happen during development. They receive detailed information about each operation, can block problematic actions before they cause issues, and can inject context that guides future AI decisions. The real power comes from combining these capabilities. You can:
  • Stop operations before they cause problems (like creating .js files in a TypeScript project)
  • Learn from what’s happening and build up project knowledge over time
  • Monitor performance and catch issues as they emerge
  • Track everything for analytics or compliance
  • Trigger external tools or services at the right moments

Getting Started

Hooks in action
Hooks work across all platforms: Windows, macOS, and Linux. The bash examples in this documentation work with standard shells on all platforms (including Git Bash or WSL on Windows).
Setting up hooks in Cline is user-friendly with the built-in hooks management interface. Here’s how to get started:
1

Access the Hooks Interface

Navigate to the Hooks management interface:
Hooks management interface showing Global Hooks and project-specific hooks with dropdown menu
  1. Open Cline (ensure hooks are enabled in settings)
  2. Look for the Hooks tab at the top (alongside Rules and Workflows)
  3. Click on Hooks to open the hooks management panel
The interface shows you all available hook types and existing hooks organized by workspace.
2

Understand Hook Locations

Hooks are automatically organized by location in the interface:Global Hooks - Apply to all workspaces:
  • Stored in ~/Documents/Cline/Rules/Hooks/
  • Perfect for personal coding standards and universal rules
Project-Specific Hooks - Apply only to current project:
  • Stored in .clinerules/hooks/ within your repo
  • Great for project-specific validation and team workflows
  • Can be committed to version control for team sharing
Multi-root workspaces run hooks from all of the repos in your open workspace, making it easy to manage and run hooks across different repos within the same workspace.
3

Create Your First Hook

Use the intuitive interface to create hooks:
Empty hooks interface showing New hook... dropdowns for both Global Hooks and project-specific hooks before any hooks are created
  1. Choose your location: Decide between Global Hooks or project-specific hooks
  2. Select hook type: Click the “New hook…” dropdown in your chosen location
  3. Pick a hook type: The dropdown shows all available hook types that haven’t been created yet in this location. Only one of each hook type is allowed per hooks directory, so the dropdown automatically filters to show only the remaining available types.
Creating a new hook with the dropdown menu showing UserPromptSubmit selected with description
  1. Review and edit the hook: Click the pencil icon to review the hook’s code and add your custom logic
  2. Enable the hook: Once you understand and approve of the hook’s behavior, toggle the switch to activate it
Hook management controls showing toggle, edit, and delete buttons for each hook
Always review a hook’s code before enabling it. Hooks execute automatically during your workflow, so it’s important to understand what they do before activation.
4

Test Your Hook

To develop and refine your hook, you’ll need to trigger it multiple times during testing. Each hook type is triggered by different events in Cline’s workflow. For example:
  • TaskStart hooks trigger when you start a new task
  • PreToolUse hooks trigger before Cline executes tools like file editing
  • PostToolUse hooks trigger after tool execution completes
  • UserPromptSubmit hooks trigger when you submit a message to Cline
For complete details on when each hook type is triggered and how to test them effectively, see the Hook Reference documentation. This includes the specific conditions that trigger each hook and examples of how to invoke them during development.
Start with a simple hook that just logs information before building complex validation logic. This helps you understand the data structure and timing.

What You Can Build

Once you understand the basics, hooks open up creative possibilities:

Intelligent Code Review

Run linters or custom validators before files get saved. Block commits that don’t pass checks. Track code quality metrics over time.

Security Enforcement

Prevent operations that violate security policies. Detect when sensitive data might be exposed. Audit all file access for compliance.

Development Analytics

Measure how long different operations take. Identify patterns in how the AI works. Generate productivity reports from hook data.

Integration Hub

Connect to issue trackers when certain keywords appear. Update project management tools. Sync with external APIs at the right moments.
The key is combining hooks with external tools. A hook can be the glue between Cline’s workflow and the rest of your development ecosystem.

Explore the Documentation

Hooks complement other Cline features:
  • Cline Rules define high-level guidance that hooks can enforce
  • Checkpoints let you roll back changes if a hook didn’t catch an issue
  • Auto-Approve works well with hooks as safety nets for automated operations