# The plan contract

jackherd reads a plan from its Markdown. This is what a plan has to hold for the readers to find it, and how to check that with one command.

## The parts

| Part | Form | Required | Read by |
| ---- | ---- | -------- | ------- |
| Phases | a heading per phase: `### Phase 1: Title` (also `## 1 — Title` or `## P1 — Title`) | yes | herd, watcher, `jh check`, lane start |
| Tasks | at least one checkbox (`- [ ]`, `- [x]`) or a ✅/⬜ table row in every phase; a phase that points at a section (``See `## Documentation` ``) counts that section's checkboxes | yes | herd (progress), watcher, `jh check` |
| Model | a table under `### Model recommendations per phase`: the phase in the first cell (`1 — Title`, `P1`, `10c`), the model in the second (`claude-opus-5-5`, `Opus 5.5`); a dash marks a phase that needs no model | yes | lane start (the model a lane runs on), `/implement` |
| Dependencies | a table under `### Dependencies and parallelization` with the columns `Depends on`, `Writes`, `Serial marker`, an optional `PR` column and one row per phase | from two phases on, optional | `jh check --parallel`, `/implement` |
| Pull requests | the `PR` column of the dependency table: one abbreviation per phase (`A`, `B`); phases with the same abbreviation go into one pull request, an empty cell or a dash means a pull request of its own | no, a note from three phases on | `jh check --parallel`, `jh plan check`, `/implement` |
| Head | a section `## For you` (de: `## Für dich`) right after the header lines (`**Date:**`, `**Status:**`, `**Scope:**`), before the first other `##` section, with five lines `- **<label>:** <text>` | no, a note | `jh plan check`, the reader who is not an agent |
| Purpose | directly under every `### Phase` heading, one line `**What it is about:** <sentence>` (de: `**Worum es geht:** <Satz>`): what is different afterwards, for whom | no, a note | `jh plan check`, `jh check` (new phases), the herd |

Details that decide a verdict:

- A sub-phase (`3b`) is covered by the row of its base phase (`3`) in the model and the dependency table, or by a row of its own.
- A model cell that names no model and is no dash is a gap: the lane would start on a guess.
- With fewer than two phases the dependency part is reported `present` ("not needed"), never missing.
- With two or more phases and no dependency table the plan is still valid: the phases run one after another. A table that is there but lacks a row for a phase is a gap.
- The `PR` column is read in lower case without a note in parentheses (`A (release)` is `a`). Two phases with the same abbreviation are one pull request: `jh check --parallel` no longer keeps them apart over a release marker for one package, nor over the files a pull request writes once (`package.json`, `CHANGELOG.md`, `index.ts`, `index.tsx`, `index.js`); a lock file, a shared directory and a shared serial marker still do. A plan without the column runs as before, every phase a pull request of its own.
- The `pull-requests` part is a note and never changes the exit code. It is `present` ("not needed") with fewer than three phases or without a dependency table, `missing` from three phases on when the table has no `PR` column, and `stale` at the heading of a phase whose serial marker is a `Migration` that shares its pull request with another phase: the question is whether the migration has to be live before or after the code; one that only adds, with its single user in the pull request, may ride along.
- The head's five labels are fixed per language. English: `What changes for you`, `Status`, `Your open decisions`, `Try it now`, `Next step`; German: `Was sich für dich ändert`, `Stand`, `Deine offenen Entscheidungen`, `Schon ausprobieren`, `Nächster Schritt`. The colon may stand outside the bold (`**Status**:`) and the list mark may be left out.
- The `Status` line carries `Phase x/y`: x the id of the first phase with an open checkbox, as its heading spells it (`3`, `3a`), y the number of phases, each id counted once. When every phase is done, x is the id of the last one.
- The head is `missing` without the section. It is `stale` when it stands behind another section, lacks a line, has no `Phase x/y`, or names another phase or phase count than the checkboxes show. Both are notes: the contract stays met and the exit code does not change, so plans written before the head keep passing.
- The purpose line counts when it is the first non-empty line under a `### Phase` heading and has text after the colon; the colon may stand outside the bold or be left out. A line behind the origin line does not count. Only `### Phase` headings are read; phases headed `## 1 — …` or `## P1 — …` and the closing `## N — …` section are not. `purpose` is `missing` (`no purpose line in P2, P3`) when a phase with checkboxes of its own lacks the line (a phase that only points at a section needs none); it is a note and the exit code does not change, so older plans keep passing. `jh check` goes further for a phase the change adds: it fails without the line; phases the plan already had are not read.
- The headings are shown in English here; a plan or board is read in German as well, and in any other language by markers (see below).

## Language and markers

jackherd reads boards and plans in every language it has words for (English and German), whatever `.jackherd/config.json` says: a German board next to an English plan works, and so does the other way round. The configuration decides only what jh **writes**:

