Skip to content
$ shellfirm

Cline

A PreToolUse hook script that checks every Cline tool call and cancels risky ones, plus shellfirm's MCP server.

Cline 3.36 or later, on macOS and Linux. The hook runs in the VS Code extension and in the Cline CLI.

Connect

shellfirm connect cline
Output
shellfirm — connecting Cline integration

  /home/dev/.config/Code/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json:
    - add mcpServers.shellfirm = {"command":"shellfirm","args":["mcp","--config-dir","/home/dev/.config/shellfirm"]}
    ✓ written
  /home/dev/Documents/Cline/Hooks/PreToolUse:
    - add the Cline PreToolUse hook script running `shellfirm check --hook cline --config-dir /home/dev/.config/shellfirm`
    ✓ written

Cline tool calls are now checked by shellfirm (PreToolUse hook; dangerous and risky ones cancel the task, because Cline hooks cannot ask). In the VS Code extension, turn on "Enable Hooks" in Cline's settings (Cline 3.36 or later).

Turn on Enable Hooks

In the VS Code extension, turn on Enable Hooks in Cline's settings. Until you do, the script is not run and nothing is intercepted. shellfirm status reminds you.

Connected Cline before?

Earlier versions registered only the MCP server for Cline. Run shellfirm connect cline again: it keeps the MCP entry (= MCP server already installed) and adds the hook script. --mcp-only keeps the old behaviour.

What it installs

A hook script, ~/Documents/Cline/Hooks/PreToolUse, that Cline runs before every tool call. It is shellfirm's own (it starts with # shellfirm-hook: cline):

~/Documents/Cline/Hooks/PreToolUse
#!/bin/sh
# shellfirm-hook: cline
# config-dir: /home/dev/.config/shellfirm
# Written by `shellfirm connect cline`; remove it with
# `shellfirm connect cline --uninstall`. Changes are overwritten when
# `shellfirm connect cline` runs again.
#
# Cline runs this before every tool call. shellfirm answers in Cline's
# format ({"cancel": true|false, ...}); if shellfirm cannot run, the
# tool call is cancelled.
SHELLFIRM=shellfirm
command -v "$SHELLFIRM" >/dev/null 2>&1 || SHELLFIRM=/usr/local/bin/shellfirm
out=$("$SHELLFIRM" check --hook cline --config-dir /home/dev/.config/shellfirm)
status=$?
if [ "$status" -eq 0 ] && [ -n "$out" ]; then
  printf '%s\n' "$out"
else
  printf '{"cancel": true, "errorMessage": "shellfirm could not check this tool call (exit %s); cancelling it. Run `shellfirm doctor` or `shellfirm connect cline --uninstall`."}\n' "$status"
fi
exit 0
  • Cline lets a tool call through when a hook script fails, so the script answers {"cancel": true} itself when shellfirm cannot run. That makes the Cline hook fail-closed.
  • When shellfirm is not on Cline's PATH, the script runs the binary that connect ran from.
  • An existing PreToolUse script that shellfirm did not write is never replaced or removed. shellfirm status lists such a script.

Checked tools: execute_command and run_commands (several commands are checked one by one), edits with write_to_file, replace_in_file, editor and apply_patch, and reads with read_file and read_files (checked like cat <path>). An apply_patch is judged by its worst file. The VS Code extension sends preToolUse.toolName and preToolUse.parameters (string values as they are, other values JSON-encoded); the Cline CLI sends tool_call.name and tool_call.input.

What Cline sees

Cline hooks cannot ask, so risky calls are blocked like dangerous ones.

CommandAnswerEffect
No check matches (ls){"cancel":false}Runs
Risky (cat ~/.ssh/id_rsa, Medium){"cancel":true,"errorMessage":...}Cline stops the task with shellfirm's message; the audit log records deny_reason: agent_auto_deny
Dangerous (git push -f origin main, High){"cancel":true,"errorMessage":...}Cline stops the task

Real answer for git push -f origin main:

{"cancel":true,"errorMessage":"shellfirm BLOCKED this command.\n[git:force_push] [HIGH] This force-pushes and can overwrite remote history.\nContext: Critical (target=main)\nBLOCKED: Severity HIGH meets or exceeds agent auto-deny threshold HIGH\nSafe alternative: git push --force-with-lease (Checks that your local ref is up-to-date before force pushing, preventing accidental overwrites of others' work.)"}

Options

OptionEffect
--scope user (default)Hook script ~/Documents/Cline/Hooks/PreToolUse, MCP server in Cline's cline_mcp_settings.json
--scope projectHook script ./.clinerules/hooks/PreToolUse. The MCP registration is user-level only
--hooks-only / --mcp-onlyOnly the hook script, or only the MCP server
--dry-runShow what would change, write nothing
--uninstallRemove shellfirm's script and MCP entry only

Where cline_mcp_settings.json is on each OS: see Where the files are on each OS.

Check the integration

Output
  Agent integrations:
    cline (user): hook yes, file tools yes, fail-closed yes, MCP yes (in the VS Code extension, turn on "Enable Hooks" in Cline's settings)