.safehouse config file allows you to define project-specific path grants that are loaded when Safehouse runs in that directory.
Trust Model
By default,.safehouse config files are ignored for security reasons. You must explicitly opt-in to loading them.
Why Disabled by Default?
Imagine you clone a repository you’ve never seen before and run an agent in it. If Safehouse automatically loaded.safehouse from that repo, a malicious config file could:
- Grant read access to
~/.ssh,~/.aws, or other credential directories - Grant write access to system locations
- Bypass the security boundaries Safehouse is designed to enforce
Enabling Config Loading
There are three ways to trust and load.safehouse config files:
- CLI Flag (Per-Invocation)
- Environment Variable (Session/Machine)
- Shell Function (Scoped)
Trust the config file for a single command:Use
=true or =false for explicit control:Config File Format
The.safehouse file uses a simple key=value format:
.safehouse
Supported Keys
Colon-separated paths to grant read-only access.Alternate names:
add_dirs_ro, SAFEHOUSE_ADD_DIRS_ROExample:Colon-separated paths to grant read/write access.Alternate names:
add_dirs, SAFEHOUSE_ADD_DIRSExample:Unknown keys are silently ignored for forward compatibility. This allows newer versions of Safehouse to add config options without breaking older versions.
Value Syntax
- Paths: Can be absolute or use
$HOME/~for home directory - Quotes: Optional. Single (
') or double (") quotes are stripped - Multiple values: Separate with colons (
:), likePATHenvironment variables - Whitespace: Leading and trailing whitespace is trimmed
- Comments: Lines starting with
#or;are ignored - Empty lines: Ignored
Complete Example
Here’s a realistic.safehouse config for a web development project:
.safehouse
- Read/write access to
~/projects/mywebapp(workdir, automatic) - Read-only access to
~/test-fixturesand~/api-mocks(from config) - Read/write access to
/tmp/myapp-build,~/myapp-dist, and~/.local/share/myapp/db(from config)
Precedence and Merging
When path grants come from multiple sources, they are merged (not overridden):- Config file (
.safehouseif trusted) - Environment variables (
SAFEHOUSE_ADD_DIRS_RO,SAFEHOUSE_ADD_DIRS) - CLI flags (
--add-dirs-ro,--add-dirs) - Workdir grant (automatic for current directory unless
--workdir="")
Debugging Config Loading
Use--explain to see whether the config file was loaded:
Security Best Practices
Review config files in unfamiliar repos
Before enabling Look for suspicious paths like
--trust-workdir-config, inspect the .safehouse file:~/.ssh, ~/.aws, or system directories.Commit .safehouse to version control
Share the config with your team:This documents the project’s filesystem requirements and makes them auditable.
Use machine-local overrides for sensitive paths
Keep machine-specific or sensitive grants in shell functions with See Shell Functions for more patterns.
--append-profile instead of .safehouse:~/.zshrc
Common Patterns
Build Output Directories
.safehouse
Shared Test Fixtures
.safehouse
Monorepo Shared Packages
.safehouse
Database Files
.safehouse
Disabling Workdir Config Explicitly
If an environment variable or shell function setsSAFEHOUSE_TRUST_WORKDIR_CONFIG=1, you can disable it for a specific invocation:
Advanced: Relative Paths
Paths in.safehouse are resolved relative to the workdir (not the location of the config file itself):
.safehouse
- Read-only:
~/my-project/shared,~/my-project/libs - Read/write:
~/my-project/build
Troubleshooting
Config file is ignored
Problem: Your.safehouse file exists but grants aren’t applied.
Solution: Enable config loading with --trust-workdir-config:
Invalid config line error
Problem: Error message:Invalid config line in .safehouse:5: expected key=value
Solution: Check line 5 of your config file. Ensure every non-comment, non-empty line has the format key=value.
Paths not expanded
Problem: Grants show literal$HOME instead of /Users/username.
Solution: This is normal. Safehouse expands $HOME and ~ internally. Use --explain to see resolved paths:
Related Resources
- Basic Usage - Common workflows with and without config files
- CLI Options - Full
--trust-workdir-configdocumentation - Shell Functions - Machine-local overrides using wrapper functions