Introduction
localspace runs isolated copies of a system that has many repositories, side by side on one machine. The command is lo.
Overview
Section titled “Overview”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.
The problem
Section titled “The problem”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.
The difference from Docker Compose
Section titled “The difference from Docker Compose”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.
The model
Section titled “The model”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.
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.
Scenarios
Section titled “Scenarios”The examples use the template shop from the first workspace tutorial. It has a storefront service, an orders service and an orders-db database.
Work on two tickets at the same time
Section titled “Work on two tickets at the same time”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.
lo new hotfix --template shoplo up hotfixReview a pull request and keep your work
Section titled “Review a pull request and keep your work”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.
lo new review --template shop storefront=feature/new-checkoutlo up reviewlo open review storefrontlo rm reviewGive each coding agent a separate copy
Section titled “Give each coding agent a separate copy”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.
claude mcp add --scope user localspace -- lo mcpCompare main and a branch side by side
Section titled “Compare main and a branch side by side”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.
lo new before --template shoplo new after --template shop orders=feature/refundlo up beforelo up afterlo lsTest a database migration
Section titled “Test a database migration”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.
lo up afterlo db reset after orders-dbRun an application with fixed ports
Section titled “Run an application with fixed ports”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.
lo checkout shop-aNext steps
Section titled “Next steps”- Install localspace on your machine.
- Run your first workspace from a template.
- Run one repository without a template.
- Read how localspace works for the reason behind the model.