Skip to content

Cline CLI

Protection level: hook only. OpenMoat writes no OS sandbox for the Cline CLI; openmoat run -- cline runs the whole agent in one (openmoat run).

  1. Write OpenMoat’s hook script

    Terminal window
    openmoat init --hosts cline

    It writes OpenMoat’s script to ~/.cline/hooks/PreToolUse and, from 0.17.0, the same script to ~/.cline/hooks/PostToolUse ($CLINE_DIR/hooks/ when that is set: run openmoat init with the same CLINE_DIR Cline runs with), and pins the MCP servers in Cline’s cline_mcp_settings.json. A file of yours with either name is backed up first, openmoat init says that it moved it aside, and openmoat uninstall gives it back.

    Cline runs PostToolUse after each call with what the call returned. OpenMoat keeps fingerprints of untrusted output, so a later call of the session that uses a host, path or command it named needs review (Injected input). That file never blocks: it prints nothing, since Cline would stop the whole run on a cancel after the call. After upgrading, openmoat status shows Cline’s hook out of date until openmoat init adds it.

  2. Start a new Cline session

    Cline runs every PreToolUse file in its hooks directories before each tool call, from its next session.

  3. Check it

    Terminal window
    openmoat status

    From 0.15.0 the Cline CLI’s line is followed by a line of its limits (cline --yolo runs no hooks; another hook or plugin can change a call after OpenMoat checked it; Cline runs the call when OpenMoat’s script cannot start or is killed after 120 s), and by every other PreToolUse file in Cline’s hook folders and every Cline plugin found. openmoat status --format json lists them under other_hooks, and gives each agent’s limit.

Cline tool Checked as
run_commands each command as a shell command, in the workspace; a {command, args} entry as its quoted words. Several commands are decided together; one that cannot be read alone (an open quote, a trailing \) makes the call need review
read_files, search_codebase file reads (search_codebase reads the workspace)
editor a file write
apply_patch every file the patch names
fetch_web_content a fetch for one URL; for several, every URL its arguments name
MCP tools (<server>__<tool>) an MCP tool, recorded as mcp__<server>__<tool>; a browser server’s call that only opens a page is that page’s open
any other tool (skills, subagent and team tools, a plugin’s) every path, URL and command its arguments name

The hook sees the arguments as the model gave them, before Cline puts them in one shape, so every shape Cline accepts is read and any other is denied. Cline sends two copies of a call’s arguments; the payload limit counts them once, so a large file is refused at the same size as on other agents, with a message that says to write it in parts. ask_question and submit_and_exit are not checked, and the model provider’s own web_search never reaches the hook.

Cline’s hooks cannot prompt, so a review is a deny, and a deny ends Cline’s run with OpenMoat’s reason. In your own terminal:

Terminal window
openmoat allow --last # that exact call, for the rest of the Cline session
openmoat allow --last --always # or a permanent rule

Then continue the session. Cline approves calls on its own by default (--auto-approve), so a call OpenMoat defers usually runs.

  • kernel-self protects Cline’s hook and plugin directories, and ~/Documents/Cline/Hooks, so the agent cannot change or remove OpenMoat’s script.
  • agent-credentials covers Cline’s stored provider keys (~/.cline/data/settings/providers.json) and connector credentials.
  • Writes to a workspace’s hooks, .clinerules/hooks/ and .cline/hooks/ (every file of which Cline runs on each tool call), and renames onto .clinerules, .cline or their hooks folders need review (runs-later, from 0.15.0), since those hooks run with the agent’s rights. Rules files in .clinerules/ stay ordinary writes.
  • Session taint covers .cline and .clinerules: after the session read a web page or an MCP result, writing them needs review.
  • Any change to OpenMoat’s script denies every call until you run openmoat doctor --accept.

Cline runs a call whose hook fails, and reads only what the hook prints. So OpenMoat’s script prints a cancel itself when openmoat is missing, crashes or exits without its answer.

Failure Cline
openmoat missing, crashing or giving no answer blocked by OpenMoat’s script
the script cannot start (no sh, as on native Windows) runs the call
the script prints something that is not JSON runs the call
the script is killed after Cline’s 120 seconds runs the call
--yolo runs no hooks at all
  • No OS sandbox from OpenMoat: an allowed command runs with your permissions, and a script the session wrote needs review before it runs (Code the agent wrote).
  • --config, --hooks-dir or a CLINE_DIR that OpenMoat did not install into skip OpenMoat’s script. CLINE_DATA_DIR and CLINE_MCP_SETTINGS_PATH move Cline’s data and MCP file; OpenMoat reads them only at their default place.
  • Another PreToolUse file or a plugin can rewrite a call’s input after OpenMoat checked it. openmoat status and openmoat doctor name each one they find.

Every agent side by side: Supported agents.