Safe Command Execution
Rafter validates shell commands before execution to prevent dangerous operations.Quick Start
Execute a command with security checks:How It Works
When you runrafter agent exec, Rafter:
- Evaluates the command against security policies
- Scans staged files (for git commands)
- Assesses risk level (low/medium/high/critical)
- Blocks or requires approval based on risk
- Logs the execution to audit log
Risk Levels
🔴 Critical (Blocked)
🔴 Critical (Blocked)
Commands that can cause catastrophic damage:
rm -rf /- Delete entire filesystem:(){ :|:& };:- Fork bombdd if=/dev/zero of=/dev/sda- Wipe diskmkfs.*- Format filesystems> /dev/sda- Overwrite disk
--force.🟠 High (Requires Approval)
🟠 High (Requires Approval)
Commands with significant risk:
rm -rf <directory>- Recursive deletionsudo rm- Delete with elevated privilegeschmod 777- Insecure permissionscurl ... | sh- Pipe to shellgit push --force- Force pushnpm publish- Publish packagesdocker system prune- Delete Docker data
--force flag is used.🟡 Medium (Context-Dependent)
🟡 Medium (Context-Dependent)
Commands that need elevated privileges:
sudo- Any sudo commandchmod- Change permissionskill -9- Force kill processessystemctl- System service management
🟢 Low (Allowed)
🟢 Low (Allowed)
Standard commands with minimal risk:
npm install- Install packagesgit commit- Commit changesls,cat,grep- Read operationsecho,touch- Basic file operations
Usage Examples
Safe Command
Executes immediately:Git Commit with Auto-Scan
Scans staged files before committing:High-Risk Command
Requires approval:Force Execution
Skip approval with--force (logged in audit):
Skip File Scanning
Skip pre-execution scanning for git commands:Command Policies
Configure how Rafter handles commands:Policy Modes
Custom Blocked Patterns
Add patterns to always block:Custom Approval Patterns
Patterns requiring approval:Audit Logging
All command executions are logged:- Timestamp
- Command executed
- Risk level
- Action taken (allowed/blocked/overridden)
- User justification (for overrides)
Integration with Agents
OpenClaw
When integrated with OpenClaw, commands are automatically routed through Rafter:Claude Code
Coming soon: MCP server integration.Exit Codes
Rafter uses standard exit codes:0- Success1- Command blocked or execution failed
Best Practices
Recommended Practices
- Always use for git commits: Auto-scans staged files
- Never bypass with
--forcein production: Use only when necessary - Review audit logs: Check
rafter agent auditafter suspicious activity - Configure policies: Adjust
commandPolicy.modefor your environment - Test in development: Ensure policies work before deploying to agents
Advanced Configuration
Risk Level vs Policy Mode
Understanding the Difference
- Risk Level (
agent.riskLevel): Controls overall security stance - Policy Mode (
agent.commandPolicy.mode): Controls specific command handling
riskLevel: aggressive+mode: approve-dangerous= Very secureriskLevel: minimal+mode: allow-all= Permissive
Custom Risk Assessment
Future feature: Define custom risk patterns and severity levels.Troubleshooting
Command Incorrectly Blocked
If a safe command is blocked:-
Check current policy:
-
Switch to a more permissive mode:
- Report false positive: rafter-cli/issues
Secrets Not Detected
If secrets aren’t caught during git commits:-
Ensure scanning is enabled (default):
-
Test scanner separately:

