Vibeleaderboard
← All Intel
Intel / article

Extend Cline With Plugins And Hooks

Source
cline.bot
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 and audit logs that an MCP 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 shell commands against regexes such as rm -rf, forced git 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 live progress through onEvent.
Terms in this piece · Glossary
  • agentic loop — The cycle an agent runs in: decide, call a tool, read the result, decide again — repeating until the goal is met or a stop condition fires.
  • guardrails — The checks around a model that block bad inputs and outputs — filters, validators, and permission rules the model itself can't override.
  • 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.
  • streaming — Sending a model's response token by token as it is generated, so the reader sees text immediately instead of waiting for the whole answer.
More from Cline evaluation and engineering blog
Recommended reads
Comments

Checking sign-in…

Loading comments…