| Key | Decides | Default |
| --- | ------- | ------- |
| `planLanguage` | the language of new plans and of the plan templates | `en` |
| `boardLanguage` | the language jh writes the board in: history lines, lane rows, waiting rows | the value of `planLanguage` |

A config without `boardLanguage` runs as before. A heading, column name or status word is looked up in this order: the marker, the word of the configured language, the word of the other language.

A document in a language jackherd has no words for carries a **marker**, `<!-- jh: <key> -->`, which Markdown does not show. The key comes from a closed set; an unknown key is ignored.

| Where the marker stands | Keys |
| ----------------------- | ---- |
| on the line directly under a `##` (or `###`) heading | `waiting`, `appointments`, `lanes`, `goal`, `history`, `plans`, `decisions`, `implementation`, `model`, `dependencies`, `documentation`, `for-you`, `next` |
| in a header cell of a table | `since`, `item`, `origin`, `unblocks`, `status`, `when`, `action`, `depends-on`, `writes`, `serial-marker`, `pull-request` |
| on a line of the head | `head-changes`, `head-status`, `head-decisions`, `head-try-now`, `head-next` |
| in a status cell | `status-open` (a board row that still waits), `status-done`, `status-abandoned`, `status-in-progress`, `status-draft` |
| on a line that opens with bold words | `no-review-gate`, `purpose` |
| in a lane's name cell or phases cell | `lane-closed`, `partial-phase` |

```markdown
## Pistes
<!-- jh: lanes -->

| Piste | Port | Plan |
| ----- | ---- | ---- |
| `checkout` nettoyé <!-- jh: lane-closed --> | 3200 | [Plan](checkout.md) |

### Phase 1: Surface

**Le but** <!-- jh: purpose --> Les clients voient leurs filtres en haut de la liste.
```

When no section of a changed plan or board is recognised, three places say so: `jh plan check` names the forms it looked for (`no model table (looked for "### Model recommendations per phase", "### Model-Empfehlungen pro Phase" or <!-- jh: model -->)`), `jh check` warns on a changed file that has `##` headings of which jh reads none, and the herd shows `board: no section recognised` instead of "nothing waits for you". A section that is absent but allowed (no waiting item) stays silent.

The plan templates are written in the language of their file name: `template-English.md` always in English, `template-German.md` always in German, whatever `planLanguage` says.

## Minimal valid plan

```markdown
# Search filter

**Date:** YYYY-MM-DD
**Status:** Draft

## Implementation

### Model recommendations per phase

| Phase | Model | Rationale |
| ----- | ----- | --------- |
| 1 — Query parser | claude-sonnet-5-5 | pure functions, cheap to review |
| 2 — Filter bar | claude-opus-5-5 | touches the shared state |

### Dependencies and parallelization

| Phase | Depends on | Writes | Serial marker |
| ----- | ---------- | ------ | ------------- |
| 1 | — | `src/query/` | — |
| 2 | 1 | `src/ui/filter-bar/` | — |

### Phase 1: Query parser

**What it is about:** nothing visible yet; the search box can turn typed text into filters.

- [ ] **Parse filters**: `parseQuery(text)` returns the filter list
- [ ] **Test it**: every operator, one malformed input

### Phase 2: Filter bar

**What it is about:** people who search see their filters as chips above the results and can remove each one.

- [ ] **Render the bar**: one chip per filter
```

## Checking a plan

```
jh plan check <plan.md>
```

Prints one line per part, `file:line` where the part is incomplete. For the plan above:

```
phases: present plan.md:22 2 phases
tasks: present plan.md:22 every phase has tasks
model: present plan.md:12 every phase has a model
dependencies: present every phase has a row
head: missing no `## For you` section (looked for "## For you", "## Für dich" or <!-- jh: for-you -->)
purpose: present every phase says what it is about
pull-requests: present not needed with fewer than three phases
```

If the model table lacked the row for phase 2, the dependency table were left out and the phases had no purpose lines, the lines would read:

```
phases: present plan.md:22 2 phases
tasks: present plan.md:22 every phase has tasks
model: malformed plan.md:22 no model for P2
dependencies: missing no dependency table: phases run one after another (looked for "### Dependencies and parallelization", "### Abhängigkeiten und Parallelisierung" or <!-- jh: dependencies -->)
head: stale plan.md:5 names phase 1, the running phase is 2
purpose: missing plan.md:22 no purpose line in P1, P2
pull-requests: present not needed without a dependency table
```

| Exit | Meaning |
| ---- | ------- |
| 0 | the contract is met (a missing dependency table, a missing or stale head, a missing purpose line and a missing or questioned pull-request cut are notes, not gaps) |
| 1 | at least one part is missing or malformed |
| 2 | wrong command line: no subcommand, unknown subcommand, no file, unreadable file, unreadable config |
| 3 | the contract is met, but the plan or a board that links it is not on the base branch (a `base:` line names each path); the coordinator commits it first (`/orchestrate` § 2 step 0), after which the check counts as done |
