Skip to main content
Shell functions provide a convenient way to set machine-specific defaults and create shorthand commands for running agents with Safehouse.

Why Use Shell Wrappers?

If you work across multiple projects with shared dependencies, caches, or team folders in machine-specific locations, you’ll want to keep those settings out of project config files. Shell wrappers let you:
  • Define machine-local defaults once
  • Create convenient shortcuts for common workflows
  • Keep machine-specific paths out of shared repositories
  • Reuse configurations across multiple agents and tools

Basic Pattern

Add this to your shell configuration file (~/.zshrc, ~/.bashrc, or equivalent):
~/.zshrc
Now you can run:

Advanced Pattern with Append Profile

For machine-local policy exceptions that can’t be expressed with --add-dirs alone, use --append-profile:
1

Create a local overrides profile

Create a Sandbox Profile file for machine-specific rules:
~/.config/agent-safehouse/local-overrides.sb
2

Set up shell function

Add this to your ~/.zshrc:
~/.zshrc
3

Use your wrapper

All invocations now include your machine-local overrides:
Use --add-dirs-ro/--add-dirs for normal folder access. Reserve --append-profile for machine-local policy exceptions or final deny/allow overrides.

Complete Example

Here’s a full-featured setup with multiple shortcuts:
~/.zshrc
Usage examples:
Agent shortcuts
Workflow wrappers
Review mode

Per-Project Wrappers

For projects with unique requirements, create project-specific scripts:
~/my-project/scripts/safe-test.sh
Make it executable:
Run it:

Environment Variable Patterns

Use environment variables for settings that apply to all Safehouse invocations:
~/.zshrc
These apply even when you invoke safehouse directly without wrapper functions.
Be careful with SAFEHOUSE_TRUST_WORKDIR_CONFIG=1. This trusts .safehouse config files in all directories you run Safehouse from, including untrusted repositories.

App Launchers

You can use shell functions to launch GUI apps through Safehouse:
~/.zshrc
Usage:
For a better app launch experience, consider using the prebuilt launcher scripts in dist/ or creating .command files that macOS can execute directly.

Debugging Your Setup

Use --explain to verify your wrapper configuration:
This shows:
  • All path grants (from shell function and environment)
  • Loaded agent profiles
  • Optional integrations
  • Appended profile files

Tips and Best Practices

Keep It DRY

Define common options once in a base safe() function. Derive agent-specific functions from it.

Machine-Local Only

Put shell functions in ~/.zshrc or ~/.bashrc, not in project repositories. These are machine-specific.

Use Append Profiles

For complex machine-local rules, use --append-profile with a .sb file instead of long CLI arguments.

Document Assumptions

Add comments in your shell config explaining what paths like $SHARED_LIBS or $TEAM_RESOURCES are for.