Vibeleaderboard
← All Intel
Intel / article

Extend Cline With Plugins And Hooks

Source
cline.bot
Publisher
Cline
Author
Cline evaluation and engineering blog
Date
Why it matters

Hooks run inside the agent harness at fixed points whether or not the model asks, so you can enforce guardrails and audit logs that an tool cannot guarantee. The post shows how to wire this up in Cline.

Key takeaways · AI-distilled
  • In Cline, a plugin is a single object attached to the agent harness that can wrap tools, providers, message rewriters, automations or hooks, and the same plugin works across the CLI, VS Code, JetBrains and the SDK.
  • Its example beforeTool matches commands against regexes such as rm -rf, forced push, mkfs and dd, and returns skip with a reason, so the agent reports the block instead of running the command.
  • A beforeRun/afterRun pair can journal each run to a JSONL file with duration, status, iterations, token counts and cost. The author notes afterRun also fires for failed or aborted runs, so the hook should record status rather than assume success.
  • Cline exposes seven hooks: beforeRun/afterRun, beforeTool/afterTool, beforeModel/afterModel and onEvent. Suggested uses include redacting secrets in beforeModel and streaming live progress through onEvent.
Terms in this piece · Glossary
  • Model Context Protocol (MCP) — A published agreement for an AI application to discover what a separate program offers and ask it to run one of those offerings.
  • agent hook — A script the harness runs automatically at a fixed point in an agent's loop — before a tool call, after an edit, on session start.
  • Terminal and shell — A text interface for navigating files and running programs.
  • Git and version control — A system for recording and comparing changes to a codebase.

Get the Brief

A cited digest of what matters for people building with AI, every morning. Unsubscribe anytime. See today’s edition

Tools in this story
More from Cline evaluation and engineering blog
Recommended reads