Skip to content

Safety rules

localspace runs commands that stop processes, delete containers and remove git worktrees. This page gives the rules that limit these commands to the things that localspace made. The rules apply to the CLI, to the dashboard and to the MCP server, because all of them call the same core.

localspace removes a worktree only if it made the worktree. This worktree is an owned worktree. lo up makes owned worktrees in the localspace home, in worktrees/<workspace>/<repository>.

localspace records for each source if it made the worktree. It does not remove these sources:

  • A worktree that you made, and that a service uses by its branch or its path.
  • The checkout where you ran lo up in worktree mode.
  • A directory that you gave to lo new as a path.

lo rm and lo set leave these directories as they are. If the directory is gone, the workspace gets the status broken. Then lo set or lo rm repairs it, and nothing is deleted.

An owned worktree holds unsaved work if it contains one of these items:

  • Uncommitted changes, or files that git does not track.
  • Commits that are on no remote.

These commands refuse to remove an owned worktree with unsaved work:

Command Worktrees that it removes
lo rm The owned worktrees of the workspace
lo set The owned worktree that a new ref replaces
lo shared rm The owned worktrees of a shared instance

The command removes nothing when it refuses. It gives the error code conflict and shows each path with its unsaved work. Commit and push the work, then run the command again.

lo up also protects unsaved work. A source that uses the default ref is a snapshot of origin. lo up moves the snapshot to a new commit only if the snapshot has no unsaved work.

The flag --force removes owned worktrees with unsaved work. lo rm, lo set and lo shared rm accept it.

An engine stops or removes a unit only if the unit is the one that localspace started. The engine does not trust the name of the unit. It looks for a marker that it set at the start.

Engine Marker
Docker The labels localspace.owner and localspace.unit on the container
Native The process ID and the start time of the process. A process ID that the system reuses has a different start time, so localspace does not send a signal to it.
pm2 plugin The name ls-<owner>-<unit> and the variable LOCALSPACE_OWNER of the app

If the marker is not correct, the engine returns the error conflict and leaves the container or the process alone. If the unit is gone, a stop does nothing.

Networks and volumes have the owner label too. localspace removes only the networks and the volumes that carry the label of the workspace. A volume with the correct name and no label is not removed.

Resources use the same method. A database, a bucket or a similar item carries a marker with the owner and the name. The provider drops the item only if the marker is correct.

All the names that localspace gives to Docker objects start with ls-. The prefix has two effects:

  • You can see in a list of containers, networks and volumes which ones localspace made.
  • docker compose commands for a project of yours with the same name do not touch them.

A container is ls-<id>-<unit>, where <id> is the ID of the workspace. A network is ls-<id>. The group of the workspace in OrbStack and in Docker Desktop is the same ls- name. A pm2 app is ls-<id>-<unit> too.

lo down stops the units and removes nothing. It keeps these items:

  • The worktrees, with all their files.
  • The volumes and the databases of the resources.
  • The host ports of the workspace.
  • The records of the workspace.

Only lo rm deletes the data of a workspace. It drops the resources of the workspace, and it removes the owned worktrees. lo db reset also deletes the data of one resource, and it makes the resource again from its seed.