Below is the **instruction spec** for the component that generates **LLM guidance** for Flex-MD compliance, by strictness level. This is written for *people writing prompts* or for your `buildPrompt(spec, strictness)` generator.

Flex-MD is **Markdown**. The “levels” only change **how much structure you require and enforce**.

---

## Flex-MD strictness levels

### L0 — Plain Markdown (minimum)

Goal: get readable content with low prompt-tax.

**What you tell the LLM**

* “Reply in Markdown.”

**What you enforce**

* Nothing beyond “it’s text/Markdown”.
* No required sections.

**When to use**

* Creative / exploratory answers.
* You don’t need predictable parsing.

---

### L1 — Sectioned Flex-MD (human-readable + machine-extractable)

Goal: ensure predictable headings exist (order doesn’t matter).

**What you tell the LLM (minimal)**

* “Reply in Markdown.”
* “Include these section headings somewhere (order doesn’t matter):”

  * `Short answer`
  * `Long answer`
  * `Reasoning`
  * `Assumptions`
  * `Unknowns`
* “If a section has nothing to say, write `None`.”

**What you enforce**

* Headings exist (case-insensitive match).
* Content can be any Markdown under each heading.
* Order is **never** required.

**Extra typing rules (only if requested by spec)**

* `Reasoning` is an **ordered list** (`1.`, `2.`, …) when you care about sequence.
* `Assumptions` and `Unknowns` are **bullets** (`- ...`) when unordered.

**When to use**

* Most production calls where you want stable extraction.
* Best “effort vs structure” tradeoff.

---

### L2 — Single-container Flex-MD (safer parsing)

Goal: eliminate “extra chatter” and make extraction reliable.

**What you tell the LLM**
Everything from L1, plus:

* “Return the entire answer inside one fenced Markdown block and nothing else.”

Example phrasing:

* “Put your full answer inside a single ` ```markdown ` fenced block. No text before or after.”

**What you enforce**

* Exactly one container fence, and all content is inside it.
* Still no ordering requirement for sections.

**When to use**

* Tool pipelines where stray tokens break parsing.
* You want consistent capture of the whole response.

---

### L3 — Fully-typed Flex-MD (max determinism, still Markdown)

Goal: strongest structural guarantees, still using Markdown (not JSON output).

**What you tell the LLM**
Everything from L2, plus **stricter formatting constraints** derived from the spec:

* Section presence is strict:

  * all required sections must exist (and be non-empty unless allowed).
* Section type rules are strict:

  * ordered list sections must be ordered lists
  * list sections must be bullet lists
  * tables must be Markdown pipe tables if requested
  * ordered tables must include a `#` column with 1..N

And (important):

* “Do not output JSON as the response format.”
* “If you include JSON-like content, present it as Markdown (lists/tables), not a JSON block.”

**What you enforce**

* All required sections present
* All required section type constraints met
* All required table constraints met
* Container constraints met

**When to use**

* High reliability extraction and downstream automation.
* You can afford slightly more prompt-tax.

---

## Minimal instruction templates for your generator

### L0 template (lowest tax)

```
Reply in Markdown.
```

### L1 template (recommended default)

```
Reply in Markdown.

Include these section headings somewhere (order does not matter):
- Short answer
- Long answer
- Reasoning
- Assumptions
- Unknowns

If a section is empty, write `None`.
```

### L1 with explicit type rules (only if your spec needs them)

```
Reply in Markdown.

Include these section headings somewhere (order does not matter):
- Short answer
- Long answer
- Reasoning (ordered list)
- Assumptions (list)
- Unknowns (list)

If a section is empty, write `None`.

List rules:
- Use numbered lists (1., 2., …) for ordered lists.
- Use '-' bullets for unordered lists.
```

### L2 template (single container)

````
Return your entire answer inside a single ```markdown fenced block and nothing else.

Inside the block, include these section headings somewhere (order does not matter):
- Short answer
- Long answer
- Reasoning
- Assumptions
- Unknowns

If a section is empty, write `None`.
````

### L3 template (max strict)

````
Return your entire answer inside a single ```markdown fenced block and nothing else.

Include these section headings somewhere (order does not matter):
- Short answer
- Long answer
- Reasoning (ordered list)
- Assumptions (list)
- Unknowns (list)

If a section is empty, write `None`.

Formatting rules:
- Ordered lists use 1., 2., …
- Unordered lists use '-' bullets.
- If a table is used, use a Markdown pipe table with the declared columns.
- If an ordered table is required, add a first column named '#' and number rows 1..N.
- Do not return JSON as the response format.
````

---

## How the “instructions builder” should decide what to include (tax-aware)

Your generator should only include guidance that is relevant to the current spec:

Include:

* Section list always at L1+
* `None` rule only if you want it (recommended at L1+ when sections are required)
* List rules only if any required section is a list / ordered list
* Table rules only if any required table exists (or strictness L3)
* Container rule only at L2+

