Skip to content

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.

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.

.localspace.yaml
services:
api:
port: 8080
env:
DATABASE_URL: ${db.url}
resources:
db:
kind: postgres

Commit 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.

  1. 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/x
    cd ../api-feature-x
  2. Run lo up with no workspace name:

    Terminal window
    lo up

    lo up reads .localspace.yaml, records the workspace and starts it. The workspace has the name of the branch, with each / changed to -. The branch feature/x gives the workspace feature-x.

  3. List the workspaces:

    Terminal window
    lo ls

    The line of feature-x shows 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.

  • 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-x removes the workspace, its resources and its data. It does not remove your worktree.
  • You can run lo up in 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.
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.

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.

  • Read the guide to templates for all the fields of the file.
  • Read the glossary for the difference between worktree mode and template mode.