Skip to content

Introduction

localspace runs isolated copies of a system that has many repositories, side by side on one machine. The command is lo.

localspace is a command-line tool, lo, with a web dashboard. You tell localspace one time how your system runs: the repositories, the programs and the databases. Then localspace starts separate copies of the system on your machine. Each copy has its branches, ports, databases, environment variables and URLs. The copies share no data unless you share a service, and one copy does not stop a different copy.

localspace is not a deployment tool, and it is not a cluster manager such as Kubernetes. It runs on your machine, for development, review and tests. It does not replace the build tools or the dev servers of your repositories. It starts them with the correct branch, ports and env.

A system has a frontend, some APIs and their databases. Each part is in a separate repository. You can run the system one time with no trouble. It is hard to run the system two times at the same time.

  • The ports collide.
  • The copies share one database.
  • Each repository must be on the correct branch.
  • Each copy must have separate environment variables and URLs.

A reviewer, a coding agent and you can all want a copy of the system at the same time. The reviewer checks a branch. The agent tests a change. You work on a feature. Without localspace, they wait for each other or they break the data of each other.

A Compose file is usually in one repository, and it is for one copy of one stack. A system with many repositories has a different structure in each project. Some projects use the same microservices. To run a second copy with Compose, you must change the project name and the port mappings manually. Compose does not select a branch for each repository, and it does not make git worktrees.

A template tells how the full system runs, across all its repositories, in one location. localspace then runs separate copies of it. localspace also uses Docker: a service with a Dockerfile runs as a container, and the resources run on Docker.

localspace gives the system one description, as a template. A template is a directory with a localspace.yaml file. The file lists these items:

  • The repositories of the system.
  • The services, which are the programs that run from the repositories.
  • The resources, which are the databases and other stores that the services use.

You make any number of workspaces from one template. A workspace is a named copy of the system. For each workspace, you select the branch of each service. localspace gives the workspace these separate items:

  • A git worktree for each branch, so that the branches do not collide.
  • Host ports that no other workspace uses.
  • A database or other resource for each resource of the template.
  • Environment variables that point to the services and resources of the same workspace.
  • Public URLs, for example https://storefront.shop-a.lo.
Templatelocalspace.yamlWorkspace shop-aall services on mainWorkspace shop-bstorefront onfeature/new-checkoutWorktreesPorts and URLsDatabasesWorktreesPorts and URLsDatabases

A workspace is a record until you start it. lo new records the workspace and lo up makes the worktrees, ports, databases and env, and starts the services. lo down stops the workspace and keeps its data. lo rm removes the workspace.

The examples use the template shop from the first workspace tutorial. It has a storefront service, an orders service and an orders-db database.

You work on a feature in the workspace shop-a. An urgent bug comes in. Start a second workspace on main for the bug. The feature workspace continues to run, and its data does not change.

Terminal window
lo new hotfix --template shop
lo up hotfix

A colleague sends you the branch feature/new-checkout for review. Start a workspace for the branch and test it in the browser. Remove the workspace after the review.

Terminal window
lo new review --template shop storefront=feature/new-checkout
lo up review
lo open review storefront
lo rm review

Three coding agents work on three tickets in parallel. Each agent starts a workspace through MCP, reads its logs and runs its tests. The tests of each workspace use the database of that workspace, so they do not change your data. localspace does not limit an agent to one workspace. Tell each agent the name of its workspace. See the guide for coding agents.

Terminal window
claude mcp add --scope user localspace -- lo mcp

A branch makes a page slow, or it changes an API response. Run one workspace on main and one workspace on the branch. Open their URLs next to each other, or send the same request to the two.

Terminal window
lo new before --template shop
lo new after --template shop orders=feature/refund
lo up before
lo up after
lo ls

A branch adds a migration. In the tutorial template, the orders service runs its migrations before each start. Thus lo up runs the migration in the workspace of the branch. If the migration breaks the data, reset only that database from its seed. The databases of the other workspaces do not change.

Terminal window
lo up after
lo db reset after orders-db

An OAuth provider accepts only http://localhost:3000 as its callback address. Give the ports of the template, such as 3000 and 5432, to one workspace. The other workspaces continue to run on their ports. See Fixed ports.

Terminal window
lo checkout shop-a
  1. Install localspace on your machine.
  2. Run your first workspace from a template.
  3. Run one repository without a template.
  4. Read how localspace works for the reason behind the model.