Quick Start
Generate a policy file
Run Safehouse without a command to generate a sandbox policy:This prints the path to a generated policy file. You can inspect the policy or pass it to your own
sandbox-exec invocation.Run a command in the sandbox
Pass a command after The policy is generated, the command runs inside it, and the policy file is cleaned up automatically.
-- to execute it inside the sandbox:Common Workflows
View Policy Text
Print the generated sandbox policy to stdout:When using
--stdout, the command (if provided) is not executed. This mode only generates and displays the policy.Execute Mode
Run commands inside the sandbox with various permission grants:Grant Additional Paths
Grant read-only or read/write access to additional directories:Read-only access
Read/write access
Paths in
--add-dirs-ro and --add-dirs are colon-separated (:) on macOS, similar to PATH variables.Preserve Policy Files
Save the generated policy to a specific file:--output is specified, the policy file is preserved after execution instead of being deleted.
Profile Detection
Safehouse automatically loads agent and app profiles based on the command you’re running:CLI Agents
Profiles are detected by command name:
App Bundles
App profiles are detected from
.app bundles:Environment Variables
By default, Safehouse runs commands with a sanitized environment containing only safe defaults. You can customize this behavior:Pass-through Mode
Inherit all environment variables from the host:Load from File
Start with sanitized defaults and overlay variables from a file:/bin/bash, so use shell syntax:
.env.sh
Pass Specific Variables
Add individual variables to the sanitized environment:Single variable
Multiple variables
--env-pass is compatible with --env=FILE but not with --env (full pass-through).Debugging and Inspection
Explain Mode
Print detailed information about the policy generation:- Effective working directory and source
- Read-only and read/write path grants
- Loaded agent/app profiles
- Optional integrations included
- Config file status (loaded, ignored, or not found)
Sandbox Denial Logs
When operations fail due to sandbox restrictions, check the system logs:Typical Patterns
Local Development
Run tests in sandbox
Multi-Tool Workflows
Git + Docker + Agent
Git and common SCM tools are enabled by default. You don’t need
--enable=git.Read-Only Project Access
Review mode
Command Separator
The-- separator is optional but recommended: