ClawBands is a security middleware for OpenClaw AI agents.
TypeScript
196
2 commits
updated Feb 9, 2026
Put safety bands on OpenClaw
ClawBands is a security middleware for OpenClaw AI agents. It hooks into OpenClaw's plugin system to intercept every tool execution (file writes, shell commands, network requests) and enforces human-in-the-loop approval before dangerous actions execute.
OpenClaw can execute shell commands, modify files, and access your APIs. OS-level isolation (containers, VMs) protects your host machine, but it doesn't protect the services your agent has access to.
ClawBands solves this by hooking into OpenClaw's before_tool_call plugin event. Before any dangerous action executes (writes, deletes, shell commands, API calls), the agent pauses and waits for your decision. In a terminal, you get an interactive prompt. On messaging channels (WhatsApp, Telegram), the agent asks you YES/NO and relays your answer via a dedicated clawbands_respond tool. Every choice is logged to an immutable audit trail. Think of it as sudo for your AI agent: nothing happens without your explicit permission.
clawbands_respond tool# Install globally
npm install -g clawbands
# Run interactive setup
clawbands init
# Restart OpenClaw
openclaw restart
Done! ClawBands is now protecting your OpenClaw instance.
Agent calls tool: write('/etc/passwd', 'hacked')
β before_tool_call hook fires
β ClawBands checks policy: write = ASK
β Interactive prompt:
βββββββββββββββββββββββββββββββββββββββ
β π¦ CLAWBANDS SECURITY ALERT β
β β
β Module: FileSystem β
β Method: write β
β Args: ["/etc/passwd", "hacked"] β
β β
β β― β Approve β
β β Reject β
βββββββββββββββββββββββββββββββββββββββ
β You reject β { block: true }
β Decision logged to audit trail
Agent calls tool: bash('rm -rf /tmp/data')
β before_tool_call β policy = ASK β blocked (pending approval)
β Agent asks: "ClawBands requires approval. YES or NO?"
User replies YES:
β Agent calls clawbands_respond({ decision: "yes" })
β before_tool_call intercepts β approves pending entry
β Agent retries bash('rm -rf /tmp/data') β approved β
User replies NO:
β Agent calls clawbands_respond({ decision: "no" })
β before_tool_call intercepts β denies pending entry
β Agent does NOT retry β cancelled β
The clawbands_respond tool is registered automatically via api.registerTool() when the gateway supports it.
ClawBands uses three decision types:
| Policy | Behavior |
|---|---|
| ALLOW | Execute immediately (e.g., file reads) |
| ASK | Prompt for approval (e.g., file writes) |
| DENY | Block automatically (e.g., file deletes) |
Default policy (Balanced):
clawbands init # Interactive setup wizard
clawbands policy # Manage security policies
clawbands stats # View statistics
clawbands audit # View decision history
clawbands reset # Reset statistics
clawbands disable # Temporarily disable
clawbands enable # Re-enable
$ clawbands audit --lines 5
16:05:00 | FileSystem.read | ALLOWED | 0.0s
16:06:00 | FileSystem.write | APPROVED | 3.5s (human)
16:07:00 | Shell.bash | REJECTED | 1.2s (human)
16:08:00 | FileSystem.delete | BLOCKED | 0.0s - Policy: DENY
$ clawbands stats
π ClawBands Statistics
Total Calls: 142
Decisions:
β
Allowed: 35 (24.6%)
β
Approved: 89 (62.7%) - by user
β Rejected: 12 (8.5%) - by user
π« Blocked: 6 (4.2%) - by policy
Average Decision Time: 2.8s
All data stored in ~/.openclaw/clawbands/:
~/.openclaw/clawbands/
βββ policy.json # Your security rules
βββ decisions.jsonl # Audit trail (append-only)
βββ stats.json # Statistics
βββ clawbands.log # Application logs
import { Interceptor, createToolCallHook } from 'clawbands';
// Create interceptor with default policy
const interceptor = new Interceptor();
// Create a hook handler for OpenClaw's before_tool_call event
const hook = createToolCallHook(interceptor);
// Register with the OpenClaw plugin API
api.on('before_tool_call', hook);
ClawBands intercepts every tool mapped in TOOL_TO_MODULE:
Any unmapped tool falls through to defaultAction (ASK by default).
src/
βββ core/
β βββ Interceptor.ts # Policy evaluation engine
β βββ Arbitrator.ts # Human-in-the-loop (TTY prompt / channel queue)
β βββ ApprovalQueue.ts # In-memory approval state for channel mode
β βββ Logger.ts # Winston-based logging
βββ plugin/
β βββ index.ts # Plugin entry point (hook + tool registration)
β βββ tool-interceptor.ts # before_tool_call handler + clawbands_respond intercept
β βββ config-manager.ts # OpenClaw config management (register/unregister)
βββ storage/ # Persistence (PolicyStore, DecisionLog, StatsTracker)
βββ cli/ # Command-line interface
βββ types.ts # TypeScript definitions
βββ config.ts # Default policies
# Clone repo
git clone https://github.com/SeyZ/clawbands.git
cd clawbands
# Install dependencies
npm install
# Build
npm run build
# Test CLI locally
node dist/cli/index.js init
# Link for global testing
npm link
clawbands --help
β Zero Trust - Every action evaluated β Synchronous Blocking - Agent waits for approval β No Bypass - Plugin hooks intercept all tool calls β Immutable Audit - JSON Lines append-only format β Human Authority - Critical decisions need approval β Fail Secure - Unknown actions default to ASK/DENY
We believe in safe AI. PRs welcome!
git checkout -b feature/amazinggit commit -m 'Add amazing feature'git push origin feature/amazingSee CONTRIBUTING.md for details.
MIT - See LICENSE for details.
Built with β€οΈ for a safer AI future.
2 commits
TypeScript
98.0%
JavaScript
2.0%
ClawBands is a security middleware for OpenClaw AI agents.
TypeScript
196
2 commits
updated Feb 9, 2026
Put safety bands on OpenClaw
ClawBands is a security middleware for OpenClaw AI agents. It hooks into OpenClaw's plugin system to intercept every tool execution (file writes, shell commands, network requests) and enforces human-in-the-loop approval before dangerous actions execute.
OpenClaw can execute shell commands, modify files, and access your APIs. OS-level isolation (containers, VMs) protects your host machine, but it doesn't protect the services your agent has access to.
ClawBands solves this by hooking into OpenClaw's before_tool_call plugin event. Before any dangerous action executes (writes, deletes, shell commands, API calls), the agent pauses and waits for your decision. In a terminal, you get an interactive prompt. On messaging channels (WhatsApp, Telegram), the agent asks you YES/NO and relays your answer via a dedicated clawbands_respond tool. Every choice is logged to an immutable audit trail. Think of it as sudo for your AI agent: nothing happens without your explicit permission.
clawbands_respond tool# Install globally
npm install -g clawbands
# Run interactive setup
clawbands init
# Restart OpenClaw
openclaw restart
Done! ClawBands is now protecting your OpenClaw instance.
Agent calls tool: write('/etc/passwd', 'hacked')
β before_tool_call hook fires
β ClawBands checks policy: write = ASK
β Interactive prompt:
βββββββββββββββββββββββββββββββββββββββ
β π¦ CLAWBANDS SECURITY ALERT β
β β
β Module: FileSystem β
β Method: write β
β Args: ["/etc/passwd", "hacked"] β
β β
β β― β Approve β
β β Reject β
βββββββββββββββββββββββββββββββββββββββ
β You reject β { block: true }
β Decision logged to audit trail
Agent calls tool: bash('rm -rf /tmp/data')
β before_tool_call β policy = ASK β blocked (pending approval)
β Agent asks: "ClawBands requires approval. YES or NO?"
User replies YES:
β Agent calls clawbands_respond({ decision: "yes" })
β before_tool_call intercepts β approves pending entry
β Agent retries bash('rm -rf /tmp/data') β approved β
User replies NO:
β Agent calls clawbands_respond({ decision: "no" })
β before_tool_call intercepts β denies pending entry
β Agent does NOT retry β cancelled β
The clawbands_respond tool is registered automatically via api.registerTool() when the gateway supports it.
ClawBands uses three decision types:
| Policy | Behavior |
|---|---|
| ALLOW | Execute immediately (e.g., file reads) |
| ASK | Prompt for approval (e.g., file writes) |
| DENY | Block automatically (e.g., file deletes) |
Default policy (Balanced):
clawbands init # Interactive setup wizard
clawbands policy # Manage security policies
clawbands stats # View statistics
clawbands audit # View decision history
clawbands reset # Reset statistics
clawbands disable # Temporarily disable
clawbands enable # Re-enable
$ clawbands audit --lines 5
16:05:00 | FileSystem.read | ALLOWED | 0.0s
16:06:00 | FileSystem.write | APPROVED | 3.5s (human)
16:07:00 | Shell.bash | REJECTED | 1.2s (human)
16:08:00 | FileSystem.delete | BLOCKED | 0.0s - Policy: DENY
$ clawbands stats
π ClawBands Statistics
Total Calls: 142
Decisions:
β
Allowed: 35 (24.6%)
β
Approved: 89 (62.7%) - by user
β Rejected: 12 (8.5%) - by user
π« Blocked: 6 (4.2%) - by policy
Average Decision Time: 2.8s
All data stored in ~/.openclaw/clawbands/:
~/.openclaw/clawbands/
βββ policy.json # Your security rules
βββ decisions.jsonl # Audit trail (append-only)
βββ stats.json # Statistics
βββ clawbands.log # Application logs
import { Interceptor, createToolCallHook } from 'clawbands';
// Create interceptor with default policy
const interceptor = new Interceptor();
// Create a hook handler for OpenClaw's before_tool_call event
const hook = createToolCallHook(interceptor);
// Register with the OpenClaw plugin API
api.on('before_tool_call', hook);
ClawBands intercepts every tool mapped in TOOL_TO_MODULE:
Any unmapped tool falls through to defaultAction (ASK by default).
src/
βββ core/
β βββ Interceptor.ts # Policy evaluation engine
β βββ Arbitrator.ts # Human-in-the-loop (TTY prompt / channel queue)
β βββ ApprovalQueue.ts # In-memory approval state for channel mode
β βββ Logger.ts # Winston-based logging
βββ plugin/
β βββ index.ts # Plugin entry point (hook + tool registration)
β βββ tool-interceptor.ts # before_tool_call handler + clawbands_respond intercept
β βββ config-manager.ts # OpenClaw config management (register/unregister)
βββ storage/ # Persistence (PolicyStore, DecisionLog, StatsTracker)
βββ cli/ # Command-line interface
βββ types.ts # TypeScript definitions
βββ config.ts # Default policies
# Clone repo
git clone https://github.com/SeyZ/clawbands.git
cd clawbands
# Install dependencies
npm install
# Build
npm run build
# Test CLI locally
node dist/cli/index.js init
# Link for global testing
npm link
clawbands --help
β Zero Trust - Every action evaluated β Synchronous Blocking - Agent waits for approval β No Bypass - Plugin hooks intercept all tool calls β Immutable Audit - JSON Lines append-only format β Human Authority - Critical decisions need approval β Fail Secure - Unknown actions default to ASK/DENY
We believe in safe AI. PRs welcome!
git checkout -b feature/amazinggit commit -m 'Add amazing feature'git push origin feature/amazingSee CONTRIBUTING.md for details.
MIT - See LICENSE for details.
Built with β€οΈ for a safer AI future.
2 commits
TypeScript
98.0%
JavaScript
2.0%