Skip to main content
Agent Safehouse operates in two distinct modes depending on whether you provide a command to execute.

Policy Mode

Generates a sandbox policy file without executing a command. Use this mode when you want to inspect the policy or pass it to your own sandbox-exec invocation.
Generates a temporary policy file and prints its path to stdout. Example:
Prints the generated policy content directly to stdout instead of creating a file. Example:
Policy mode is useful for:
  • Inspecting generated policies before execution
  • Debugging sandbox behavior
  • Creating reusable policy files
  • Understanding what permissions are granted

Execute Mode

Generates a sandbox policy and immediately executes the specified command inside that sandbox.

Basic Execution

The -- separator is recommended to clearly distinguish policy options from command arguments. Examples:

Execution Without Separator

You can omit -- if the command is unambiguous (doesn’t start with --). Example:
If your command arguments include options starting with --, always use the -- separator to avoid ambiguity.

Explain Mode

Debugging mode that prints detailed information about policy decisions to stderr.
Shows:
  • Effective workdir and its source (flag, env, or default)
  • Path grants (read-only and read-write)
  • Selected agent profiles
  • Integration selections and reasons
Example:
--explain is invaluable for troubleshooting:
  • Why certain files are accessible/inaccessible
  • Which profiles are being loaded
  • Where configuration values come from

Common Usage Patterns

Quick Testing

Development Workflow

CI/CD Integration

Debugging

Command Resolution

Safehouse automatically detects the command being executed and loads appropriate agent profiles:

Supported Wrappers

Safehouse looks through these wrapper commands to find the actual target:
  • npx
  • bunx
  • uvx
  • pipx
  • xcrun
For wrappers, safehouse uses the second argument (the actual command name) for profile selection.

Exit Status

In execute mode, safehouse exits with the same status code as the wrapped command: