Shell Guard
July 16, 2026 ยท View on GitHub
Block specific tool calls so MindRoom agents cannot run dangerous shell commands.
Agents may legitimately run shell commands, edit files, and inspect services. This plugin narrows one critical safety gap: it prevents an agent from restarting, stopping, or disabling the mindroom-chat service that it is currently running inside.
Features
- Intercepts
run_shell_commandbefore the shell command executes - Blocks
systemctl restart,stop, anddisableformindroom-chat - Catches both direct and
sudovariants of those commands - Declines the tool call with an explicit explanation instead of failing silently
- Keeps the blocked command list local and easy to extend in
_BLOCKED_PATTERNS
How It Works
- An agent invokes
run_shell_command. - The
shell-guardhook inspects the tool arguments duringtool:before_call. - If the command matches a blocked regex, the hook declines the call immediately.
- If nothing matches, the shell tool proceeds normally.
Hooks
| Hook | Event | Purpose |
|---|---|---|
shell-guard | tool:before_call | Intercept and block dangerous shell commands before execution |
Customization
Blocked by default:
systemctl restart mindroom-chatsystemctl stop mindroom-chatsystemctl disable mindroom-chat- The same commands prefixed with
sudo
To block additional commands, add more regex patterns to _BLOCKED_PATTERNS in hooks.py.
Install
Vendor this plugin with the MindRoom CLI:
mindroom plugins install shell-guard-plugin
Then reference it from config.yaml:
plugins:
- path: plugins/shell-guard-plugin
Update to the latest commit later with:
mindroom plugins update shell-guard-plugin
The command pins the exact installed commit in .mindroom-plugin.lock.json and strictly validates the plugin before activating it.
For a manual checkout instead, see Setup below.
Setup
- Copy this plugin to
~/.mindroom/plugins/shell-guard. - Add the plugin to
config.yaml:plugins: - path: plugins/shell-guard - Restart MindRoom.
No agent tools or plugin settings are required.