Skip to main content
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
string | string[]
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
inheritedBy
InheritedByConfig
Conditions that determine which projects inherit this configuration.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

tasks
object
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:
taskOptions
TaskOptionsConfig
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

fileGroups
object
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

implicitDeps
string[]
Task dependencies automatically inserted into all inherited tasks.
implicitDeps:
  - '^:build'
Useful for ensuring dependencies are built before dependent tasks run.
implicitInputs
string[]
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
cacheKey
string
Custom key for cache invalidation.Added in v1.35.0
cacheLifetime
string
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'
runFromWorkspaceRoot
boolean
default:false
Run task from workspace root instead of project root.
persistent
boolean
default:false
Marks task as long-running (e.g., servers).Added in v1.6.0
interactive
boolean
default:false
Marks task as interactive (needs stdin).Added in v1.12.0
internal
boolean
default:false
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.
retryCount
number
default:0
Number of retry attempts on failure.
timeout
number
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
allowFailure
boolean
default:false
Allows task to fail without failing the pipeline.Added in v1.13.0
affectedFiles
boolean | 'args' | 'env'
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
mutex
string
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
shell
boolean
Whether to run command in a shell.
unixShell
string
Shell to use on Unix (bash, fish, zsh, etc).Added in v1.21.0
windowsShell
string
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'
inferInputs
boolean
default:false
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

.moon/tasks/node.yml
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'

Build docs developers (and LLMs) love