The .moon/tasks/**/* configuration files define tasks and file groups that are inherited by projects based on conditions. This enables centralized task management and reduces duplication.
Configuration Files
Location: .moon/tasks/*.yml or .moon/tasks/*.json
Type: InheritedTasksConfig
Common files:
.moon/tasks/node.yml - Node.js/JavaScript projects
.moon/tasks/rust.yml - Rust projects
.moon/tasks/python.yml - Python projects
.moon/tasks/all.yml - All projects
Schema
Core Settings
Extends one or many task configuration files. Supports relative paths or HTTPS URLs. extends : 'https://example.com/.moon/tasks/base.yml'
Added in v1.12.0
Conditions that determine which projects inherit this configuration. Inheritance order. Lower values are inherited first. If not defined, order is calculated based on conditions:
Base: 0
Toolchains/Languages: +50
Stacks: +100
Layers: +150
Tags: +500
Matches against project toolchains. # Single value
inheritedBy :
toolchains : 'node'
# Multiple values (OR)
inheritedBy :
toolchains : [ 'node' , 'bun' ]
# Logical operators
inheritedBy :
toolchains :
or : [ 'node' , 'bun' ]
not : [ 'rust' ]
Matches against project language setting.
Matches against project stack setting. inheritedBy :
stacks : [ 'frontend' , 'backend' ]
Matches against project layer setting. inheritedBy :
layers : [ 'library' , 'tool' ]
Matches against project tags. inheritedBy :
tags :
or : [ 'react' , 'vue' ]
not : [ 'deprecated' ]
Matches if at least one file exists in the project. inheritedBy :
files :
- 'package.json'
- 'tsconfig.json'
If not defined or empty, configuration is inherited by all projects. inheritedBy :
toolchains : 'node'
stacks : [ 'frontend' , 'backend' ]
layers : [ 'application' , 'library' ]
Added in v2.0.0
Tasks
Map of task identifiers to task configurations. tasks :
format :
command : 'prettier --check .'
inputs :
- 'src/**/*'
lint :
command : 'eslint .'
options :
cache : true
test :
command : 'jest --passWithNoTests'
Each task supports the following fields: Command to execute. Use for single commands with arguments. tasks :
lint :
command : 'eslint --fix .'
# Or array format
command :
- 'eslint'
- '--fix'
- '.'
Script to execute. Supports pipes, redirects, and multiple commands. tasks :
cleanup :
script : 'rm -rf dist && mkdir dist'
Added in v1.27.0 Additional arguments to append to the command. tasks :
test :
command : 'jest'
args : '--coverage --verbose'
Human-readable description of the task. Added in v1.22.0
Extends settings from another task. tasks :
lint :
command : 'eslint .'
lint-fix :
extends : 'lint'
args : '--fix'
Added in v1.12.0 Task dependencies (targets) to run before this task. tasks :
build :
command : 'vite build'
deps :
- 'design-system:build'
- '~:generate'
Supports args and env overrides: deps :
- target : 'api:build'
args : [ '--production' ]
env :
NODE_ENV : 'production'
Files, globs, and environment variables that affect the task. tasks :
build :
inputs :
# Files and globs
- 'src/**/*'
- 'package.json'
# Workspace-relative
- '/tsconfig.json'
# Environment variables
- '$NODE_ENV'
# File groups
- '@group(sources)'
# External projects
- 'project://design-system?group=sources'
Advanced file input options: inputs :
- file : 'config.json'
optional : true
- file : 'src/constants.ts'
content : 'API_KEY|SECRET'
Files and folders created by the task. tasks :
build :
outputs :
- 'dist'
- 'build/**/*.js'
Advanced output options: outputs :
- file : 'dist/optional.js'
optional : true
Environment variables for the task. tasks :
build :
env :
NODE_ENV : 'production'
API_URL : '${BASE_URL}/api'
Toolchains the command runs on. tasks :
build :
command : 'npm run build'
toolchains : [ 'javascript' , 'node' , 'npm' ]
Added in v1.31.0 Applies a preset configuration.
server: Long-running processes (cache off, streaming output, persistent, no CI)
utility: Interactive utilities (cache off, interactive, streaming output)
tasks :
dev :
command : 'vite'
preset : 'server'
Added in v1.28.0
Default options inherited by all tasks in this configuration. taskOptions :
cache : true
retryCount : 2
runInCI : true
tasks :
build :
# Inherits taskOptions
command : 'vite build'
options :
# Override specific options
cache : false
Added in v1.20.0
File Groups
Maps file group IDs to lists of globs, paths, or environment variables. fileGroups :
sources :
- 'src/**/*'
- 'types/**/*'
configs :
- '*.config.{js,ts}'
- 'tsconfig.json'
tests :
- 'tests/**/*'
- '**/__tests__/**/*'
File groups are relative to each project that inherits them.
Implicit Settings
Task dependencies automatically inserted into all inherited tasks. implicitDeps :
- '^:build'
Useful for ensuring dependencies are built before dependent tasks run.
Inputs automatically inserted into all inherited tasks. implicitInputs :
- 'package.json'
- '/tsconfig.json'
Ensures common configuration changes trigger task reruns.
Task Options
Task options control execution behavior and can be defined in options or taskOptions.
cache
boolean | 'local' | 'remote'
default: true
Controls caching of task results. options :
cache : false # Disable caching
cache : 'local' # Only local cache
cache : 'remote' # Only remote cache
Custom key for cache invalidation. Added in v1.35.0
How long cached results are valid (e.g., “1 day”, “2 hours”). Added in v1.29.0
runInCI
boolean | 'always' | 'skip' | 'only'
default: true
Controls execution in CI environments.
true/affected: Run if affected
false: Never run
always: Always run
skip: Skip but allow dependencies
only: Only in CI
options :
runInCI : 'always'
Run task from workspace root instead of project root.
Marks task as long-running (e.g., servers). Added in v1.6.0
Marks task as interactive (needs stdin). Added in v1.12.0
Marks task as internal-only (can’t be run directly). Added in v1.23.0
outputStyle
'buffer' | 'buffer-only-failure' | 'hash' | 'none' | 'stream'
Controls stdout/stderr display.
Number of retry attempts on failure.
Maximum execution time in seconds. Added in v1.26.0
priority
'critical' | 'high' | 'normal' | 'low'
default: "normal"
Task priority in the pipeline queue. Added in v1.35.0
Allows task to fail without failing the pipeline. Added in v1.13.0
Passes affected files as arguments or environment variable. options :
affectedFiles : true # Both args and env
affectedFiles : 'args' # Only args
affectedFiles : 'env' # Only MOON_AFFECTED_FILES
Creates exclusive lock on a virtual resource. Added in v1.24.0
os
'linux' | 'macos' | 'windows' | array
Restricts task to specific operating systems. Added in v1.28.0
Whether to run command in a shell.
Shell to use on Unix (bash, fish, zsh, etc). Added in v1.21.0
Shell to use on Windows (pwsh, bash, etc). Added in v1.21.0
envFile
boolean | string | string[]
Load environment variables from .env files. options :
envFile : true # Auto-load .env files
envFile : '.env.production'
envFile :
- '.env'
- '.env.local'
Automatically infer inputs from commands. Added in v1.31.0
Merge Strategies
Control how settings merge when tasks are inherited:
merge
'append' | 'prepend' | 'replace'
Default merge strategy for all mergeable fields. Added in v1.29.0
mergeArgs
'append' | 'prepend' | 'replace'
default: "append"
Merge strategy for args.
mergeDeps
'append' | 'prepend' | 'replace'
default: "append"
Merge strategy for deps.
mergeEnv
'append' | 'prepend' | 'replace'
default: "append"
Merge strategy for env.
mergeInputs
'append' | 'prepend' | 'replace'
default: "append"
Merge strategy for inputs.
mergeOutputs
'append' | 'prepend' | 'replace'
default: "append"
Merge strategy for outputs.
Complete Example
inheritedBy :
toolchains : 'node'
stacks : [ 'frontend' , 'backend' ]
fileGroups :
sources :
- 'src/**/*'
- 'types/**/*'
configs :
- '*.config.{js,ts}'
- 'package.json'
- 'tsconfig.json'
tests :
- 'tests/**/*'
- '**/__tests__/**/*'
- '**/*.test.ts'
implicitInputs :
- 'package.json'
- '/tsconfig.json'
implicitDeps :
- '^:build'
taskOptions :
cache : true
retryCount : 1
tasks :
format :
command : 'prettier --check .'
inputs :
- '@group(sources)'
- '@group(configs)'
lint :
command : 'eslint'
args : '--no-error-on-unmatched-pattern .'
inputs :
- '@group(sources)'
- '@group(configs)'
test :
command : 'jest --passWithNoTests'
inputs :
- '@group(sources)'
- '@group(tests)'
options :
retryCount : 2
typecheck :
command : 'tsc --noEmit'
inputs :
- '@group(sources)'
- 'tsconfig.json'
deps :
- '^:typecheck'