# Recurring tasks

How a task repeats with `every()` or `rrule()`, and how `mt recur` writes the next occurrence.

For a chore that comes back, like a weekly review or a yearly renewal, set `recur:` on the task. `mt` never advances a series by itself, and no read command changes a file. When you finish an occurrence, run `mt recur <task>` to write the next one.

## Periods

`every()` takes exactly one of `days`, `weeks`, `months` or `years`:

```typ
// tasks/nightly-dependency-audit.typ: every day
  recur: every(days: 1),

// tasks/weekly-backlog-grooming.typ: every Monday
  recur: every(weeks: 1, on: (mon,)),

// tasks/annual-certificate-rotation.typ: every year, counted from the due date
  recur: every(years: 1, anchor: "due"),
```

`on:` takes a set of weekdays, written with the prelude’s names `mon` to `sun`, and needs a `weeks` period. Each occurrence falls on the next listed weekday in an on-week.

Weeks run Monday to Sunday and count from Monday 2001-01-01. With `weeks: N`, every Nth week from that Monday is an on-week. So `every(weeks: 2, on: (mon, thu))` falls on Monday and Thursday of every second week. If you finish late in an off week, the next occurrence still falls on the following on-week.

To pick which weeks, pass `start:` with a date. The week containing `start` is an on-week, and so is every Nth week after it. So `every(weeks: 2, on: (mon, thu), start: on(2026, 6, 1))` runs the weeks of June 1 and June 15, and a series with `start: on(2026, 6, 8)` runs the other weeks. A series without `start` keeps the 2001-01-01 epoch. `start` needs a `weeks` period with an `on:` set, and a spawned occurrence keeps it.

## Policy

Four more arguments control the series:

- `anchor` sets the date the next occurrence counts from. `"completion"` counts from the day you run `mt recur`. `"due"` counts from the task’s `due` date and skips any occurrence already past, so finishing late doesn’t shift the schedule.
- `until` is the last date an occurrence may fall on.
- `count` is the number of occurrences left. `mt recur` lowers it by one each time.
- `materialize` sets what `mt recur` writes. `"spawn"` writes a new task file for the next occurrence. `"mutate"` resets the task’s own status and dates for it. Spawn keeps a file per occurrence as history. Mutate keeps one file, and git keeps the history.

`[tasks.recur]` sets the `default-anchor` and `materialize` a task gets when it leaves them out, and limits the values a task may use:

| Key | Default | Purpose |
| --- | --- | --- |
| `anchors` | `["completion", "due"]` | Allowed anchors. Empty = any. |
| `default-anchor` | `"completion"` | Anchor used when a task’s `recur` omits one. |
| `enabled` | `true` | Whether the config enables the recurrence feature. `false` rejects any authored `recur` field outright, at both `mt check` and `mt recur`. |
| `materialize` | `"spawn"` | Materialize model used when a task’s `recur` omits one. |
| `max-advance` | `52` | Largest `N` that `mt recur --advance N` accepts. |
| `rrule` | `false` | Whether a `recur` field may use `rrule(...)`. Off by default. Without it, `mt` rejects an `rrule(...)` with an error. |
| `units` | `["days", "weeks", "months", "years"]` | Allowed period units. Empty = any. |

```typ
// tasks/quarterly-access-audit.typ: every three months, with each policy argument set
  recur: every(
    months: 3,
    anchor: "due",
    until: on(2027, 1, 1),
    count: 4,
    materialize: "mutate",
  ),
```

## Writing the next occurrence

`mt recur <task>` writes the next occurrence. With `"spawn"`, it writes a new file and leaves the task you ran it on alone:

```
$ mt recur nightly-dependency-audit
spawned tasks/audit-dependencies-nightly-2026-09-16.typ (due 2026-09-16)
```

The new task has a `recurred-from` edge to the one before it. The series forms a chain of files:

```typ
// tasks/standup-notes-2026-09-15.typ: an edge from the next day's task to the one before
  links: recurred-from("standup-notes-2026-09-14.typ"),
```

`mt recur` refuses a task that already has a successor, and a series that has reached its `until` date or a `count` of 0. `--dry-run` prints what it would write. `--advance <N>` writes the next N occurrences at once. `--skip` skips the next occurrence without writing one. The [`mt recur` page](https://mlavrinenko.github.io/mindtape/cli/recur/index.md) lists every flag.

## Calendar rules with rrule

When `every()` can’t express the schedule, such as the first Monday of each month or every weekday, `rrule(...)` takes an RFC 5545 rule:

```typ
// tasks/monthly-cost-report.typ: the first Monday of every month
  recur: rrule("FREQ=MONTHLY;BYDAY=1MO"),
```

To allow it, set `[tasks.recur] rrule = true` in the project’s config. Without that key, `mt check` reports each `rrule(...)` as disabled. With it, `mt check` checks the rule and quotes one that doesn’t parse.

An `rrule(...)` series counts from the task’s `due` date, because RFC 5545 can’t count from a completion date. `mt check` refuses `anchor: "completion"` on one. A task without a `due` date counts from today.
