Introduction
Moonrepo (moon) is a monorepo management tool written in Rust that handles task running, dependency graph resolution, and project organization for repositories containing multiple projects. It is designed to be fast, language-agnostic, and to reduce the configuration overhead common in large monorepos.
What Moonrepo Does
- Orchestrates task execution across multiple projects with automatic dependency ordering
- Detects affected projects from Git changes and only runs necessary tasks
- Manages toolchain versions for Node.js, Bun, Deno, and Rust automatically
- Generates project configuration from templates using a code generation system
- Enforces project boundaries and dependency constraints through ownership rules
Architecture Overview
Moon reads a .moon/workspace.yml configuration that defines the workspace structure and toolchain settings. Each project contains a moon.yml declaring its tasks and dependencies. When a task is run, moon builds a directed acyclic graph of all task and project dependencies, hashes inputs for cache keys, and executes tasks in parallel where possible. Outputs are cached locally and can be shared via a remote cache for CI acceleration.
Self-Hosting & Configuration
- Install the
moonbinary via the install script, npm, or Homebrew - Run
moon initto create.moon/workspace.ymland configure project sources - Define tasks in each project's
moon.ymlwith commands, inputs, outputs, and dependencies - Set up toolchain auto-management in
.moon/toolchain.ymlto pin Node.js or Rust versions - Enable remote caching by configuring a moonbase or S3-compatible storage endpoint
Key Features
- Rust-based CLI with sub-second startup and parallel task execution
- Smart affected detection using Git diff to skip unchanged projects in CI
- Integrated toolchain management that downloads and pins language runtime versions
- Code ownership system with CODEOWNERS-like rules for enforcing project boundaries
- VCS hooks management for running linters and formatters on pre-commit
Comparison with Similar Tools
- Turborepo — JavaScript/TypeScript focused; Moon is language-agnostic and manages toolchains
- Nx — Plugin-rich with deep framework integration; Moon is simpler and configuration-driven
- Bazel — Hermetic builds for massive repos; Moon is easier to adopt with less configuration
- Lerna — npm package publishing tool; Moon handles task orchestration and project constraints
- Rush — Microsoft monorepo manager for npm; Moon supports multiple language runtimes
FAQ
Q: What languages does Moon support? A: Moon is language-agnostic for task running. Toolchain management currently covers Node.js, Bun, Deno, and Rust with more planned.
Q: How does caching work? A: Moon hashes task inputs (source files, env vars, dependencies) to create cache keys. Matching hashes skip execution and restore cached outputs.
Q: Can I migrate from Turborepo or Nx? A: Yes. Moon provides migration guides. The task configuration format is different but conceptually similar, and moon can coexist during migration.
Q: Does it work with Docker? A: Yes. Moon can run inside Docker containers and supports generating Dockerfiles that leverage the dependency graph for optimal layer caching.