---
title: .moon/tasks
---

import HeadingApiLink from '@site/src/components/Docs/HeadingApiLink';
import VersionLabel from '@site/src/components/Docs/VersionLabel';

The `.moon/tasks/**/*` files configures file groups and tasks that are inherited by _every matching_
project in the workspace based on inheritance conditions.
[Learn more about task inheritance!](../concepts/task-inheritance)

Projects can override or merge with these settings within their respective [`moon.*`](./project).

## `extends`

<HeadingApiLink to="/api/types/interface/InheritedTasksConfig#extends" />

Defines one or many external `.moon/tasks/**/*`'s to extend and inherit settings from. Perfect for
reusability and sharing configuration across repositories and projects. When defined, this setting
must be an HTTPS URL _or_ relative file system path that points to a valid YAML document!

```yaml title=".moon/tasks/all.yml" {1}
extends: 'https://raw.githubusercontent.com/organization/repository/master/.moon/tasks/all.yml'
```

:::caution

For map-based settings, `fileGroups` and `tasks`, entries from both the extended configuration and
local configuration are merged into a new map, with the values of the local taking precedence. Map
values _are not_ deep merged!

:::

## `fileGroups`

<HeadingApiLink to="/api/types/interface/InheritedTasksConfig#fileGroups" />

> For more information on file group configuration, refer to the
> [`fileGroups`](./project#filegroups) section in the [`moon.*`](./project) doc.

Defines [file groups](../concepts/file-group) that will be inherited by projects, and also enables
enforcement of organizational patterns and file locations. For example, encourage projects to place
source files in a `src` folder, and all test files in `tests`.

```yaml title=".moon/tasks/all.yml"
fileGroups:
  configs:
    - '*.config.{js,cjs,mjs}'
    - '*.json'
  sources:
    - 'src/**/*'
    - 'types/**/*'
  tests:
    - 'tests/**/*'
    - '**/__tests__/**/*'
  assets:
    - 'assets/**/*'
    - 'images/**/*'
    - 'static/**/*'
    - '**/*.{scss,css}'
```

:::info

File paths and globs used within a file group are relative from the inherited project's root, and
not the workspace root.

:::

## `implicitDeps`

<HeadingApiLink to="/api/types/interface/InheritedTasksConfig#implicitDeps" />

Defines task [`deps`](./project#deps) that are implicitly inserted into _all_ inherited tasks within
a project. This is extremely useful for pre-building projects that are used extensively throughout
the repo, or always building project dependencies. Defaults to an empty list.

```yaml title=".moon/tasks/all.yml" {1-2}
implicitDeps:
  - '^:build'
```

:::info

Implicit dependencies are _always_ inherited, regardless of the [`mergeDeps`](./project#mergedeps)
option.

:::

## `implicitInputs`

<HeadingApiLink to="/api/types/interface/InheritedTasksConfig#implicitInputs" />

Defines task [`inputs`](./project#inputs) that are implicitly inserted into _all_ inherited tasks
within a project. This is extremely useful for the "changes to these files should always trigger a
task" scenario.

Like `inputs`, file paths/globs defined here are relative from the inheriting project.
[Project and workspace relative file patterns](../concepts/file-pattern#project-relative) are
supported and encouraged.

```yaml title=".moon/tasks/node.yml" {1-2}
implicitInputs:
  - 'package.json'
```

:::info

Implicit inputs are _always_ inherited, regardless of the [`mergeInputs`](./project#mergeinputs)
option.

:::

## `inheritedBy`<VersionLabel version="2.0.0" />

<HeadingApiLink to="/api/types/interface/InheritedTasksConfig#inheritedBy" />

A map of conditions that must be met for the configuration within the file to be inherited by a
project. When this field is not defined, or is an empty map, the configuration will be inherited by
all projects.

```yaml title=".moon/tasks/custom.yml"
inheritedBy:
  # Project belongs to either javascript or typescript toolchain, but not the ruby toolchain
  toolchains:
    or: ['javascript', 'typescript']
    not: ['ruby']
  # And project is either a frontend or backend stack
  stacks: ['frontend', 'backend']
  # And project is either a library or tool layer
  layers: ['library', 'tool']
```

:::info

View the [official task inheritance guide](../concepts/task-inheritance) for more information!

:::

## `tasks`

<HeadingApiLink to="/api/types/interface/InheritedTasksConfig#tasks" />

> For more information on task configuration, refer to the [`tasks`](./project#tasks) section in the
> [`moon.*`](./project) doc.

As mentioned in the link above, [tasks](../concepts/task) are actions that are ran within the
context of a project, and commonly wrap a command. For most workspaces, every project _should_ have
linting, typechecking, testing, code formatting, so on and so forth. To reduce the amount of
boilerplate that _every_ project would require, this setting offers the ability to define tasks that
are inherited by many projects within the workspace, but can also be overridden per project.

```yaml title=".moon/tasks/all.yml"
tasks:
  format:
    command: 'prettier --check .'

  lint:
    command: 'eslint --no-error-on-unmatched-pattern .'

  test:
    command: 'jest --passWithNoTests'

  typecheck:
    command: 'tsc --build'
```

:::info

Relative file paths and globs used within a task are relative from the inherited project's root, and
not the workspace root, or the location of the `.moon/tasks/*` file.

:::

## `taskOptions`<VersionLabel version="1.20.0" />

<HeadingApiLink to="/api/types/interface/InheritedTasksConfig#taskOptions" />

> For more information on task options, refer to the [`options`](./project#options) section in the
> [`moon.*`](./project) doc.

Like [tasks](#tasks), this setting allows you to define task options that will be inherited by _all
tasks_ within the configured file, and by all project-level inherited tasks. This setting is the 1st
link in the inheritance chain, and can be overridden within each task.

:::info

As of v2.4, task options can also be defined per project with the
[`taskOptions`](./project#taskoptions) setting in [`moon.*`](./project), which sits later in the
inheritance chain and takes precedence over these workspace-level defaults.

:::

```yaml title=".moon/tasks/all.yml"
taskOptions:
  # Never cache builds
  cache: false
  # Always re-run flaky tests
  retryCount: 2

tasks:
  build:
    # ...
    options:
      # Override the default cache setting
      cache: true
```
