# Configuration

The keys of axle.toml, the file that says what Axle can't find out by itself.

Axle needs no configuration: it reads the workspace files you already have. An `axle.toml` says what it can't find out by itself, such as the environment variables a build reads, which tasks wait for which, or how a dev server shows it has started. [`axle init`](https://axlers.dev/docs/reference/init.md) writes a first one.

```toml
#:schema ./node_modules/@axle-rs/axle/axle.schema.json

globalEnv = ["API_URL"]

[tasks.build]
description = "Compiles each package into dist"
dependsOn = ["^build", "codegen"]
outputs = ["dist/**", "!dist/**/*.map"]

[tasks.e2e]
dependsOn = ["api#dev"]
exclusive = true

[run]
concurrency = 8

[cache]
dir = ".axle/cache"
maxSize = "20GB"
```

Every key is optional. A key Axle doesn't know or a value of the wrong type is an [error](https://axlers.dev/docs/messages/file-has-a-mistake.md) that names the file, the line and the column, so a typo can't silently do nothing. So is a broken [output](https://axlers.dev/docs/messages/invalid-output-pattern.md) or [input](https://axlers.dev/docs/messages/invalid-input-pattern.md) pattern.

## Where settings go

The `axle.toml` at the repository root holds settings for the whole repository, and `[tasks.<script>]` there applies to that script in every package, so it's the place for defaults. A package can have its own `axle.toml` next to its `package.json`, with `[tasks.<script>]` for its own tasks only:

```toml
# packages/web/axle.toml
[tasks.build]
outputs = ["...", ".next/**", "!.next/cache/**"]

[tasks.build.variants.dev]
arguments = ["--mode", "development"]
```

From weakest to strongest, a setting comes from:

1. Axle's defaults.
2. For a task a [plugin](#plugins) adds, the settings the plugin gives it.
3. The [presets](#presets) named in `extends`, in order.
4. The root `axle.toml`.
5. The package's own `axle.toml`.
6. The [variant](#variants) chosen with `--variant`.
7. For `[run]` and `[cache]`, an `AXLE_*` environment variable, then a flag.

A stronger setting replaces a weaker one. That holds for lists too, unless the list contains `"..."`, which stands for the weaker list at that place: `outputs = ["...", ".next/**"]` adds to the root's outputs. Tables, such as `setEnv` and `ready`, merge key by key. [`axle show`](https://axlers.dev/docs/reference/show.md) prints a package's final settings and where each came from.

## Editor support

`@axle-rs/axle` ships `axle.schema.json`. With a `#:schema` line at the top of `axle.toml` pointing to it, editors that read TOML schemas, such as VS Code with Even Better TOML, complete the keys and explain each one as you type.

## Environment variables

| Key                    | Meaning                                                                                            |
| ---------------------- | -------------------------------------------------------------------------------------------------- |
| `globalEnv`            | variables every task reads: they change the hash, and tasks get them in strict mode                |
| `globalPassThroughEnv` | variables every task gets without changing the hash, such as credentials                           |
| `frameworkEnv`         | `false` stops Axle hashing and passing on the variables of the frameworks it finds; default `true` |

These go at the root of `axle.toml`. A task has its own `env` and `passThroughEnv`, for the variables only it reads. Before 0.1, the root keys were called `env` and `passThroughEnv`. Those names are now an [error](https://axlers.dev/docs/messages/migration-needed.md) at the root, and [`axle migrate`](https://axlers.dev/docs/reference/migrate.md) renames them. A name ending in `*` stands for every variable that starts with it, such as `PUBLIC_*`. [Caching](https://axlers.dev/docs/reference/cache.md#environment-variables) explains strict mode and the variables every task gets anyway.

## Tasks

| Key                 | Meaning                                                                                                                                                                                                                                                       |
| ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `description`       | what the task does, in a few words; `axle list --tasks`, `axle show`, the editors, the terminal UI and AI agents show it                                                                                                                                      |
| `command`           | what to run instead of the `package.json` script, through the system's shell: `sh` on macOS and Linux, `cmd` on Windows                                                                                                                                       |
| `arguments`         | arguments added after the command or script, before those given after `--`; `{changedFiles}` and `{testFiles}` stand for files, see [test files](#test-files)                                                                                                 |
| `fallbackArguments` | the arguments used instead of `arguments` when Axle can't name the files for `{changedFiles}` or `{testFiles}`; see [test files](#test-files)                                                                                                                 |
| `dependsOn`         | the tasks this one waits for: `^build` for `build` in every package it depends on, `codegen` for a task of the same package, `api#dev` for one package's task; a task declared here that no package has a script for, such as `^topo`, only orders and hashes |
| `outputs`           | the files the task makes, as [glob patterns](https://axlers.dev/docs/reference/globs.md) relative to the package; `!` leaves files out, and `{root}/` starts at the root                                                                                                          |
| `inputs`            | the files the task reads, which decide its hash and whether it's affected; see [inputs](#inputs)                                                                                                                                                              |
| `testFiles`         | the task's test files, as [glob patterns](https://axlers.dev/docs/reference/globs.md) relative to the package, for `{testFiles}`; `!` leaves files out; see [test files](#test-files)                                                                                             |
| `split`             | `true` spreads the task's test files over the jobs of [`axle run --shard`](https://axlers.dev/docs/reference/run.md#splitting-a-run-across-ci-jobs); needs `{testFiles}` in `arguments`                                                                                           |
| `env`               | more variables this task reads, added to the root `globalEnv`                                                                                                                                                                                                 |
| `passThroughEnv`    | more variables this task gets without changing its hash                                                                                                                                                                                                       |
| `setEnv`            | variables set to a fixed value for this task, such as `{ NODE_ENV = "production" }`; they change its hash                                                                                                                                                     |
| `cache`             | `false` means the task always runs and is never stored; default `true`                                                                                                                                                                                        |
| `persistent`        | `true` for a task that runs until stopped, such as a dev server                                                                                                                                                                                               |
| `with`              | tasks started alongside this persistent task and stopped with it                                                                                                                                                                                              |
| `ready`             | when a persistent task counts as started; see [persistent tasks](#persistent-tasks)                                                                                                                                                                           |
| `restart`           | `true` makes [`axle watch`](https://axlers.dev/docs/reference/watch.md#persistent-tasks) restart this persistent task when a file in its package changes or a task it waits for runs again; default `false`                                                                       |
| `exclusive`         | `true` means the task never runs at the same time as another task                                                                                                                                                                                             |
| `interactive`       | `true` for a task that reads from the terminal: it gets the terminal's input and output, runs alone and is never cached                                                                                                                                       |
| `batch`             | for a task a plugin adds, `true` lets the plugin run it together with other projects' tasks in one process; `false` runs it on its own; see [batch mode](https://axlers.dev/docs/reference/plugins.md#batch-mode)                                                                 |
| `retries`           | how many more times to run the task when it fails, such as `2` for tests that fail now and then; default `0`; see [retries and timeouts](#retries-and-timeouts)                                                                                               |
| `timeout`           | how long the task may run before Axle stops it and fails it, such as `"90s"`, `"10m"` or `"1h"`; see [retries and timeouts](#retries-and-timeouts)                                                                                                            |
| `variants`          | named sets of the other keys; see [variants](#variants)                                                                                                                                                                                                       |

Without `dependsOn`, a task waits for the same script in the packages it depends on, as `^build` would. With it, a task waits for exactly what it lists, and tasks named together, as in `axle run codegen build`, wait for each other when it says so. A `^` entry passes through packages that don't have the script. An entry naming a task no package has is an [error](https://axlers.dev/docs/messages/unknown-dependency.md).

A package's own `axle.toml` can also give it a task that isn't in its `package.json`, with `command`. The command runs in the package's folder, and its arguments are quoted for the shell.

Without `outputs`, Axle finds a task's outputs itself, as [caching](https://axlers.dev/docs/reference/cache.md#outputs) describes. Declare them when a task writes files it shouldn't store, such as source maps, or so that two tasks of the same package can run at the same time.

### Retries and timeouts

```toml
[tasks.e2e]
retries = 2
timeout = "15m"
```

A task with `retries` that fails runs again, up to that many more times, and passes if any try passes. Its output shows each try. A task that passed only on a later try is a [warning](https://axlers.dev/docs/messages/task-passed-on-retry.md), so a flaky test doesn't go unnoticed. Only the try that passed is stored in the cache.

A task that runs longer than its `timeout` is stopped, and killed if it hasn't ended 5 seconds later, and [fails](https://axlers.dev/docs/messages/task-timed-out.md), so a hung test can't keep CI waiting. With `retries`, a try that timed out runs again. Persistent tasks have no time limit, interactive tasks are never retried, and a plugin doesn't [batch](https://axlers.dev/docs/reference/plugins.md#batch-mode) a task that has either key.

### Persistent tasks

Scripts named `dev`, `start`, `serve`, `preview` or `watch` are persistent unless `persistent = false`. A persistent task is never cached, doesn't count towards `--concurrency`, and waits for nothing unless `dependsOn` says so.

A task can wait for a persistent task, such as end-to-end tests that need a server, once the persistent task says when it's ready:

| `ready`                                | The task is ready when                                                 |
| -------------------------------------- | ---------------------------------------------------------------------- |
| `{ port = 3000 }`                      | something on this computer listens on the port                         |
| `{ url = "http://localhost:3000/up" }` | the address, which must start with `http://`, answers without an error |
| `{ log = "Listening on" }`             | the task prints a line containing the text                             |
| `timeout = 120`                        | added to any of these: seconds to wait, 60 by default                  |

`ready` takes one of `port`, `url` and `log`. A task waiting for a persistent task [without a ready check](https://axlers.dev/docs/messages/never-ready.md) is an error, since it would wait forever, and a ready check that doesn't pass in time [fails the task](https://axlers.dev/docs/messages/not-ready-in-time.md). When everything else has finished, Axle stops the persistent tasks the run started only to wait for. Persistent tasks you name yourself, such as in `axle run dev`, run until you press Ctrl+C.

```toml
[tasks.dev]
with = ["api#dev"]

[tasks.e2e]
dependsOn = ["api#dev"]
exclusive = true
```

```toml
# services/api/axle.toml
[tasks.dev]
ready = { url = "http://localhost:8080/health" }
```

Here `axle run dev` also starts the API, and stops it when the web dev server stops. `axle run e2e` starts the API, waits until it answers, runs the tests alone, then stops the API.

Under [`axle watch`](https://axlers.dev/docs/reference/watch.md), a persistent task starts once and keeps running while other tasks run again; most dev servers reload on their own. One that doesn't, such as an API server run with `node`, can say `restart = true`, and `axle watch` restarts it when a file in its package changes or a task it waits for runs again.

### Variants

A variant is a named set of task keys that applies over the task when `axle run` is given `--variant <name>`. It can set any task key except `variants` and `description`, since a variant keeps its task's description. Each task that has the variant uses it, and the others run as usual. A variant's name is part of the hash, so `build` and `build --variant dev` are cached apart. Naming a variant no selected task has is an [error](https://axlers.dev/docs/messages/unknown-variant.md).

```toml
[tasks.build.variants.dev]
arguments = ["--mode", "development"]
setEnv = { NODE_ENV = "development" }
```

## Inputs

Without `inputs`, a task's hash counts every file in its package. `inputs` narrows that to the files the task reads, so a change to a README or a test doesn't rebuild what doesn't read it:

```toml
globalInputs = ["tsconfig.base.json", ".nvmrc"]

[inputs]
production = ["default", "!**/*.test.ts", "!**/*.md"]

[tasks.build]
inputs = ["production", "^production", "{root}/babel.config.js"]
outputs = ["dist/**"]

[tasks.test]
inputs = ["default", "^production"]
```

Each entry of `inputs` is one of these:

| Entry                            | Means                                                                                         |
| -------------------------------- | --------------------------------------------------------------------------------------------- |
| `src/**/*.ts`                    | a [glob pattern](https://axlers.dev/docs/reference/globs.md) relative to the package                              |
| `{root}/*.ts`                    | a glob pattern relative to the repository root                                                |
| `production`                     | a named set from `[inputs]`; `default` is every file in the package unless `[inputs]` sets it |
| `^production`                    | the set's files in every package this one depends on, directly or not                         |
| `^outputs`                       | the files that the tasks this one waits for wrote, instead of their hashes                    |
| `!**/*.md`                       | leaves out what a pattern or set would add                                                    |
| `{ command = "node --version" }` | the output of a command; see [command inputs](#command-inputs)                                |

Sets in `[inputs]` can name other sets, but not in a circle, and can't contain a `^` entry. Only the root `axle.toml` and its presets have `[inputs]` and `globalInputs`.

### Command inputs

Some tasks depend on a tool that isn't a file in the repository, such as the compiler or the version of Node.js on the machine. An entry `{ command = "..." }` makes the command's output one of the task's inputs, so the task runs again when the output changes:

```toml
[inputs]
toolchain = [{ command = "node --version" }, { command = "go version" }]

[tasks.build]
inputs = ["default", "toolchain"]
```

- Axle runs each command once per run, whichever tasks name it, through the system's shell at the repository root, before any task starts.
- A command gets the variables tasks get: in strict mode, those every task gets and those in `globalEnv` and `globalPassThroughEnv`; in loose mode, every variable.
- Both what it prints and what it writes to standard error count, so a command such as `java -version` works.
- If a command can't start or exits with a code other than 0, nothing runs and Axle [says which command failed](https://axlers.dev/docs/messages/input-command-failed.md).
- [`axle why miss`](https://axlers.dev/docs/reference/cache.md#why-a-task-ran) says "the output of `node --version` changed", and [`axle show`](https://axlers.dev/docs/reference/show.md) lists the command with the other inputs.
- Commands don't take part in `--affected`, which compares files between two commits: a task isn't affected because a command's output differs.

`globalInputs` takes only globs.

A task with `inputs` still counts its dependencies in its package's lockfile, its environment variables and the hashes of the tasks it waits for. With `^outputs`, Axle hashes the files those tasks wrote instead of their hashes, so a dependency that rebuilds to the same files doesn't rebuild what waits for it. That hash is only known once those tasks have finished, so `--dry` shows "after dependencies" for it, and each task it waits for must declare `outputs`, or it's an [error](https://axlers.dev/docs/messages/outputs-not-declared.md).

Files outside every package, such as a root `tsconfig.json`, count for every task. `globalInputs` limits that to the files it matches, relative to the root, and leaves the others out of every hash and out of `--affected`.

## Affected

With `inputs`, `--affected` runs a task only when a changed file is one of its inputs, when its dependencies in the lockfile changed, or when a task it waits for is affected. [Command inputs](#command-inputs) play no part. A task without `inputs` is affected when its package is, as [affected](https://axlers.dev/docs/reference/affected.md) describes. [`axle why affected web#build`](https://axlers.dev/docs/reference/affected.md) names the input that matched.

```toml
affected = "projects"
```

`affected = "projects"` at the root goes back to package-level affected for every task, whatever its inputs. The default is `"tasks"`.

```toml
base = "develop"
```

`base` names the branch, tag or commit `--affected` compares with when neither `--base` nor `AXLE_SCM_BASE` names one, and a pull request in CI doesn't either. Without it, Axle uses `origin`'s default branch, then `main` or `master`, as [what is compared](https://axlers.dev/docs/reference/affected.md#what-is-compared) describes.

## Test files

A task can be given the files of a change as arguments, so it runs only the tests the change reaches. Two placeholders in `arguments` stand for lists of files, with `--affected` and in [`axle watch`](https://axlers.dev/docs/reference/watch.md#test-files):

| Placeholder      | Stands for                                                                                                         |
| ---------------- | ------------------------------------------------------------------------------------------------------------------ |
| `{testFiles}`    | the task's test files that import a changed file it reads, directly or through other files, in its own package     |
| `{changedFiles}` | the changed files the task reads: those in its package and the packages it depends on, or those its `inputs` match |

```toml
[tasks.test]
arguments = ["{testFiles}"]
```

```toml
[tasks.test]
command = "vitest"
arguments = ["related", "--run", "{changedFiles}"]
fallbackArguments = ["run"]
```

Each placeholder has to be an argument of its own, and becomes one argument per file, as a path from the task's folder such as `src/button.test.ts` or `../../packages/ui/src/button.ts`.

When Axle can't name the files, the task runs every test, with `fallbackArguments`, or without the placeholders when it has none: without `--affected`, when a changed file reaches none of its test files, when the lockfile or a file outside every package changed, or when the list would be longer than 8,000 characters. [Running only the tests a change reaches](https://axlers.dev/docs/crafting-your-repository/running-only-affected-tests.md) lists every case, and `axle run --dry` says which applies.

`testFiles` says which files are tests, as globs relative to the package. Without it, they're the files named like `*.test.ts` or `*.spec.tsx`, in any of the JavaScript and TypeScript extensions, and every such file in a `__tests__` folder:

```toml
[tasks.test]
arguments = ["{testFiles}"]
testFiles = ["src/**/*.test.ts", "!src/**/*.slow.test.ts"]
```

## Projects

A project is a folder Axle runs tasks in without a `package.json`, such as a Go service or a Python tool. The root `axle.toml` lists where projects are, and each project's own `axle.toml` gives its name and the commands of its tasks:

```toml
projects = ["services/*"]
```

```toml
# services/worker/axle.toml
name = "worker"
tags = ["backend", "go"]
implicitDependencies = ["@acme/schema"]

[tasks.build]
command = "go build ./..."
outputs = ["bin/**"]
```

| Key                    | Meaning                                                                                                                         |
| ---------------------- | ------------------------------------------------------------------------------------------------------------------------------- |
| `projects`             | at the root: glob patterns of folders that hold a project's `axle.toml`                                                         |
| `name`                 | in a project's file: the project's name, unique among packages and projects                                                     |
| `tags`                 | labels to choose packages and projects by, with `--filter tag:backend`, and for [boundaries rules](https://axlers.dev/docs/reference/boundaries.md) |
| `implicitDependencies` | names of packages or projects this one depends on beyond its `package.json`; `!name` removes a dependency                       |

Projects join the task graph, the cache, `--affected` and filters exactly like packages, and `axle list` shows them. Each task of a project needs a `command`, since there's no script to run. Axle only looks for projects where `projects` says, never through the whole repository. `tags` and `implicitDependencies` also work in a package's own `axle.toml`. A pattern that matches no project is a [warning](https://axlers.dev/docs/messages/project-pattern-matches-nothing.md), and a name that isn't a package or project is an [error](https://axlers.dev/docs/messages/unknown-implicit-dependency.md).

## Plugins

```toml
[plugins.services]
source = "./tools/axle-services"
```

A plugin finds projects Axle can't, such as Python packages, and adds tasks from the files they already have.

| Key       | Meaning                                                                                                                 |
| --------- | ----------------------------------------------------------------------------------------------------------------------- |
| `source`  | required: the plugin's folder relative to the root, `npm:<package>@<version>`, or the `https://` address of a `.tar.gz` |
| `hash`    | the SHA-256 of what Axle downloads for an npm or `https://` source, as `sha256-<hex>`                                   |
| `timeout` | how many seconds the plugin may take to answer before Axle stops it; default `30`                                       |

Every other key is the plugin's own setting. Only the root `axle.toml` lists plugins, not a preset. `axle add` writes the table for you. See [plugins](https://axlers.dev/docs/reference/plugins.md).

## Generators

```toml
[generators.component]
path = "tools/generators/component"
```

The repository's own generators for [`axle generate`](https://axlers.dev/docs/reference/generate.md), by the name they're run with. `path` is the generator's folder, relative to the repository root, with its `generator.toml`. Only the root `axle.toml` lists generators, and a name can't be `package` or `ci`, which are built in, or have a `:`. See [writing generators](https://axlers.dev/docs/crafting-your-repository/writing-generators.md).

## Sync

```toml
[sync]
typescriptReferences = true
```

The files [`axle sync`](https://axlers.dev/docs/reference/sync.md) keeps in step with the graph. With `typescriptReferences`, each package's `tsconfig.json` refers to the packages it depends on. It's off by default. Only the root `axle.toml` and its presets have `[sync]`.

## Boundaries

```toml
[boundaries]
ignoreImports = ["src/*"]

[[boundaries.rules]]
tag = "type:app"
allow = ["type:lib"]

[[boundaries.rules]]
tag = "*"
deny = ["scope:internal"]
```

What [`axle boundaries`](https://axlers.dev/docs/reference/boundaries.md) checks. Each rule is about the projects with its `tag`, or every project with `*`:

| Key     | What it does                                                                                                   |
| ------- | -------------------------------------------------------------------------------------------------------------- |
| `tag`   | the tag of the projects the rule is about, or `*`                                                              |
| `allow` | tags a dependency of these projects must have one of; `[]` allows no dependency, and leaving it out allows any |
| `deny`  | tags no dependency of these projects may have                                                                  |

`undeclaredImports`, on by default, also checks that each file imports only packages its own `package.json` or the root's declares, and no other package's files. Projects without a `package.json` aren't checked for undeclared imports. `ignoreImports` lists import specifiers to leave alone, such as path aliases, with `*` for any characters; Axle leaves them out of the rules and of `scanImports` too. A preset may set these too: `axle.toml` replaces a preset's `rules`, and its `ignoreImports` replaces the preset's unless it contains `"..."`.

## Releases

```toml
[release]
mode = "fixed"
versions = "changes"
changelog = true
hosting = "github"
alsoUpdate = ["Cargo.toml"]

[[release.groups]]
name = "sdk"
packages = ["@acme/sdk-*"]
mode = "fixed"
tag = "sdk-v{version}"
```

How [`axle release`](https://axlers.dev/docs/reference/release.md) works out versions and what it writes:

| Key          | What it does                                                                                                                              |
| ------------ | ----------------------------------------------------------------------------------------------------------------------------------------- |
| `mode`       | `independent`, the default, gives each package its own version and tag; `fixed` gives every package the same version, tagged `v<version>` |
| `versions`   | `commits`, the default, reads Conventional Commits; `changes` reads the change files in `.changes/`                                       |
| `changelog`  | writes a section into each released package's `CHANGELOG.md`, or the root's in `fixed` mode; on by default                                |
| `hosting`    | `github` or `gitlab`: `axle release publish` also creates a release there for each tag; none by default                                   |
| `alsoUpdate` | more files whose version follows a `fixed` release, such as `Cargo.toml`, relative to the root                                            |
| `tag`        | the format of each tag, with `{name}` and `{version}`; `{name}@{version}` by default, and `v{version}` in `fixed` mode                    |
| `groups`     | [release groups](https://axlers.dev/docs/reference/release.md#release-groups): named sets of packages, each with its own settings                             |

Each of the `[[release.groups]]` takes these keys; packages outside every group follow the keys above:

| Key         | What it does                                                                                                         |
| ----------- | -------------------------------------------------------------------------------------------------------------------- |
| `name`      | the group's name, for `axle release --group` and, in a `fixed` group, its tags; required                             |
| `packages`  | the packages in the group, by name or by a glob such as `@acme/sdk-*`; a package can be in only one group; required  |
| `mode`      | `independent` or `fixed`, for the group's packages; the same as `[release]` when left out                            |
| `versions`  | `commits` or `changes`, for the group's packages; the same as `[release]` when left out                              |
| `tag`       | the format of the group's tags; `{name}@{version}` by default, where `{name}` is the group's name in a `fixed` group |
| `changelog` | whether the group's packages get changelogs; the same as `[release]` when left out                                   |

Only the root `axle.toml` and its presets have `[release]`. A preset's `alsoUpdate` is replaced unless the list contains `"..."`, and its `groups` are replaced when `axle.toml` has any.

## Dependencies from imports

```toml
scanImports = true
```

Adds a dependency on each workspace package that a package's JavaScript and TypeScript files import, beyond the dependencies in its `package.json`. It's off by default, and leaves out the specifiers `[boundaries]` `ignoreImports` lists. See [dependencies from imports](https://axlers.dev/docs/reference/plugins.md#dependencies-from-imports).

## Run settings

`[run]` sets the defaults of [axle run](https://axlers.dev/docs/reference/run.md)'s options. An `AXLE_*` variable wins over the file, and a flag wins over both.

| Key               | Flag                  | Variable                 | Values                                                                                                                    |
| ----------------- | --------------------- | ------------------------ | ------------------------------------------------------------------------------------------------------------------------- |
| `concurrency`     | `--concurrency`       | `AXLE_CONCURRENCY`       | a number such as `4`, or a share of the cores, `"50%"`; the number of cores by default                                    |
| `continue`        | `--continue`          | `AXLE_CONTINUE`          | `"never"`, the default, `"always"` or `"dependencies-successful"`                                                         |
| `logOrder`        | `--log-order`         | `AXLE_LOG_ORDER`         | `"stream"`, the default, or `"grouped"`, the default [in CI](https://axlers.dev/docs/reference/run.md#in-ci)                                  |
| `outputLogs`      | `--output-logs`       | `AXLE_OUTPUT_LOGS`       | `"full"`, the default, `"new-only"`, `"hash-only"`, `"errors-only"` or `"none"`                                           |
| `envMode`         | `--env-mode`          | `AXLE_ENV_MODE`          | `"strict"`, the default, or `"loose"`                                                                                     |
| `checkInputs`     | `--check-inputs`      | `AXLE_CHECK_INPUTS`      | `"off"`, the default, `"warn"` or `"error"`; see [checking inputs](https://axlers.dev/docs/reference/run.md#checking-inputs)                  |
| `checkInputsWith` | `--check-inputs-with` | `AXLE_CHECK_INPUTS_WITH` | `"tracing"`, on Linux only and the default there, or `"sandbox"`, the default elsewhere                                   |
| `ui`              | `--ui`                | `AXLE_UI`                | `"tui"`, the default, or `"stream"`; see [terminal UI](https://axlers.dev/docs/reference/run.md#terminal-ui)                                  |
| `logFile`         | `--log-file`          | `AXLE_LOG_FILE`          | a file that also gets every task's output and the summary, without colours; see [log file](https://axlers.dev/docs/reference/run.md#log-file) |

[axle exec](https://axlers.dev/docs/reference/exec.md) and [axle watch](https://axlers.dev/docs/reference/watch.md) read them too, for the options they have. A relative `logFile` is relative to the repository's root, while a relative `--log-file` or `AXLE_LOG_FILE` is relative to the folder Axle was started in.

## Cache settings

| Key       | Variable              | Meaning                                                                                                                                                                                   |
| --------- | --------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `mode`    | `AXLE_CACHE`          | what the caches may do, such as `"local:rw,remote:r"`, or `"none"`; default `"local:rw,remote:rw"`; see [caching](https://axlers.dev/docs/reference/run.md#caching)                                           |
| `dir`     | `AXLE_CACHE_DIR`      | the cache's folder; a relative path is relative to the repository root; by default a folder in your user cache folder                                                                     |
| `maxAge`  | `AXLE_CACHE_MAX_AGE`  | entries unused for this long are removed, in days or hours, such as `"7d"` or `"12h"`; default `"14d"`                                                                                    |
| `maxSize` | `AXLE_CACHE_MAX_SIZE` | above this size the least recently used entries go, in `KB`, `MB`, `GB` or `TB`, such as `"20GB"`; default `"10GB"`; no entry may [unpack to more](https://axlers.dev/docs/messages/cache-entry-too-large.md) |

A `dir` inside the repository suits a CI service that saves a folder between runs. Axle puts a `.gitignore` in it, so it's never committed, unless the folder already holds files of yours; then it leaves the folder alone. `--cache` also wins over `mode`.

### Remote cache

```toml
[cache.remote]
url = "https://cache.example.com"
team = "web"
signature = true
encryption = true
```

| Key          | Variable                    | Meaning                                                                                                                                                           |
| ------------ | --------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `url`        | `AXLE_REMOTE_CACHE_URL`     | the address of an `axle-server`, `s3://bucket/prefix`, `azure://account/container/prefix`, or a shared folder                                                     |
| `team`       | `AXLE_REMOTE_CACHE_TEAM`    | keeps the entries of different teams or repositories apart; default `"default"`                                                                                   |
| `signature`  |                             | `true` signs entries with `AXLE_REMOTE_CACHE_SIGNATURE_KEY` and refuses those without a matching signature                                                        |
| `encryption` |                             | `true` encrypts entries with `AXLE_REMOTE_CACHE_ENCRYPTION_KEY` before they leave the machine                                                                     |
| `timeout`    | `AXLE_REMOTE_CACHE_TIMEOUT` | how long a request may go without progress before Axle gives up on the remote cache for the run, in seconds or minutes such as `"30s"` or `"2m"`; default `"30s"` |

Only the root `axle.toml` and its presets have `[cache.remote]`. Tokens never go in the file; [remote cache](https://axlers.dev/docs/reference/remote-cache.md) explains them and every other setting.

## Hooks

```toml
[hooks]
before = ["node scripts/login.mjs"]
after = ["node scripts/upload-report.mjs"]
```

`before` commands run at the repository root, in order, before any task. If one fails, no task runs and `axle run` [exits with its exit code](https://axlers.dev/docs/messages/before-hook-failed.md). `after` commands run when the run ends, whether it passed or not, with `AXLE_RUN_STATUS` set to `passed`, `failed` or `stopped`, and `AXLE_RUN_REPORT` set to the report's path when `--summarize` wrote one. A failing `after` command is a [warning](https://axlers.dev/docs/messages/after-hook-failed.md). Hooks don't run for `--dry`.

## Watch settings

```toml
[watch]
ignore = ["**/*.log", "docs/**"]
```

`ignore` lists [glob patterns](https://axlers.dev/docs/reference/globs.md), from the root, of files whose changes never start a run of [`axle watch`](https://axlers.dev/docs/reference/watch.md). Files Git ignores, `.git`, `.axle` and `node_modules` never do anyway.

## Dev proxy

```toml
[proxy]
port = 3000
routes = { "/" = 5173, "/api" = 4000, "/docs" = "http://localhost:4321" }
```

When a run of `axle run` or [`axle watch`](https://axlers.dev/docs/reference/watch.md) includes a [persistent task](#persistent-tasks), such as `axle run dev`, Axle also listens on `port` and sends each request to a dev server by its path, so an app split into several dev servers works on one address, as it does in production, with no cross-origin settings:

```text
The proxy at http://localhost:3000 sends /docs to localhost:4321, /api to localhost:4000 and / to localhost:5173.
```

Each route is a path and where its requests go: the port of a dev server on this computer, or its address, `http://` with a host and a port. The longest path that matches a request wins, so `/api/users` goes to the `/api` server and `/about` to the `/` one; a path matches whole segments, so `/apiary` isn't under `/api`. Requests pass through unchanged, path included, with `X-Forwarded-Host`, `X-Forwarded-Proto` and `X-Forwarded-For` added, and WebSocket connections pass through too, so hot reloading keeps working. A dev server served under a path, such as `/docs`, needs that as its base path in its own config.

A request no route matches gets a page that says so, and one whose dev server isn't listening yet gets a page asking to reload in a moment. The proxy listens only on this computer, and stops when Axle does. A port another program has, or routes without a port, is a [warning](https://axlers.dev/docs/messages/proxy-not-started.md), and the run goes on without the proxy.

## Presets

```toml
extends = ["@acme/axle-preset", "./config/axle.base.toml"]
```

A preset holds settings shared between repositories. A package name is found in `node_modules`, as Node finds packages from the root, and its `axle.toml` is read. A path starting with `.` is read relative to the file that names it. Later presets win over earlier ones, the root file wins over all of them, and a preset can extend others. A preset that [isn't installed](https://axlers.dev/docs/messages/preset-not-installed.md) or that [extends itself](https://axlers.dev/docs/messages/presets-in-a-circle.md) is an error. A preset can't set `projects`, `plugins` or `generators`.
