Skip to main content

Overview

Agent Safehouse provides two primary customization mechanisms:
  1. Machine-local overrides (.safehouse config files)
  2. --append-profile flag (runtime policy overlays)
Each serves different use cases. This guide explains when to use which approach.

Machine-Local Overrides

Workdir Config Files

Place a .safehouse file in your project root to configure project-specific grants:
Workdir config files are untrusted by default. You must explicitly opt in:
Or set globally:

Shell Environment Variables

Set environment variables in your shell profile (~/.zshrc, ~/.bashrc):

Precedence Order

When the same variable is set in multiple locations:
1

CLI flags (highest priority)

2

Environment variables

3

Workdir config (lowest priority)

Path grants are merged across all sources (CLI + ENV + config). Later sources append to earlier ones.Feature flags (--enable) are replaced (not merged). CLI --enable overrides ENV SAFEHOUSE_ENABLE, which overrides config SAFEHOUSE_ENABLE.

--append-profile Flag

Purpose

Append a custom .sb file to the end of the generated policy. This is the final extension point in the assembly order.

Use Cases

Deny Sensitive Paths

Block access to specific directories even if earlier rules allowed them:

Ad-Hoc Grants

Quickly grant access to a new tool or path without editing committed profiles:

Testing Policy Changes

Iterate on policy rules before committing them to the repository:

Environment-Specific Rules

Apply machine-specific grants without editing source profiles:

Multiple Appended Profiles

Pass --append-profile multiple times. They are concatenated in order:

Last Rule Wins

Because --append-profile rules are emitted last in the policy assembly order, they override earlier rules:
The deny rule wins because it comes last.

Comparison: When to Use Which


Example Workflows

Workflow 1: Project-Specific Reference Repo

You’re working on ~/projects/myapp and need read-only access to ~/reference/design-system.
1

Create workdir config

2

Trust the config (once)

Or enable trust globally:
3

Run agent

The agent now has read-only access to ~/reference/design-system.

Workflow 2: Block Cloud Credentials

You want to ensure agents never access ~/.aws or ~/.config/gcloud, even if cloud-credentials integration is enabled.
1

Create deny profile

2

Run with appended profile

3

Make it persistent (optional)

Add to shell ENV:
Now all safehouse invocations include the deny rules.
--append-profile paths are not automatically resolved in ENV vars. Use absolute paths or $HOME:

Workflow 3: Machine-Wide Docker + SSH

You want Docker and SSH enabled for all agent invocations on your machine.
1

Set ENV var

2

Reload shell

3

Verify

Output:

Debugging Overrides

Inspect Effective Config

Use --explain to see which config sources were loaded:

Check Policy for Appended Rules

Generate policy and search for your appended profile:

Best Practices

Use Workdir Config for Projects

Commit .safehouse to your repo for team-shared project grants. Keep machine-specific overrides in ENV or --append-profile.

Use ENV for Machine Defaults

Set SAFEHOUSE_ENABLE, SAFEHOUSE_ADD_DIRS_RO in ~/.zshrc for your personal workflow defaults.

Use --append-profile for Denies

Deny rules must come last to override allows. --append-profile is the only way to guarantee last-rule-wins.

Test Before Committing

Use --append-profile=./test.sb to iterate on new rules before moving them to profiles/.

Environment Variable Reference

All path variables (SAFEHOUSE_ADD_DIRS_RO, SAFEHOUSE_ADD_DIRS, SAFEHOUSE_APPEND_PROFILE) support colon-separated lists:

Next Steps

Write Custom Profiles

Learn how to write your own .sb files with matchers and real examples.

Policy Architecture

Understand assembly order, profile layers, and dependency system.