Overview
By default, hcom uses~/.hcom for all state (database, logs, config). Sandbox mode isolates state to a project-local directory using the HCOM_DIR environment variable.
Use cases:
- Multiple projects with separate agent groups
- Temporary sandboxes for testing
- Environments without
$HOMEwrite access - Per-project relay groups
Setting HCOM_DIR
Per-Command
Persistent (Recommended)
Add to your shell config (~/.bashrc, ~/.zshrc):
Directory Structure
Global Mode
Project-Local Mode
HCOM_DIR is set to a local path.
Initial Setup
Create Project Sandbox
Verify Isolation
Hook Installation
WhenHCOM_DIR is project-local, hooks install relative to the project:
Global Mode
Project-Local Mode
OpenCode (Special Case)
OpenCode hooks always install to~/.config/opencode/settings.json (global only).
For project-local OpenCode, set both:
Configuration
EachHCOM_DIR has its own config.toml:
Shared Settings
Environment variables override config files:Usage Patterns
Pattern 1: Per-Project Agents
Each project gets its own agent group:Pattern 2: Temporary Sandbox
Quick test without polluting global state:Pattern 3: Team Collaboration
Share project directory withHCOM_DIR in git:
Switching Contexts
Manual Switch
Auto-Detect Function
cd automatically switches HCOM_DIR:
Relay with Sandboxes
EachHCOM_DIR can have a separate relay group:
Cleanup
Remove Project Sandbox
Archive Before Cleanup
Restricted Environments
No $HOME Write Access
If~/.hcom is read-only:
Docker/Container
In containers, setHCOM_DIR to a mounted volume:
./hcom-state on host.
Path Expansion
HCOM_DIR supports:
- Absolute paths:
/home/user/project/.hcom - Relative paths:
.hcom(resolved to$PWD/.hcom) - Tilde expansion:
~/.hcom(expands to$HOME/.hcom)
Environment Variable Summary
Troubleshooting
Agents Not Appearing
Check active HCOM_DIR:Hooks Not Working
Check hook installation location:Permission Denied
Check directory permissions:State Leaking Between Projects
Verify separate databases:Best Practices
- Use project-local for multi-project work - Avoid agent name collisions
- Add .hcom to .gitignore - But commit
config.tomlfor team consistency - Auto-detect with shell function - Less manual context switching
- Document HCOM_DIR setup - In project README for team members
- Use separate relay groups - If syncing project sandboxes across devices
- Clean up temp sandboxes - Use
/tmpfor experiments - Backup archives - Before deleting
.hcomdirectories - Test in sandbox first - Before running in global mode