# Packs

How a project adopts and tunes packs, how their rules merge, and the rules and parameters of the built-in packs.

A pack is a TOML file in config syntax that a project adopts by name: its rules, its priority framework, its views, whatever you’d otherwise copy around. Each project can still change any of it locally. [Configuration](https://mlavrinenko.github.io/mindtape/config/index.md) lists the `extends` and `disable` keys. This page covers how `mt` finds and merges a pack, and lists the rules of the built-in packs: `mindtape:tasks`, `mindtape:dogfood`, `mindtape:flow`, `mindtape:ice`, `mindtape:wip-caps`, `mindtape:budget`, `mindtape:tweaks` and `mindtape:commits`.

## Adopt a pack

`extends` in any [config layer](https://mlavrinenko.github.io/mindtape/config/index.md#layers) declares the packs that layer adopts. If the layer declares a rule with the same `name` as a pack’s rule, it replaces that rule where the pack put it. Mindtape’s own `.mindtape/config.toml` adopts `mindtape:tasks` and, after it, `mindtape:dogfood`, so a task can carry a Dogfood section. It adopts the other packs below too, `mindtape:budget` with `max-files` set to 5. It keeps only its own policy: the allowlist that names `Dogfood` and `Goals`, its goal check, its tag list, its actors, its path sets and its close gate:

```toml
# .mindtape/config.toml: the adoption, at the top of the file
extends = [
  { pack = "mindtape:tasks", with = { statefulness = true, examples = true } },
  "mindtape:dogfood",
  "mindtape:flow",
  "mindtape:ice",
  "mindtape:wip-caps",
  { pack = "mindtape:budget", with = { max-files = 5 } },
  "mindtape:tweaks",
  "mindtape:commits",
]

# .mindtape/config.toml: the project's own rule, which replaces both packs' allowlist and names Dogfood and Goals
[[tasks.body.headers.rules]]
name = "allow-only-declared-sections"
action = "allowlist"
allowed = [
  { match = "^(AS-IS|Environment|TO-BE|Source of truth|Changes|Alternatives|Rollback|Out of scope|Dogfood|Goals)$" },
]
when = "!terminal"
message = "limit an open task to AS-IS, TO-BE, Changes, Out of scope, Dogfood and Goals, plus its kind's own section"
```

A name replaces a rule only across sources. Two rules with one name in the same file are a config error, as [Configuration](https://mlavrinenko.github.io/mindtape/config/index.md) describes.

## Keys a pack may hold

Any config key, except seven. `extends` and `disable` belong to the project, so a pack can’t extend another pack and there’s only ever one level to resolve. `[pack-sources]` belongs to the project too, which keeps every source in one file. `project.code` is the project’s own name. `tasks.roots`, `templates.dirs` and `[typst]` point into the project’s own tree, which a shared file can’t know. `mt` refuses a pack that declares one of them and names the pack and the key:

```
$ head .mindtape/config.toml team.toml
==> .mindtape/config.toml <==
extends = ["./team.toml"]

==> team.toml <==
extends = ["mindtape:tasks"]

[[tasks.rules]]
name = "has-owner"
assert = "has(assignee)"
message = "name an owner"
$ mt check
error: .mindtape/config.toml:1: extends: pack 'team.toml' may not declare: 'extends'
```

`[params]` is the one key a pack has that a layer doesn’t. It declares the pack’s parameters, which `mt` writes into the pack’s expressions and never merges into the config.

## Pack sources

An `extends` entry with no `/` in it is `<source>:<pack>`. `mindtape` is the one source `mt` knows without a declaration. It holds the built-in packs listed above. `mt` refuses an unknown name and lists the packs that source has:

```
$ cat .mindtape/config.toml
extends = ["mindtape:task"]
$ mt check
error: .mindtape/config.toml:1: extends: unknown pack: 'mindtape:task'
hint: did you mean mindtape:tasks?
hint: use one of: mindtape:tasks, mindtape:wip-caps, mindtape:budget, mindtape:tweaks, mindtape:commits, mindtape:dogfood, mindtape:flow, mindtape:ice
```

An entry with a `/` is a path to a TOML file, like `./team.toml` above, or to a [folder](https://mlavrinenko.github.io/mindtape/packs/index.md#a-pack-in-a-directory). A path is relative to the directory two levels above the config file that names it. For `.mindtape/config.toml` that’s the project root. For the user layer `mindtape/defaults.toml` it’s your config directory, such as `~/.config` on Linux. `mt` refuses a missing file and prints the path it resolved.

> **Warning:** `"tasks.toml"` has no `/`, so `mt` reads it as a pack name, not a file, and refuses it as unknown. Write `"./tasks.toml"` for a file of that name.

## Packs from a git source

Your team’s packs can be in a git repository of their own. Declare it as `[pack-sources.<name>]` in the project’s `.mindtape/config.toml`, with `git` for the repository and `ref` for a tag, branch or commit, and adopt a pack from it as `<name>:<pack>`. A pack from a git source comes only from the project config. A clone then resolves the same packs on every machine. `mt` reserves the name `mindtape`.

`.mindtape/packs.lock` pins each source to the commit its `ref` named and a hash of the files there, and you commit it beside the config. Every command that reads the config checks the lock against the sources first. `mt` refuses a source the lock lacks, or one pinned from another `git` or `ref`, as here after a bump from `v1` to `v2`.

```
$ head .mindtape/config.toml .mindtape/packs.lock
==> .mindtape/config.toml <==
[pack-sources.acme]
git = "https://github.com/acme/mindtape-packs"
ref = "v2"

==> .mindtape/packs.lock <==
[acme]
git = "https://github.com/acme/mindtape-packs"
ref = "v1"
commit = "3f2c1a9e0b7d4c55e1a2b3c4d5e6f708192a3b4c"
sha256 = "9c41e0d2b7a35f8c6e1d4a9b0c2f7e3d5a8b1c4e7f0a3d6b9c2e5f8a1b4d7c0e"
$ mt check
error: pack source lock is stale: 'acme'
hint: run `mt packs update` to lock the sources as declared
```

`mt packs update` writes the lock. It asks the repository which commit each `ref` names, takes a 40- or 64-digit `ref` as the commit itself, fetches that tree and rewrites the source’s entry. Here it locks a source the lock lacked, from a repository beside the project:

```
$ cat .mindtape/config.toml
extends = ["acme:commits"]

[pack-sources.acme]
git = "../acme-packs.git"
ref = "v1"
$ mt packs update
acme v1: locked 53eca03
  + acme:commits
wrote .mindtape/packs.lock
```

Name sources, as in `mt packs update acme`, to move only those. A source whose `ref` still names the locked commit prints `up to date` and keeps its entry, and `mt` drops an entry that has no declaring source. Read the lock’s diff before you commit it, since the new commit is the config every clone gets.

Under each source it moves, `mt packs update` prints what the move changes, compared as parsed TOML. A reformatted pack reads as unchanged. Each line gives a pack, a key, a rule or another array entry, marked `+` for added, `~` for changed and `-` for removed. Every new `run` or `editor` line prints in full under its entry, and it still runs only once you `mt allow` it. Any other file of the source, such as a template or a check module, prints as `file <path>`. When your cache lacks the old tree, it fetches it by its commit from the old `git`, or from the new one if that fails. If both fail, it warns and lists the new tree as all added. Here the project bumps `ref` to `v2`, whose commit tightens a rule, gates a close on a `run` line and adds a pack:

```
$ mt packs update
acme v2: 53eca03 → 938e8a2
  ~ acme:commits
    ~ rule commits.rules.short-subject
    + on.flip.close-gate
        run "just check"
  + acme:ops
wrote .mindtape/packs.lock
```

`mt` reads a source’s packs from your cache directory, such as `~/.cache` on Linux, under `mindtape/packs/<sha256>/`, named by the lock’s hash. `acme:team` is `team.toml` at the top of that tree, or `team/pack.toml` for a [folder](https://mlavrinenko.github.io/mindtape/packs/index.md#a-pack-in-a-directory) pack. A pack name takes letters, digits, `-` and `_`. `MINDTAPE_CACHE_HOME` moves the cache, as [Configuration](https://mlavrinenko.github.io/mindtape/config/index.md#environment-variables) says.

Every load hashes the cached tree again and refuses one that doesn’t match the lock, naming its directory, so a file edited by hand there can’t slip in. It hashes each source once, however many of its packs you adopt. Every command computes that hash, so keep a pack source small: a repository that holds packs and nothing else. A pack from a source can only reference dictionary files inside the source’s tree. Only `mt packs` touches the network. Every other command refuses a source the cache lacks, with a hint to fetch it:

```
$ head .mindtape/config.toml .mindtape/packs.lock
==> .mindtape/config.toml <==
extends = ["acme:commits"]

[pack-sources.acme]
git = "https://github.com/acme/mindtape-packs"
ref = "v1"

==> .mindtape/packs.lock <==
[acme]
git = "https://github.com/acme/mindtape-packs"
ref = "v1"
commit = "3f2c1a9e0b7d4c55e1a2b3c4d5e6f708192a3b4c"
sha256 = "9c41e0d2b7a35f8c6e1d4a9b0c2f7e3d5a8b1c4e7f0a3d6b9c2e5f8a1b4d7c0e"
$ mt check
error: .mindtape/config.toml:1: extends: pack source not installed: 'acme'
hint: run `mt packs install` to fetch the locked sources
```

`mt packs install` fetches each locked source the cache lacks and refuses a tree that doesn’t hash to the lock. Like `npm ci`, it refuses a lock that disagrees with `[pack-sources]`, so a CI job or a fresh clone gets the packs you reviewed and nothing newer. Here an empty cache gets the locked tree, and a second run finds it there:

```
$ mt packs install
fetched acme 53eca03 into ~/.cache/mindtape/packs/77a26352181e8548692fbad04992f2f8ae65b657d7d87b523ccf207dfac1b909
$ mt packs install
1 source up to date
```

In CI, run `mt packs install && mt check`.

## A pack in a directory

A pack with files needs a folder. Name the folder in `extends`, and `mt` reads `pack.toml` inside it. The folder’s `templates/` joins `[templates] dirs` behind your own directories, so `mt add -t feat` finds a template the pack provides, and a template of yours with the same name wins. `mt templates` lists both:

```
$ find team -type f
team/templates/feat.typ
team/pack.toml
$ mt templates
feat  kind: any  7 slots
task  kind: any  1 slot    default
```

The folder can sit anywhere, inside the project or not. When two packs include a template with one name, the pack of the later layer wins, and within a layer the one listed last. If a `team.toml` sits beside a `team/` folder, `extends = ["./team"]` could mean either, so `mt` refuses it and names both:

```
$ find team team.toml
team
team/pack.toml
team.toml
$ mt check
error: .mindtape/config.toml:1: extends: ambiguous pack: 'team' is a directory beside 'team.toml'
hint: name the file with its .toml extension, or rename one of them
```

Write `"./team.toml"` to read the file.

## Files a pack names

A pack can name files of its own: a rule’s Typst `check`, or a [dictionary](https://mlavrinenko.github.io/mindtape/named-sets/index.md) `path`. Both resolve from the pack’s directory, which is the folder of a directory pack, or the one holding a pack file. So a pack in `team/` finds `team/check.typ` and `team/words.txt` wherever the project is, with nothing copied across.

A pack’s check file runs in a Typst world rooted at that directory. It imports the pack’s other files and `@local` packages, and it can’t import a file of the project. So `mt` refuses a `check` path that leaves the pack’s directory. A rule and a dictionary that the project declares resolve from the project root, and so does a rule that replaces a pack’s rule by name. The built-in packs don’t reference any files.

## Drop a rule

To turn off a rule you don’t want, list its name in `disable`. It drops the rule or collector from any of the eight arrays, whichever pack or layer declared it, a named [flip, add or rm hook](https://mlavrinenko.github.io/mindtape/hooks/index.md) included. A name that matches no rule is a config error, so a typo can’t leave a rule running:

```
$ cat .mindtape/config.toml
extends = ["mindtape:tasks"]
disable = ["imperative-titles"]
$ mt check
error: .mindtape/config.toml:2: disable: no rule named: 'imperative-titles'
```

## Set a pack’s parameters

A pack can leave a number open for each project to pick. It declares the value with a default in `[params]`, and its expressions read it as `param("name")`. A project sets its own value in the `extends` entry with `with`, and still gets every later fix to the rule. Here the pack caps a task at 5 files and the project raises the cap to 8:

```
$ head .mindtape/config.toml team.toml
==> .mindtape/config.toml <==
extends = [{ pack = "./team.toml", with = { max-files = 8 } }]

==> team.toml <==
[params]
max-files = 5

[[tasks.rules]]
name = "small"
assert = 'estimate.src-files <= param("max-files")'
$ mt config show --json | jq -r '.config.tasks.rules[] | select(.name == "small") | .assert'
estimate.src-files <= 8
```

`mt` writes each value into the pack’s expressions when it loads the config, so `mt check` and `mt config show` both see `8`. It works in every expression in the pack, from a rule’s `when` and `assert` to a view’s `filter`, an `[[on.flip]]` `when` or `list`, an `[[on.add]]` `when`, each `required` and the `[ls]` and `[rm]` filters. A `param()` inside a string literal stays as written, and so does one in a rule’s `message`, which is text and no expression. A bare entry like `"./team.toml"` keeps every default.

A value is a string, a number or a boolean, of the same type as its default. The parameters belong to their pack, so two packs can each have a `max-files`. `mt` refuses a `with` key the pack doesn’t declare and suggests the nearest one:

```
$ head .mindtape/config.toml team.toml
==> .mindtape/config.toml <==
extends = [{ pack = "./team.toml", with = { max-file = 8 } }]

==> team.toml <==
[params]
max-files = 5
$ mt check
error: .mindtape/config.toml:1: extends: pack 'team.toml' has no parameter: 'max-file'
hint: did you mean max-files?
hint: use one of: max-files
```

It also refuses a value of another type than the default. It refuses a `param()` that doesn’t specify a parameter, and one pack listed twice in one `extends`, even by two paths to the same file. `mt` also refuses a `param()` in a layer’s own expression, since only a pack has parameters.

## A mistake in a pack

An error points at the file that contains the mistake, with the line, so you open the pack and not your own config. That goes for a path pack, a directory pack, a source’s pack and the `defaults.toml` of a parent folder alike. An unknown key:

```
$ head .mindtape/config.toml team.toml
==> .mindtape/config.toml <==
extends = ["./team.toml"]

==> team.toml <==
[views.board]
filter = "has(title)"

[projet]
name = "app"
$ mt check
error: team.toml:4:2: can't parse config: unknown field `projet`, expected one of `project`, `tasks`, `ls`, `rm`, `retire`, `templates`, `add`, `go`, `typst`, `format`, `views`, `dicts`, `commits`, `on`, `actors`, `roles`, `extends`, `disable`, `pack-sources`
```

And a value that doesn’t pass its check:

```
$ head .mindtape/config.toml team.toml
==> .mindtape/config.toml <==
extends = ["./team.toml"]

[views.mine]
filter = "has(title)"

==> team.toml <==
[views.board]
filter = "(("
$ mt check
error: team.toml:2: views.board.filter: failed to parse filter: a '(' is never closed
```

A problem that only the merge causes, with no one file to blame, leads with the key alone.

## Merge order

`mt` merges each config layer, and each layer’s packs merge just below it. Tables merge key by key, and an array or a scalar replaces the value under it whole, the same as between two layers. So a project’s `[tasks.priority]` keeps the framework a pack picked, and the floor fills in what neither sets:

```
$ head .mindtape/config.toml team.toml
==> .mindtape/config.toml <==
extends = ["./team.toml"]

[tasks.priority]
allow-manual = true

==> team.toml <==
[tasks.priority]
framework = "ice"
allow-manual = false
$ mt config show --json | jq -c '.config.tasks.priority | {framework, "allow-manual", min, max}'
{"framework":"ice","allow-manual":true,"min":0,"max":9}
```

A pack beats every layer below the one adopting it, and that layer beats the pack. A [dictionary](https://mlavrinenko.github.io/mindtape/named-sets/index.md) merges the same way, key by key.

Two packs in one `extends` that set one value differently are an error, since nothing would say which one the project got. `mt` names the key and both packs:

```
$ head .mindtape/config.toml team.toml ops.toml
==> .mindtape/config.toml <==
extends = ["./team.toml", "./ops.toml"]

==> team.toml <==
[tasks.priority]
framework = "ice"

==> ops.toml <==
[tasks.priority]
framework = "rice"
$ mt check
error: .mindtape/config.toml:1: extends: packs 'team.toml' and 'ops.toml' set different values for: 'tasks.priority.framework'
hint: set the key in the config that extends both packs to pick one
```

Set that key in the layer that adopts both packs and the clash disappears, since the layer’s value wins anyway. Equal values agree, so two packs can both set the same dictionary. Packs adopted by two different layers never clash: the higher layer wins.

Eight arrays merge by name instead: `[[tasks.rules]]`, the two body rule arrays, `[[commits.rules]]`, `[[on.flip]]`, `[[on.add]]`, `[[on.rm]]` and `[[tasks.collectors]]`. Each takes the entries of the layer’s packs in `extends` order, then the layer’s own, and an entry replaces an earlier one with the same `name` in its place. A flip, add or rm hook with no `name` appends and nothing can replace it, so a pack’s hook that the project should be able to change needs one. After every layer merges, `mt` drops the rules named in any layer’s `disable`. `mt` drops a name listed in two layers once.

## Read `mt config show --origin`

To see where each rule, key and parameter came from, run `mt config show
--origin`. It prints the layers that contributed, then one line per rule in merge order: `rule <label>: <origin>`. `<label>` is the rule’s array and name, such as `tasks.rules.<name>`, `on.flip.<name>` or `on.add.<name>`, or `tasks.rules[<index>]` for a rule with no name. An unnamed add hook reads `on.add[<index>]`. `mt check` names a broken rule without the leading `tasks.`. `<origin>` is a layer (`embedded`, `xdg`, `dir` or `project`), or `pack <name>` for a pack. The output in the Mindtape repository:

```
$ mt config show --origin
embedded: <built-in>
project: .mindtape/config.toml (exists)

rule tasks.rules.tag-task-stateful-or-stateless: pack mindtape:tasks
rule tasks.rules.start-title-with-verb: pack mindtape:tasks
rule tasks.rules.keep-one-milestone-in-progress: pack mindtape:wip-caps
rule tasks.rules.keep-one-task-in-progress: pack mindtape:wip-caps
rule tasks.rules.cap-judgment-work-at-max-source-files: pack mindtape:budget
rule tasks.rules.keep-work-inside-changes-plan: pack mindtape:budget
rule tasks.rules.file-tweak-done: pack mindtape:tweaks
rule tasks.rules.give-every-goal-verdict: project
rule tasks.rules.file-tasks-by-month: project
rule tasks.rules.sweeps-live-in-their-folder: project
rule tasks.rules.link-finding-to-what-surfaced-it: project
rule tasks.body.headers.rules.allow-only-declared-sections: project
rule tasks.body.headers.rules.require-environment-for-fix: pack mindtape:tasks
rule tasks.body.headers.rules.require-alternatives-for-design: pack mindtape:tasks
rule tasks.body.headers.rules.require-source-of-truth-for-docs: pack mindtape:tasks
rule tasks.body.headers.rules.require-rollback-for-stateful-change: pack mindtape:tasks
rule tasks.body.headers.rules.allow-environment-only-for-fix: pack mindtape:tasks
rule tasks.body.headers.rules.allow-alternatives-only-for-design: pack mindtape:tasks
rule tasks.body.headers.rules.allow-source-of-truth-only-for-docs: pack mindtape:tasks
rule tasks.body.headers.rules.allow-rollback-only-for-stateful-change: pack mindtape:tasks
rule tasks.body.headers.rules.put-environment-after-as-is: pack mindtape:tasks
rule tasks.body.headers.rules.put-to-be-after-as-is: pack mindtape:tasks
rule tasks.body.headers.rules.put-source-of-truth-after-to-be: pack mindtape:tasks
rule tasks.body.headers.rules.put-changes-after-to-be: pack mindtape:tasks
rule tasks.body.headers.rules.put-changes-after-source-of-truth: pack mindtape:tasks
rule tasks.body.headers.rules.put-alternatives-after-changes: pack mindtape:tasks
rule tasks.body.headers.rules.put-rollback-after-changes: pack mindtape:tasks
rule tasks.body.headers.rules.put-out-of-scope-after-changes: pack mindtape:tasks
rule tasks.body.headers.rules.put-out-of-scope-after-alternatives: pack mindtape:tasks
rule tasks.body.headers.rules.put-out-of-scope-after-rollback: pack mindtape:tasks
rule tasks.body.headers.rules.keep-one-as-is-section: pack mindtape:tasks
rule tasks.body.headers.rules.keep-one-to-be-section: pack mindtape:tasks
rule tasks.body.headers.rules.keep-one-changes-section: pack mindtape:tasks
rule tasks.body.headers.rules.keep-one-out-of-scope-section: pack mindtape:tasks
rule tasks.body.headers.rules.keep-sections-flat: pack mindtape:tasks
rule tasks.body.headers.rules.keep-one-dogfood-section: pack mindtape:dogfood
rule tasks.body.headers.rules.put-dogfood-after-out-of-scope: pack mindtape:dogfood
rule tasks.body.headers.rules.keep-one-goals-section: project
rule tasks.body.headers.rules.put-goals-after-dogfood: project
rule tasks.body.content.rules.write-as-is-as-numbered-steps: pack mindtape:tasks
rule tasks.body.content.rules.open-as-is-with-the-essence: pack mindtape:tasks
rule tasks.body.content.rules.mark-defect-step-with-red: pack mindtape:tasks
rule tasks.body.content.rules.add-fenced-repro-to-as-is: pack mindtape:tasks
rule tasks.body.content.rules.open-to-be-bullet-with-green: pack mindtape:tasks
rule tasks.body.content.rules.open-every-to-be-bullet-with-green: pack mindtape:tasks
rule tasks.body.content.rules.add-fenced-example-to-to-be: pack mindtape:tasks
rule tasks.body.content.rules.name-path-in-changes: pack mindtape:tasks
rule tasks.body.content.rules.start-every-changes-bullet-with-path: pack mindtape:tasks
rule tasks.body.content.rules.write-changes-plan: pack mindtape:tasks
rule tasks.body.content.rules.leave-no-listed-section-empty: pack mindtape:tasks
rule tasks.body.content.rules.write-as-is-section: pack mindtape:tasks
rule tasks.body.content.rules.cap-every-listed-section-at-120-words: pack mindtape:tasks
rule tasks.body.content.rules.cap-as-is-at-120-words: pack mindtape:tasks
rule tasks.body.content.rules.cap-changes-at-220-words: pack mindtape:tasks
rule tasks.body.content.rules.show-proposed-shape-when-gating: pack mindtape:tasks
rule tasks.body.content.rules.keep-at-most-one-em-dash-per-paragraph: pack mindtape:tasks
rule tasks.body.content.rules.leave-no-question-open: pack mindtape:tasks
rule tasks.body.content.rules.write-dogfood-section: pack mindtape:dogfood
rule tasks.body.content.rules.cap-dogfood-at-120-words: pack mindtape:dogfood
rule tasks.body.content.rules.write-goals-section: project
rule tasks.body.content.rules.cap-goals-at-160-words: project
rule commits.rules.name-task-in-refs-trailer: project
rule commits.rules.squash-every-autosquash-commit: pack mindtape:tasks
rule commits.rules.flip-task-with-its-work: pack mindtape:tasks
rule commits.rules.finish-named-task-at-tip: pack mindtape:tasks
rule commits.rules.keep-tweak-to-one-source-file: pack mindtape:tweaks
rule commits.rules.add-changelog-entry-for-product-change: pack mindtape:commits
rule commits.rules.start-named-task-in-its-commit: pack mindtape:commits
rule on.flip.review-stale-task-before-starting: pack mindtape:flow
rule on.flip.close-only-on-fresh-gate: project
rule on.flip.refresh-the-task-arms: project
rule on.add.file-by-month: project
rule on.add.sweeps: project
key dicts.product.case: project
key dicts.product.values: project
key dicts.source.case: project
key dicts.source.values: project
key dicts.verbs.include: pack mindtape:tasks
key tasks.comments.policy: pack mindtape:tasks
key tasks.estimate.units: pack mindtape:budget
key tasks.fields.kind.example: pack mindtape:tasks
key tasks.fields.kind.required: pack mindtape:tasks
key tasks.fields.kind.values: pack mindtape:tasks
key tasks.priority.allow-manual: pack mindtape:ice
key tasks.priority.example: pack mindtape:ice
key tasks.priority.framework: pack mindtape:ice
key tasks.priority.required: pack mindtape:ice
key tasks.status: pack mindtape:flow
param examples = true: project, for pack mindtape:tasks
param statefulness = true: project, for pack mindtape:tasks
param days = 30: default, for pack mindtape:flow
param leaves = 1: default, for pack mindtape:wip-caps
param milestones = 1: default, for pack mindtape:wip-caps
param max-files = 5: project, for pack mindtape:budget
param min-difficulty = 3: default, for pack mindtape:budget
```

Every rule from a pack reads `pack <name>`: the two caps read `pack mindtape:wip-caps`, `cap-judgment-work-at-max-source-files` and `keep-work-inside-changes-plan` read `pack mindtape:budget`, `file-tweak-done` reads `pack mindtape:tweaks`, and the rest of the task rules read `pack mindtape:tasks`. The exception is the Dogfood rules, which read `pack mindtape:dogfood`. The `review-stale-task-before-starting` hook reads `pack mindtape:flow`. The repository’s own rules read `project`: the allowlist, the goal check and its warning, the month and finding rules, the four `Goals` rules, and the `close-only-on-fresh-gate` hook. Keys that aren’t rules read the same way, such as `key tasks.status` for `pack mindtape:flow`. To read each rule’s severity and message as well, run [`mt config show --resolved`](https://mlavrinenko.github.io/mindtape/cli/config/index.md).

After the rules come the other keys a pack set, as `key <dotted path>:
<origin>`, and the parameters packs declare, as `param <name> = <value>: <set
by>, for pack <pack>`. A key reports the layer instead of the pack when the layer replaced the value, as `dicts.product.values` shows. `<set by>` is the layer whose `with` set the parameter, such as `project` for `max-files`, or `default` for a parameter no one set.

When `mt` reports a problem with a rule itself, not with a task, it points at the rule’s own `[[tasks.rules]]` header, whichever layer or pack declared it. That’s a file and line for a layer or a path pack, and `pack <name>:<line>` for a built-in pack. `mt check` reports a rule skipped for lack of git this way.

## The rules in `mindtape:tasks`

`extends = ["mindtape:tasks"]` gives you the task shape Mindtape’s own backlog uses. Each open task has four sections in order: `AS-IS`, `TO-BE`, Changes and Out of scope. A `fix` adds Environment, a `feat` or a `decision` adds Alternatives, a `docs` task adds Source of truth, and a task tagged `stateful` adds Rollback. The pack also declares the `kind` field the rules read, with `feat`, `fix`, `refactor`, `docs`, `test`, `dev`, `decision` and `milestone`. It requires the field of an open task and rejects a comment in a task file. The `statefulness` and `examples` parameters, both off, gate the tag rule and the two fenced-example rules. A project turns them on in `with`. The tables below come from [the pack file](https://github.com/mlavrinenko/mindtape/blob/main/crates/mindtape/src/packs/tasks.toml), and each message is the text `mt check` prints. The `start-title-with-verb` rule reads the `verbs` dictionary, which the pack builds from the two word lists `mt` provides.

### Task rules

| Rule | When | Message |
| --- | --- | --- |
| `tag-task-stateful-or-stateless` | `!terminal && param("statefulness") && kind != "decision"` | tag the task \`stateful\` or \`stateless\`, so the Rollback rule knows which applies |
| `start-title-with-verb` | `!terminal` | start the title with an imperative verb |

### Section rules

| Rule | When | Message |
| --- | --- | --- |
| `allow-only-declared-sections` | `!terminal` | limit an open task to AS-IS, TO-BE, Changes and Out of scope, plus its kind's own section |
| `require-environment-for-fix` | `!terminal && kind == "fix"` | add one Environment section saying where the AS-IS reproduces |
| `require-alternatives-for-design` | `!terminal && (kind == "feat" || kind == "decision")` | add one Alternatives section naming the designs you rejected |
| `require-source-of-truth-for-docs` | `!terminal && kind == "docs"` | add one Source of truth section naming what the prose must match |
| `require-rollback-for-stateful-change` | `!terminal && has_tag("stateful")` | add one Rollback section saying how to undo the change |
| `allow-environment-only-for-fix` | `!terminal && kind != "fix"` | remove the Environment section; only fix tasks have one |
| `allow-alternatives-only-for-design` | `!terminal && kind != "feat" && kind != "decision"` | remove the Alternatives section; only feat and decision tasks have one |
| `allow-source-of-truth-only-for-docs` | `!terminal && kind != "docs"` | remove the Source of truth section; only docs tasks have one |
| `allow-rollback-only-for-stateful-change` | `!terminal && !has_tag("stateful")` | remove the Rollback section; only a stateful task has one |
| `put-environment-after-as-is` | `!terminal` | move Environment after AS-IS |
| `put-to-be-after-as-is` | `!terminal` | move TO-BE after AS-IS |
| `put-source-of-truth-after-to-be` | `!terminal` | move Source of truth after TO-BE |
| `put-changes-after-to-be` | `!terminal` | move Changes after TO-BE |
| `put-changes-after-source-of-truth` | `!terminal` | move Changes after Source of truth |
| `put-alternatives-after-changes` | `!terminal` | move Alternatives after Changes |
| `put-rollback-after-changes` | `!terminal` | move Rollback after Changes |
| `put-out-of-scope-after-changes` | `!terminal` | move Out of scope after Changes |
| `put-out-of-scope-after-alternatives` | `!terminal` | move Out of scope after Alternatives |
| `put-out-of-scope-after-rollback` | `!terminal` | move Out of scope after Rollback |
| `keep-one-as-is-section` | `!terminal` | keep exactly one AS-IS section |
| `keep-one-to-be-section` | `!terminal` | keep exactly one TO-BE section |
| `keep-one-changes-section` | `!terminal` | keep exactly one Changes section |
| `keep-one-out-of-scope-section` | `!terminal` | keep exactly one Out of scope section |
| `keep-sections-flat` | `!terminal` | remove the subsections, or split the task; a section takes none |

### Content rules

| Rule | When | Message |
| --- | --- | --- |
| `write-as-is-as-numbered-steps` | `!terminal` | write AS-IS as numbered steps anyone can follow |
| `open-as-is-with-the-essence` | `!terminal` | open AS-IS with one plain line that carries the essence, then the numbered steps |
| `mark-defect-step-with-red` | `!terminal` | open the step that shows the defect with 🔴 |
| `add-fenced-repro-to-as-is` | `!terminal && param("examples") && kind == "fix" && !has_tag("no-repro")` | show the bug in one fenced block you can run, or tag the task \`no-repro\` |
| `open-to-be-bullet-with-green` | `!terminal` | say how it should work as bullets opening with 🟢 |
| `open-every-to-be-bullet-with-green` | `!terminal` | open every TO-BE bullet with 🟢 |
| `add-fenced-example-to-to-be` | `!terminal && param("examples") && (kind == "feat" || kind == "fix" || kind == "dev") && !has_tag("no-ui-ux")` | show the proposed shape in a fenced example, or tag the task \`no-ui-ux\` |
| `name-path-in-changes` | `!terminal` | list Changes as bullets naming the \`path\` each one touches |
| `start-every-changes-bullet-with-path` | `!terminal` | start every Changes bullet with one backticked path, then what changes there |
| `write-changes-plan` | `!terminal` | write the plan under Changes, one backticked path per bullet |
| `leave-no-listed-section-empty` | `!terminal` | write what belongs under the heading, or why nothing does, or remove it |
| `write-as-is-section` | `!terminal` | write the state the change starts from, or remove the section |
| `cap-every-listed-section-at-120-words` | `!terminal` | cut this section to under 120 words, or split the task in two |
| `cap-as-is-at-120-words` | `!terminal` | cut this section to under 120 words, or split the task in two |
| `cap-changes-at-220-words` | `!terminal` | cut this section to under 220 words, or split the task in two |
| `show-proposed-shape-when-gating` | `has_tag("gating") && !terminal` | show the proposed config shape in a block |
| `keep-at-most-one-em-dash-per-paragraph` | `!terminal` | keep one em dash per paragraph at most; use a comma, a colon or a second sentence for the rest |
| `leave-no-question-open` | `!terminal` | ask the user and write the answer in, since a task leaves no question open |

### Commit rules

These run on a commit from `mt check --commit-msg` and on a range from `mt check --commits`. See [Commit rules](https://mlavrinenko.github.io/mindtape/commit-rules/index.md).

| Rule | When | Message |
| --- | --- | --- |
| `name-task-in-refs-trailer` | `!tasks_only && !matches(subject, "^(fixup|squash|amend)! ")` | name the task this commit works on in a \`Refs: \<stem\>\` footer |
| `squash-every-autosquash-commit` | `in_range` | squash this commit first: git rebase -i --autosquash \<target\> |
| `flip-task-with-its-work` | `into("wip") || into("done")` | start or close a task in a commit that carries its work; a task with no work closes as \`decision\` or \`milestone\` |
| `finish-named-task-at-tip` | always | run \`mt done \<stem\>\` and commit it with the task's last work |

## The rules in `mindtape:wip-caps`

`extends = ["mindtape:wip-caps"]` keeps one milestone and one other task open at a time. Both rules are errors, so `mt` refuses a flip that would open a second one. Each cap is a parameter, read from [the pack file](https://github.com/mlavrinenko/mindtape/blob/main/crates/mindtape/src/packs/wip-caps.toml):

| Parameter | Default | Meaning |
| --- | --- | --- |
| `milestones` | `1` | How many milestones may be \`wip\` at once. |
| `leaves` | `1` | How many tasks that aren't milestones may be \`wip\` at once. |

| Rule | When | Message |
| --- | --- | --- |
| `keep-one-milestone-in-progress` | `status == "wip" && kind == "milestone"` | close or split the open milestone before opening another |
| `keep-one-task-in-progress` | `status == "wip" && kind != "milestone"` | finish the open task, or split off what is done and close that, before starting another |

## The rules in `mindtape:budget`

`extends = ["mindtape:budget"]` caps a task’s size at the number of source files its Changes section names. A `changes` collector reads the first backticked path on every bullet, so `derived.changes` is a list of paths, and a glob counts once. `cap-judgment-work-at-max-source-files` refuses an open task of judgment work whose Changes section names more than `max-files` source files. A milestone is exempt. `keep-work-inside-changes-plan` warns when the working tree has changed more files than the task in progress plans.

| Parameter | Default | Meaning |
| --- | --- | --- |
| `max-files` | `5` | The most source files a judgment task may plan. |
| `min-difficulty` | `3` | The lowest difficulty that counts as judgment work. |

| Rule | When | Message |
| --- | --- | --- |
| `cap-judgment-work-at-max-source-files` | `!terminal && kind != "milestone" && difficulty >= param("min-difficulty")` | split the decision from the mechanical fan-out instead of widening the cap |
| `keep-work-inside-changes-plan` | `status == "wip"` | move work not yet written into a new task; what is already written ships with this one, so closing it needs no split |

The pack also sets `[tasks.estimate] units = ["src-files"]`, which keeps a task filed with an `estimate.src-files` valid, and a `[dicts.source]` of `**`, which counts every file. An array replaces it, so a `[dicts.source]` of yours with `!` globs for docs and generated files replaces the pack’s `**`, as Mindtape’s own does. A parameter reaches expressions only, never the unit, so a project that sizes in `files` overrides both rules by name.

## The rules in `mindtape:tweaks`

A tweak is a change too small to plan: `mt add -t tweak` files it done, in the commit that makes the change. `extends = ["mindtape:tweaks"]` enforces that on a project. `file-tweak-done` refuses a tweak that isn’t terminal, and `keep-tweak-to-one-source-file` refuses a commit that closes a tweak and changes more than one file of the `source` path set. The pack leaves the `tweak` tag to the project: list it in `[tasks.tags]` if that table limits the tags. It sets `[dicts.source]` to `**`, the same as `mindtape:budget`. A project can adopt both, and the two agree. Your own `[dicts.source]` replaces it for both.

| Rule | When | Message |
| --- | --- | --- |
| `file-tweak-done` | `has_tag("tweak")` | file a tweak done, in the commit that makes the change: \`mt add -t tweak\`; plan anything bigger with another template |

| Rule | When | Message |
| --- | --- | --- |
| `keep-tweak-to-one-source-file` | `into("done") && staged(has_tag("tweak"))` | file a planned task for the rest, since a tweak changes one source file |

## The rules in `mindtape:commits`

`extends = ["mindtape:commits"]` applies two rules to each commit, and both are [commit rules](https://mlavrinenko.github.io/mindtape/commit-rules/index.md). `add-changelog-entry-for-product-change` asks a commit that changes a file of the `product` path set for a `CHANGELOG.md` entry. A `Changelog: none` trailer says there’s nothing to announce, and a `fixup!`, `squash!` or `amend!` subject is exempt, since autosquash folds it into a commit that has one. `start-named-task-in-its-commit` refuses a commit whose `Refs:` task isn’t `wip` or terminal in the staged tree.

The pack sets `[dicts.product]` to `**`. Every file counts as product. Replace it with your own `[dicts.product]`, such as `crates/**` and `!**/*_tests.rs`, to say what reaches a user. A project that keeps its changelog elsewhere overrides the rule by name.

| Rule | When | Message |
| --- | --- | --- |
| `add-changelog-entry-for-product-change` | `count(files, "@product") >= 1 && !matches(subject, "^(fixup|squash|amend)! ") && !matches(trailers, "(?i)^Changelog: none$")` | add an entry under \[Unreleased\] in CHANGELOG.md, or add a \`Changelog: none\` trailer |
| `start-named-task-in-its-commit` | `named && staged(exists)` | flip the task to wip in the first commit that names it (\`mt wip \<stem\>\`, staged with the work) |

## The rules in `mindtape:dogfood`

A project that builds with its own tool can ask each task how it will use the change itself. `extends = ["mindtape:tasks", "mindtape:dogfood"]` adds a Dogfood section after Out of scope. It must exist once, contain something (“Not applicable” and a reason counts) and stay under 120 words. List it after `mindtape:tasks`, since its `allow-only-declared-sections` replaces that pack’s rule of the same name, with `Dogfood` allowed, and a test keeps the two lists one name apart.

| Rule | When | Message |
| --- | --- | --- |
| `allow-only-declared-sections` | `!terminal` | limit an open task to AS-IS, TO-BE, Changes, Out of scope and Dogfood, plus its kind's own section |
| `keep-one-dogfood-section` | `!terminal` | add one Dogfood section saying how this repo will dogfood the task ("Not applicable" with a reason opts out) |
| `put-dogfood-after-out-of-scope` | `!terminal` | move Dogfood after Out of scope |

| Rule | When | Message |
| --- | --- | --- |
| `write-dogfood-section` | `!terminal` | write how this repo uses the change under Dogfood, or "Not applicable" and why |
| `cap-dogfood-at-120-words` | `!terminal` | cut this section to under 120 words, or split the task in two |

## The rules in `mindtape:flow`

`extends = ["mindtape:flow"]` gives you the six statuses of the floor, with the moves between them. A task goes `proposed`, `accepted`, `wip`, then `done`, `cancelled` or `failed`, and a closed task reopens into `wip`. `wip` and `done` refuse a task whose `depends-on` target lacks a terminal status. The pack also adds the `review-stale-task-before-starting` hook, which refuses to start a task untouched for `days` days until `mt review` stamps it. The default is 30 days.

| Parameter | Default | Meaning |
| --- | --- | --- |
| `days` | `30` | How many days a task may sit untouched before mt refuses to start it. |

| Status | Moves to | Blocked by an open dependency |
| --- | --- | --- |
| `proposed` | `accepted`, `wip`, `cancelled` | no |
| `accepted` | `wip`, `cancelled` | no |
| `wip` | `done`, `failed`, `accepted` | yes |
| `done` | `wip`, `cancelled`, `failed` | yes |
| `cancelled` | nothing | no |
| `failed` | `wip` | no |

A `[[tasks.status]]` of yours replaces the legend whole. The hook names `wip`, so a legend with no `wip` is a config error until you list `review-stale-task-before-starting` in `disable`. The pack leaves a close gate to the project: it would run a tool your project may lack. See [Hooks](https://mlavrinenko.github.io/mindtape/hooks/index.md) for writing one.

## The rules in `mindtape:ice`

`extends = ["mindtape:ice"]` scores priority with the ICE framework. It sets `framework = "ice"`, `allow-manual = false`, `required = "!terminal"` and `example = 3` under `[tasks.priority]`. An open task then calls `ice(...)`. `mt` refuses a raw number. The pack sets only those keys. The default 0 to 9 scale and its three bands show through, and a `[[tasks.priority.bands]]` of yours replaces them. See [Priority](https://mlavrinenko.github.io/mindtape/priority/index.md) for the frameworks.
