Skip to main content
The moon check [...projects] (or moon c) command will run all build and test tasks for one or many projects. This is a convenience command for verifying the current state of a project, instead of running multiple moon run commands.
# Check project by name
$ moon check app

# Check multiple projects by name
$ moon check client server

# Check closest project from current working directory
$ moon check --closest

# Check ALL projects (may be costly)
$ moon check --all

How it works

The moon check command simplifies project verification by:
  1. Selecting projects - Based on provided IDs, --all flag, or --closest flag
  2. Filtering tasks - Automatically finds all tasks with build or test type
  3. Building action graph - Creates dependency graph with all selected tasks
  4. Running tasks - Executes all build and test tasks in topological order
  5. Failing fast - Stops immediately if any task fails
This is equivalent to manually running all build and test targets:
# Instead of:
$ moon run app:build app:test app:lint-types ...

# Just run:
$ moon check app

Arguments

  • [...id] - List of project IDs or aliases to explicitly check, as defined in projects.
If no arguments are provided and no flags are used, you’ll be prompted to select projects interactively.

Options

Inherits all options from moon exec, and pre-fills with: --on-failure=bail, --upstream=deep.

Project selection

  • --all - Run check for all projects in the workspace. Use with caution in large workspaces.
  • --closest - Run check for the closest project starting from the current working directory.

Common options

  • -f, --force - Force run and bypass cache, ignore changed files, and skip affected checks.
  • -i, --interactive - Run the pipeline and tasks interactively.
  • -s, --summary [LEVEL] - Print a summary of all actions that were ran in the pipeline.

Affected options

  • --affected [BY] - Only check tasks if affected by changed files. Optionally accepts “local” or “remote”.
  • --base <BASE> - Base branch, commit, or revision to compare against.
  • --head <HEAD> - Current branch, commit, or revision to compare with.
  • -g, --include-relations - Include graph relations for affected checks.
  • --status <STATUS> - Filter changed files based on a changed status.
  • --stdin - Accept changed files from stdin for affected checks.

Graph options

  • --downstream <DEPTH> - Control the depth of downstream dependents. Supports none (default), direct, deep.
  • --upstream <DEPTH> - Control the depth of upstream dependencies. Supports none, direct, deep (default).

Parallelism options

  • --job <INDEX> - Index of the current job (0 based).
  • --job-total <TOTAL> - Total amount of jobs to run.

Examples

Check a single project

$ moon check app
Output:
▪▪▪▪ app:build
  └─ /path/to/project/app (2.1s)

▪▪▪▪ app:test
  └─ /path/to/project/app (5.3s)

▪▪▪▪ app:type-check
  └─ /path/to/project/app (1.2s)

✓ Tasks completed in 8.6s

Check multiple projects

$ moon check frontend backend shared

Check closest project

Navigate to a project directory and check it:
$ cd packages/app
$ moon check --closest

Check all projects

$ moon check --all
:::caution Using --all in large workspaces can be very time-consuming. Consider using affected checks instead. :::

Check only affected projects

Check only projects affected by changed files:
$ moon check --all --affected
Or with specific base/head:
$ moon check --all --affected --base main --head feature-branch

Check with summary

$ moon check app --summary
Output:
✓ Tasks completed in 8.6s

Summary:
  3 tasks completed
  1 task cached
  2 tasks executed

Force check without cache

$ moon check app --force

Interactive project selection

Run moon check without arguments to select projects interactively:
$ moon check
Output:
? Which project(s) to check?
  ◯ app - Main application
  ◯ client - Client library
  ◯ server - Server application
  ◯ shared - Shared utilities

Task types checked

The moon check command automatically runs tasks with the following types:
  • Build tasks - Tasks marked with type: "build" in task configuration
  • Test tasks - Tasks marked with type: "test" in task configuration
Common examples:
# In moon.yml or .moon/tasks/*.yml
tasks:
  build:
    command: 'npm run build'
    type: 'build'

  test:
    command: 'npm test'
    type: 'test'

  type-check:
    command: 'tsc --noEmit'
    type: 'build'

  lint:
    command: 'eslint .'
    type: 'test'

Environment variables

The following environment variables can be used as alternatives to command line options:
  • MOON_FORCE - Same as --force
  • MOON_AFFECTED - Same as --affected
  • MOON_BASE - Same as --base
  • MOON_HEAD - Same as --head
  • MOON_INCLUDE_RELATIONS - Same as --include-relations
  • MOON_JOB - Same as --job
  • MOON_JOB_TOTAL - Same as --job-total
  • MOON_SUMMARY - Same as --summary

Configuration

Build docs developers (and LLMs) love