---
title: ".ci config reference: ModernCI docs"
description: "The .ci/<target>.yaml and .ci/repo.yaml files: checks, inputs, promotions and release steps."
url: https://modernci.dev/docs/config/
---

# Configuring checks: `.ci/*.yaml`

Checks live in your repo, next to the code they check, and change through pull requests like any
other file. One file per target branch:

| File | What it holds |
|---|---|
| `.ci/<target>.yaml` | The checks for PRs **into** that branch (`.ci/dev.yaml`, `.ci/main.yaml`). |
| `.ci/repo.yaml` | The few repo-level keys that live in the repo. |

Your editor can validate and complete these files. Add this as the first line:

```yaml
# yaml-language-server: $schema=https://modernci.dev/schema/ci.json
```

The schema is published as `crates/mci-config/schema/ci.schema.json` (branch files) and
`repo.schema.json` (`.ci/repo.yaml`). The loader is stricter than any editor: it refuses unknown
keys and names the file and line.

## The smallest file

```yaml
# .ci/dev.yaml
checks:
  test:
    run: make test
```

Every key under a check except `run` is optional. A check is a command; it passes when it exits 0.

## What a file may contain

| Key | Meaning |
|---|---|
| `checks` | The checks, by name, in the order shown to people. |
| `setup` | Commands every check runs first (see below). |
| `env` | Environment for every check. Names starting `MODERNCI_` are reserved. |
| `toolchain` | Pinned tool versions, for example `rust: "1.98.0"`. |
| `promotes` | Marks a promotion file; see [Promotion targets](#promotion-targets). |

Anything else is an error: `.ci/dev.yaml:4: unknown key `retries``.

### What is not here

Who may approve, which paths are guarded, budgets, compute, secrets, webhooks and which branches
are judged are **ModernCI settings**, changed by a person in the repo's settings. They are never
read from a file in the repo, because anyone who can push a branch could then change how your CI
runs. A file that contains one (`guard`, `budget`, `compute`, `targets`, `webhook`, `shadow`, and
so on) is refused with a message pointing at settings.

## Check keys

| Key | Default | Meaning |
|---|---|---|
| `run` | required | The command line. |
| `setup` | the file's `setup` | Commands to run first instead of the file's, or `false` for none. |
| `inputs` | whole tree | Globs of the only files the check reads. |
| `tools` | none | Tools the check needs, name to version. |
| `needs` | none | Checks that must pass before this one starts. |
| `shards` | 1 | Split across 1 to 32 machines. |
| `class` | `gate` | `gate`, `after` or `release`. |
| `on` | from `class` | `pr` (gate checks) or `landed` (`after` and `release`). `on: landed` alone makes a release step. |
| `publish` | none | Release steps only: what the release publishes (see [Release steps](#release-steps)). |
| `stage` | 1 | Pre-check stage, 1 to 9 (gate checks only). |
| `queue_only` | false | Run only in the merge queue (gate checks only). |
| `required` | true | `false` makes a red advisory. |
| `timeout` | none | `90`, `45s`, `30m`, `1h30m`; at most 24 hours. |
| `tests` | none | Test report format: `nextest`, `libtest` or `junit`. |
| `env` | none | Environment on top of the file's `env`. |

Check names are lowercase letters, digits, `-`, `_` and `.`, up to 64 characters. `@` is reserved
for shards.

## Shared setup

Put commands every check needs first in `setup:`. They run before each check's `run`, in the same
shell, and the first one that fails fails the check. A check can run its own list instead, or none.

```yaml
# .ci/dev.yaml
env:
  CARGO_HOME: ${cache}/cargo
setup:
  - cargo fetch --locked
checks:
  test:
    run: cargo test --locked
  docs:
    run: ./tools/lint-docs
    setup: false
  wasm:
    run: cargo build --target wasm32-unknown-unknown
    setup: [rustup target add wasm32-unknown-unknown]
```

A check's setup is part of what its result depends on: editing `setup:` re-runs only the checks
that run it.

## Narrow what a check reads: `inputs`

By default a check's result is reused only when the whole tree is identical. If a check only reads
some files, say so:

```yaml
# .ci/dev.yaml
checks:
  fmt:
    run: cargo fmt --check
    inputs: ["**/*.rs", Cargo.toml, rustfmt.toml]
  docs:
    run: ./tools/lint-docs
    inputs: ["docs/**", "tools/lint-docs"]
```

The check then runs in a **sparse, read-only checkout of just those paths**, and its result is
reused on every commit where those files are unchanged. A read outside the list fails to find the
file, so the check goes red; it cannot pass by accident. When a red looks like that, the log
excerpt says "possibly an undeclared input". Globs are repo-relative, with no `..`.

Changing `inputs` is a gate change (below).

## Order and stages: `needs`, `stage`

`needs: [build]` starts a check only after `build` passes. A gate check can only need gate checks;
`after` and `release` checks can need gates and each other. Loops and unknown names are errors.

On a PR's pre-check, checks run in **stages** so cheap failures arrive first:

```yaml
# .ci/dev.yaml
checks:
  fmt:
    run: cargo fmt --check
    stage: 1
  clippy:
    run: cargo clippy --locked -- -D warnings
    stage: 1
  test:
    run: cargo test --locked
    stage: 2
    needs: [clippy]
```

Everything in a stage runs, so all of that stage's reds arrive together; the next stage starts
when the earlier ones pass. A check cannot need a check in a later stage. The merge queue runs
every gate at once and ignores stages, to land as fast as possible.

## Merge-queue-only checks: `queue_only`

Slow or expensive checks can skip the PR pre-check and run only when a PR is in the merge queue:

```yaml
# .ci/dev.yaml
checks:
  test:
    run: cargo test --locked
  load-test:
    run: ./load-test
    queue_only: true
    timeout: 20m
```

A pre-check cannot wait for a `queue_only` check, so a check that `needs` one must be `queue_only`
too.

## Split a check across machines: `shards`

```yaml
# .ci/dev.yaml
checks:
  build:
    run: make tool
  e2e:
    run: ./e2e --shard "$MODERNCI_SHARD"
    needs: [build]
    shards: 4
```

- The check runs as `e2e@0` to `e2e@3`. Each is told `MODERNCI_SHARD_INDEX` (from 0),
  `MODERNCI_SHARD_COUNT` and `MODERNCI_SHARD` (`2/4`).
- Each shard is its own job: placed, retried, billed, logged (`log --check e2e@2`) and reused on
  its own. The PR passes only when every shard passes, and a red names the shard.
- `needs: [e2e]` waits for every shard. `needs: ["e2e@1"]` and a check named `e2e@1` are errors.
- `shards` is 1 to 32. Long checks on the merge queue should be sharded so the queue's wall time
  stays short.

## Classes: `gate`, `after`, `release`

```yaml
# .ci/dev.yaml
checks:
  test:
    run: cargo test --locked
  soak:
    run: ./soak
    class: after
    timeout: 1h
  publish:
    run: ./publish
    class: release
    needs: [soak]
```

- `gate` (default) blocks landing.
- `after` runs on the newest landed tip. A red is reported as a **landed red** and attributed to
  the change that caused it; it never blocks other PRs.
- `release` is a step of the release after landing.

`on:` says the same thing from the other side: `on: pr` for gate checks (pre-check and merge
queue), `on: landed` for `after` and `release` checks. A check with `on: landed` and no `class`
is a release step. `on: landed` on a gate check, and `on: pr` on an `after` or `release` check,
are errors. Landed steps run only on a checked tip of the target, never on an unchecked one.

`stage` and `queue_only` apply to gate checks only.

## Release steps

Release steps run after a PR lands on the release target (usually `main`). They build and
package; ModernCI signs and publishes. A step **never sees the signing key**: after its `run`
passes, ModernCI asks its separate signer process to sign the artifacts' digests, writes signed
SLSA build provenance for them, and publishes the signed channel metadata (a key set, a snapshot and a short-lived timestamp) for the release.

```yaml
# .ci/main.yaml
checks:
  test:
    run: cargo test --locked
  release:
    on: landed
    needs: [test]
    timeout: 1h
    run: >-
      v="$(mci release version)" &&
      for t in x86_64 aarch64; do
        cargo build --release --locked --target "$t-unknown-linux-gnu" &&
        mci release package --arch "$t-linux" --version "$v"
          --binary "target/$t-unknown-linux-gnu/release/mci" --out out || exit 1;
      done
    publish:
      channel: stable
      rollback_safe: true
      artifacts:
        - { arch: x86_64-linux, path: "out/mci-*-x86_64-linux.tar.gz" }
        - { arch: aarch64-linux, path: "out/mci-*-aarch64-linux.tar.gz" }
```

The artifacts a step publishes are the files it wrote in its own job. `mci release package` writes
`mci-<version>-<arch>.tar.gz` (one `mci` binary inside) and its `.sha256`; an artifact `path` may
contain `*`, which must match exactly one file.

| `publish` key | Default | Meaning |
|---|---|---|
| `artifacts` | required | One `{arch, path}` per architecture: `x86_64-linux`, `aarch64-linux`. Paths are repo-relative. |
| `channel` | `stable` | Channel name: lowercase letters, digits and `-`. |
| `rollback_safe` | `true` | `false` when the release cannot be rolled back to the previous one (a migration that cannot be expanded). Such a release is installed only after the owner approves it. |

The version is never configured: it comes from the commit (`<major.minor>.<height on main>`).
See [Build & Release](/build/) for signing and provenance.

## Required and advisory

`required: false` runs the check and shows its result without blocking landing. A new check also
starts in **shadow**: it runs, but does not block until it has passed once on the target. Shadow
follows what the check does, not its name, so renaming a check does not reset it.

## Promotion targets

`.ci/qa.yaml` and `.ci/main.yaml` usually share most checks with `dev`. A promotion file says
`promotes:` and lists only what it **adds**; the target's checks are the source's checks plus
those.

```yaml
# .ci/dev.yaml
toolchain:
  rust: "1.98.0"
checks:
  test:
    run: cargo test --locked
  lint:
    run: cargo clippy --locked -- -D warnings
```

```yaml
# .ci/qa.yaml
promotes: dev
checks:
  smoke:
    run: ./smoke
    needs: [test]
```

```yaml
# .ci/main.yaml
promotes: qa
checks:
  release-notes:
    run: ./release-notes
    class: release
    needs: [smoke]
```

Re-using a source check's name, a loop of `promotes`, a missing source file and conflicting
toolchain pins are errors. Because checks unchanged from the source have the same definition,
their results are reused in the promotion.

## Gate changes

Changing what blocks landing is itself reviewed. A PR that changes a gate check's `run`, `setup`,
`inputs` or `tools`, adds or removes a gate check, changes `required`, `shards` or `queue_only`
on one, or changes a `toolchain` pin:

- is shown as `gate changed`, with the change in cost per landed PR;
- needs a person's approval (it is a guarded change);
- lands on its own, never batched with other PRs, so no PR lands under a gate it was not shown.

Not gate changes: renaming a check, changing `timeout`, `stage`, `needs`, `env` or `tests`, and
anything about `after` or `release` checks, including `on` and `publish`.

## A broken file never falls back

If `.ci/<target>.yaml` is missing or does not parse, PRs into that target report a configuration
error naming the file and line. ModernCI never substitutes an older copy of the file.

## `.ci/repo.yaml`

```yaml
# .ci/repo.yaml
agents: true
```

`agents` says whether agents may take the repo's work items. Every other key is refused.

## Reference

`.ci/` files are YAML. The JSON Schemas are `crates/mci-config/schema/ci.schema.json` and
`crates/mci-config/schema/repo.schema.json`; they are generated from the loader's own types and a
test fails if they drift.

## Where each kind of configuration lives

| What | Where | How to change it |
|---|---|---|
| Checks, setup, env, toolchain, promotions | `.ci/<target>.yaml` in the repo (this page) | A PR. Gate changes need a person's approval. |
| `agents` | `.ci/repo.yaml` | A PR. |
| Budgets, approvals required, data regions, which forge and compute kinds are allowed, feature flags | ModernCI settings, by level (operator, tenant, project) with a source and optional lock | `mci settings list <level> <scope>`, `mci settings get <level> <scope> <setting>`, `mci settings set <level> <scope> <setting> --value '{...}'`, or the console's settings page. |
| Forge and compute connection | Settings `forge.plugin` and `compute.plugin` with their config | `mci forges connect`, `mci computes connect` . |
| Secrets | A write-only secret store, never the repo | `mci secrets put` (coming). |

The reasons settings never come from the repo are in [security](/docs/security.md#who-can-change-what).
Concepts such as class, gate change and reuse: [concepts](/docs/concepts.md).
