What is safeagent?
safeagent creates a lightweight Linux virtual machine for each Git worktree, giving parallel coding sessions separate processes, ports, databases and service data. It is designed to work automatically with Claude Code worktrees; people using other coding agents can create workspaces with its command line. The project is in early development and currently supports Macs with Apple Silicon, with Linux host support in development.
safeagent Features:
Worktree VMs: Each workspace gets its own Linux VM, with separate processes, ports, Postgres, Valkey and Temporal services, and service data.
Claude Code Hooks: Hooks connect worktree creation, removal and session startup to safeagent, preparing a workspace in the background for enabled folders.
Project Detection: safeagent reads lockfiles, compose files, monorepo packages and local addresses in environment files to detect dependencies and services.
Command Routing: Runtime commands such as node, npm, Python and Go run in the VM, while Git and other commands run on the host.
App Forwarding: safeagent can start project apps inside the VM, restart them after crashes and forward their ports to the host.
Workspace Configuration: A safeagent.yaml file can specify services, runtimes, extra packages, setup commands, apps and ports for a project.
safeagent Benefits:
Fewer Session Collisions: Separate ports, processes and service data let multiple worktree sessions run without competing over the same development environment.
Protected Host: Code running in the VM can reach the internet but not local network services on the host.
Less Setup Work: Automatic project detection and dependency installation reduce the manual preparation needed to get a workspace ready.
Keep Git Familiar: Because Git runs on the host and the checkout is shared live with the VM, branches and files remain part of the usual worktree.
Cleaner Teardown: Removing a worktree also removes its VM and data, while uncommitted work and branches with commits are preserved.
Use Cases:
Parallel Coding: Run separate Claude Code worktrees on different tasks without their databases, ports or running processes interfering.
Migration Testing: Test a branch that adds a database migration in its own workspace without changing another session’s database.
Application Preview: Start one project app or a set of apps in the VM and access them through forwarded ports on the host.
Agent Command Runs: Run tests or other runtime commands from a coding agent inside the workspace’s Linux environment.
Manual Workspaces: Create and manage isolated workspaces from the command line when using a coding tool other than Claude Code.

