Lesson 0003 · ~12 minutes

Everyday loop: install → init → map → run

One skill: walk the path from a moon binary to moon run app:lint — install, moon init, project discovery, then targets — without memorizing every config knob.

Win for this lesson

You can narrate the first-day sequence on a real repo: install moon, init the workspace, make projects visible, run a target — and know why “folder exists” ≠ “moon knows the project.”

1. Install the binary

moon ships as a single binary (install guide). Common paths:

Upgrade later via proto install moon --pin or moon upgrade (for ~/.moon/bin installs).

2. Init the workspace

After install: setup workspace + moon init.

$ moon init
# prototype: moon init --minimal

The workspace owns VCS integration, tree-wide config, the project graph, and running the action graph. moon needs a VCS (default git) for hashing and affected runs — set vcs.defaultBranch if yours is main not master.

3. Map projects (discovery)

Load-bearing fact

A folder can sit in the repo and still be invisible to moon until it appears under projects in .moon/workspace.* ((create a project).

Three patterns (all official):

Check a project: moon project client. Wrong path → error. Config tasks with shared .moon/tasks/** and/or per-project moon.* (lesson 2 inheritance still applies).

4. Run targets

Everyday command: moon run (alias moon r). Run a task spells the pipeline:

  1. Build action graph (DAG).
  2. Insert task deps, then the primary target.
  3. Run topo-sorted, parallel where possible.
  4. Hash each task → cache hit short-circuits, miss runs + caches.
$ moon run app:build
$ moon run client:dev server:dev
$ moon run :test              # all projects
$ moon run '~:test'           # closest project (cwd)
$ moon run app:build --affected
$ moon run app:build -- --force   # args after -- go to the tool

Default is fail-fast (one failure aborts the graph). --affected only runs when VCS-touched files intersect the task’s inputs — the anti-“full CI every push” lever from lesson 1.

5. Trace it once (mental dry-run)

Binary

proto / ~/.moon/bin / @moonrepo/cli

Workspace

moon init.moon/workspace.*

Projects

projects: map or globs → graph nodes

Run

moon run scope:task → action graph + cache

6. Practice

Equal-length options. Retrieve the loop, not the whole manual.

Question 1

You installed moon globally. What creates the workspace root?

Question 2

apps/web exists with source, but moon project web fails. Likeliest cause?

Question 3

How do you run the lint task in project app?

Question 4

Why pass --affected to moon run?

7. Primary source

Recommended path (in order): InstallSetup workspaceCreate a projectRun a task.

Keep the loop sheet open when you try this on a real repo (optional hands-on; quiz first is fine).

Ask your teacher Map trio-moon (or any moon repo) onto this loop, or debug “project not found” / wrong default branch. Chat is part of the course.