Windsurf
Cascade hooks that check Windsurf commands, file writes and reads before they run, plus shellfirm's MCP server.
Connect
shellfirm connect windsurfshellfirm — connecting Windsurf integration
/home/dev/.codeium/windsurf/hooks.json:
- add hooks.pre_run_command entry running `shellfirm check --hook windsurf --config-dir /home/dev/.config/shellfirm`
- add hooks.pre_write_code entry running `shellfirm check --hook windsurf --config-dir /home/dev/.config/shellfirm`
- add hooks.pre_read_code entry running `shellfirm check --hook windsurf --config-dir /home/dev/.config/shellfirm`
✓ written
/home/dev/.codeium/windsurf/mcp_config.json:
- add mcpServers.shellfirm = {"command":"shellfirm","args":["mcp","--config-dir","/home/dev/.config/shellfirm"]}
✓ written
Windsurf (Cascade) commands, file writes and reads are now checked by shellfirm (pre_run_command / pre_write_code / pre_read_code hooks; dangerous and risky ones are blocked, because Cascade hooks cannot ask). Restart Windsurf.Restart Windsurf afterwards.
Connected Windsurf before?
Earlier versions registered only the MCP server for Windsurf. Run
shellfirm connect windsurf again: it keeps the MCP entry
(= MCP server already installed) and adds the hooks. --mcp-only keeps the
old behaviour.
What it installs
{
"hooks": {
"pre_run_command": [
{
"show_output": false,
"command": "shellfirm check --hook windsurf --config-dir /home/dev/.config/shellfirm"
}
],
"pre_write_code": [
{
"show_output": false,
"command": "shellfirm check --hook windsurf --config-dir /home/dev/.config/shellfirm"
}
],
"pre_read_code": [
{
"show_output": false,
"command": "shellfirm check --hook windsurf --config-dir /home/dev/.config/shellfirm"
}
]
}
}| Hook | Checks |
|---|---|
pre_run_command | Every command Cascade runs (tool_info.command_line, in tool_info.cwd) |
pre_write_code | Every file write (tool_info.file_path) |
pre_read_code | Every file read, checked like cat <path> |
The MCP server in ~/.codeium/windsurf/mcp_config.json gives Cascade the MCP tools as well.
What Cascade sees
Cascade reads no JSON from a hook. To block, shellfirm exits 2 and writes the reason to stderr; Cascade shows it to the agent. Cascade hooks cannot ask, so risky actions are blocked like dangerous ones, with the reason and a safer alternative. If the command is intended, run it yourself.
| Command | Answer | Effect |
|---|---|---|
No check matches (ls) | exit 0, no output | Runs |
Risky (cat ~/.ssh/id_rsa, Medium) | exit 2, reason on stderr | Blocked; the audit log records deny_reason: agent_auto_deny |
Dangerous (git push -f origin main, High) | exit 2, reason on stderr | Blocked |
Real stderr for cat ~/.ssh/id_rsa:
shellfirm BLOCKED this command.
[exfil:read_secret_file] [MEDIUM] This reads a private key or a credentials file. Shown on screen it can leak (screen sharing, terminal logs); run by an AI agent, the secret goes into the conversation and on to the model provider.
BLOCKED: Matched risky pattern(s) (severity MEDIUM, below the auto-deny threshold HIGH); confirm before running (Windsurf cannot ask for confirmation, so shellfirm blocks it; run it yourself if it is intended)
Safe alternative: read only what you need, not the secret itself (An SSH private key: `ssh-keygen -y -f <key>` prints just the public half. A credentials file: a command that hides the secret shows the same, e.g. `aws configure list`, `kubectl config view`, `gh auth status`, `npm config list`.)Not fail-closed
Any exit code other than 2 lets the action run, also when shellfirm is missing.
shellfirm status shows fail-closed no for Windsurf.
Options
| Option | Effect |
|---|---|
--scope user (default) | Hooks in ~/.codeium/windsurf/hooks.json, MCP server in ~/.codeium/windsurf/mcp_config.json |
--scope project | Hooks in ./.windsurf/hooks.json. The MCP registration is user-level only, so run the user-scope connect for it |
--hooks-only / --mcp-only | Only the hooks, or only the MCP server |
--dry-run | Show what would change, write nothing |
--uninstall | Remove shellfirm's entries only |
Check the integration
Agent integrations:
windsurf (user): hook yes, file tools yes, fail-closed no, MCP yesshellfirm doctor:
[ok] agent_hook windsurf (user): hook in /home/dev/.codeium/windsurf/hooks.json (the agent runs the tool call if shellfirm cannot run)