Run one repository
A system sometimes has only one repository, or you want to run only the code that you changed. In this case, you can use no template. You put a .localspace.yaml file in the repository. This is the worktree mode of localspace.
In worktree mode, lo up runs the checkout that you are in, as it is. The workspace has the name of the branch. Coding agents use this mode: an agent works in a git worktree and runs lo up there.
Write the file
Section titled “Write the file”Put .localspace.yaml at the root of the repository. The file has the same fields as a template, with two differences. It has no repos field, and a service has no repo field. Each service runs from the checkout that holds the file.
services: api: port: 8080 env: DATABASE_URL: ${db.url}
resources: db: kind: postgresCommit the file, so that each worktree of the repository has it. If the file has a repos field or a repo field, lo up shows an error.
Start a workspace
Section titled “Start a workspace”-
Go to a git worktree of the repository. To make a worktree for a new branch, run these commands:
Terminal window git worktree add ../api-feature-x -b feature/xcd ../api-feature-x -
Run
lo upwith no workspace name:Terminal window lo uplo upreads.localspace.yaml, records the workspace and starts it. The workspace has the name of the branch, with each/changed to-. The branchfeature/xgives the workspacefeature-x. -
List the workspaces:
Terminal window lo lsThe line of
feature-xshows the name of the repository in the template column.
To stop the workspace, run lo down in the same worktree. To start it again, run lo up. The commands find the workspace from the branch of the checkout.
Which items localspace changes
Section titled “Which items localspace changes”- The worktree is the source of each service. localspace does not make a worktree and does not move your files.
- The worktree is not a worktree that localspace made.
lo rm feature-xremoves the workspace, its resources and its data. It does not remove your worktree. - You can run
lo upin a subdirectory of the worktree. localspace finds the root of the checkout. - Ports, databases, environment variables and public URLs are separate for each workspace, as in a workspace from a template.
Errors
Section titled “Errors”| Situation | Result |
|---|---|
The checkout has no .localspace.yaml file, or it is not in a git repository |
lo up tells you to name a workspace or to run it in a worktree of a repository with .localspace.yaml. |
| The checkout is on a detached HEAD | lo up refuses. Check out a branch, because its name is the name of the workspace. |
| A workspace with the same name is for a different checkout | lo up refuses with a conflict error. Rename the branch or remove the other workspace. |
| The branch name has characters that a workspace name cannot have | lo up refuses with an invalid error. A name has letters, digits, ., _ and -, and it starts with a letter or a digit. |
Use worktree mode from an agent
Section titled “Use worktree mode from an agent”The MCP tool up of lo mcp has a dir argument for the same purpose. Give it a directory in the worktree of the repository, and it makes and starts the workspace of the branch. See the guide for coding agents.