locus

Development Workflow

This guide covers the typical day-to-day workflow you’ll use when building an application with Locus. The process is designed to be fast, iterative, and keep you in a state of flow.

The Core Development Loop

Your primary tool during development is the locus dev command.

  1. Start the Dev Server: Open your terminal, navigate to your project folder, and run:
    locus dev
    

    This single command compiles your entire project, starts the backend API and frontend web server, and then actively watches all your .locus files for changes.

  2. Open Your Editor and Browser: Arrange your windows side-by-side. On one screen, have your code editor open to your .locus files. On the other, have your web browser open to http://localhost:3000.

  3. Write Code and Save: Make changes to your pages, components, or design system in your .locus files. The moment you hit save, locus dev detects the change, incrementally rebuilds only what’s necessary, and automatically refreshes your browser. Changes to your UI and styling appear almost instantly.

This edit -> save -> see changes loop is the heart of the Locus workflow.

Handling Database Changes

When you edit a database block in any .locus file, the workflow is slightly different.

  1. Edit Your Schema: Add or change an entity, field, or relationship.
  2. Save the File: When you save, locus dev will detect the change and print a message in your terminal telling you that your database schema is out of sync with your code. It will give you a locus db migrate command to run.
  3. Run the Migration: Open a second terminal window (leaving locus dev running in the first) and run the suggested command. This will generate and apply a new migration, safely updating your database to match your new schema.

Keeping a second terminal window open for database commands is a common practice during Locus development.

Debugging Your Application

If things aren’t working as expected, you have a few tools at your disposal:

A Few Best Practices