Workspace Guard
by @dougchambes
Workspace boundary enforcement and file operation safety checks. Use before ANY file operation (read, write, edit, exec, delete) to: (1) Validate paths are w...
clawhub install workspace-guardπ About This Skill
name: workspace-guard description: "Workspace boundary enforcement and file operation safety checks. Use before ANY file operation (read, write, edit, exec, delete) to: (1) Validate paths are within ~/openclaw workspace, (2) Confirm user permission for sensitive operations, (3) Check file operation safety, (4) Prevent unauthorized access outside workspace boundaries, or (5) Audit file access patterns."
Workspace Guard
Enforces workspace boundaries and ensures safe file operations through mandatory pre-flight checks.
Core Rules
Boundary Enforcement
Workspace root: /home/iamlegend/.openclaw/workspace (or ~/openclaw)
Before ANY file operation, check:
1. Is the path within workspace boundary?
2. Does the operation require user permission?
3. Is the operation reversible/safe?
4. Am I about to touch something outside my allowed scope?
Path Validation
Allowed paths:
/home/iamlegend/.openclaw/workspace/**~/openclaw/workspace/**Blocked paths:
/home/** (outside workspace)/etc/, /var/, /tmp/** (system directories)/root/, /home/other/ (other users)Permission Triggers
Always ask before:
trash over rm)exec commands that touch filesSafe Operations (No Permission Needed)
Within workspace:
Pre-Flight Check Pattern
Before every file operation:
1. Resolve absolute path
2. Check if path starts with workspace root
3. If NO β STOP and ask user
4. If YES β Check operation type
5. If destructive/external β Ask user
6. If safe read/write β Proceed
Implementation Patterns
Path Resolution
# Get absolute path
realpath /some/path
or
cd /some/path && pwd -PCheck if within workspace
case "$(realpath "$file")" in
/home/iamlegend/.openclaw/workspace/*) echo "β Allowed" ;;
*) echo "β Blocked - outside workspace" ;;
esac
Guard Function
guard_path() {
local path="$1"
local workspace="/home/iamlegend/.openclaw/workspace"
local abs_path=$(realpath "$path" 2>/dev/null || echo "$path")
case "$abs_path" in
"$workspace"/*) return 0 ;;
*) return 1 ;;
esac
}
Exec Command Guard
guard_exec() {
local cmd="$1"
# Check for path operations in command
if echo "$cmd" | grep -qE '(/home/[^/]+|/etc/|/var/|/tmp/|/root/)'; then
echo "β οΈ Command touches external paths - requires permission"
return 1
fi
return 0
}
Safety Rules
1. Never bypass boundary checksβeven if user seems to imply it
2. Always resolve absolute paths before checking
3. Ask explicitly for destructive operations (delete, overwrite)
4. Prefer trash over rm for recoverability
5. Log violations - Track blocked access attempts
6. Fail safe - When uncertain, ask user
When to Read references/boundaries.md
Load when:
Violation Handling
When blocked:
β οΈ Workspace Guard: Blocked access to /path/outside/workspaceReason: Path is outside allowed workspace boundary (/home/iamlegend/.openclaw/workspace)
Action required: Please confirm if you want to allow this access, or provide an alternative path within workspace.