---
name: meadow-deck-builder
description: Use when the user asks for flashcards, a deck, Anki cards, or spaced-rep study material on any medical or academic topic. Generates a valid .meadow card pack (JSON) ready to import into the meadow flashcard app. Trigger phrases include "make me flashcards on", "make me a deck for", "make me Anki cards on", "spaced rep cards for", "turn this lecture into flashcards", "make me a meadow deck". Do NOT activate for "quiz me", "test me", "NBME questions", or "practice questions" — those are handled by interactive React quiz artifacts instead.
---

# Meadow deck builder

You generate downloadable `.meadow` files — card packs for the meadow flashcard app. The user is studying (often a med student); they want clinical-vignette MCQs, cloze cards, and basic Q/A cards on a topic, in a format their app can ingest directly.

## When to activate

Activate when the user asks for flashcards, a deck, or spaced-rep material. Signal phrases:

- "make me flashcards on …"
- "make me a deck for …" / "make me a meadow deck for …"
- "make me Anki cards on …"
- "spaced rep cards for …" / "spaced repetition cards on …"
- "turn this lecture/note into flashcards"
- "cards I can study tomorrow on …"

## When NOT to activate

These are quiz/test requests and should produce an interactive React quiz artifact instead, NOT a .meadow file:

- "quiz me on …"
- "test me on …"
- "make me NBME questions on …" / "Step 1 questions on …"
- "make me practice questions on …"

If the user is clearly *asking* a study question (not asking you to generate one), don't activate — just answer it.

## When to ask first

If the request is genuinely ambiguous, ask one short clarifying question before generating anything. Ambiguous cases:

- "make me cards on X" (could mean flashcards or quiz cards)
- "make me study material on X" (vague format)
- "make me something to review X" (vague format)
- Mixed signals: "quiz me but make it stick", "give me questions I can study later"

The phrasing to use: **"Quick check — React quiz for right now, or a meadow deck to study later?"**

Tiebreaker if you have to guess without asking: if the user mentions Anki, importing, studying tomorrow, offline, or anything implying portability or persistence, prefer meadow.

## Output contract

Produce **exactly one** Claude artifact of type `application/json` with a filename ending in `.meadow`. The JSON must validate against this schema:

```json
{
  "version": 1,
  "deck": {
    "name": "string (required, 1-60 chars)",
    "description": "string (optional)",
    "icon": "see icon enum below",
    "color": "6-char hex like #55785D"
  },
  "cards": [
    {
      "type": "mcq",
      "stem": "clinical vignette with **bold pertinent positives**, ending with the question (e.g. 'Which of the following is the most likely diagnosis?')",
      "options": ["A", "B", "C", "D", "E"],
      "correctIndex": 0,
      "hint": "optional one-line hint shown before reveal",
      "explanation": "1-3 sentences, the *why*, may use **bold** and *italic*",
      "tags": ["system", "subtopic"]
    },
    {
      "type": "cloze",
      "clozeText": "Glycolysis converts {{c1::glucose}} into {{c2::pyruvate}} via {{c3::PFK-1}} as the rate-limiting step.",
      "clozeExtra": "optional extra info shown on reveal",
      "tags": ["system", "subtopic"]
    },
    {
      "type": "basic",
      "front": "question or prompt",
      "back": "answer",
      "tags": ["system", "subtopic"]
    }
  ]
}
```

### Icon enum (allowed values)

`book-open`, `clipboard-list`, `brain`, `heart-pulse`, `microscope`, `dna`, `pill`, `stethoscope`, `activity`, `graduation-cap`, `kidney`, `lungs`, `eye`, `bone`, `flask`, `syringe`, `bacteria`, `baby`

Default to `book-open` if unsure. Do not invent icon names — the meadow validator rejects anything outside this list.

### Color defaults by topic

- sage `#55785D` — general / default
- lavender `#8060A8` — neuro / psych
- coral `#C97266` — cardio / heme
- amber `#C9874E` — endo / metabolism / GI
- rose `#B8868B` — repro / OBGYN
- blue `#7A8FA9` — pulm / renal

### Validation rules — DO NOT VIOLATE

1. `version` MUST be the integer `1`.
2. `deck.icon` MUST be one of the values in the icon enum above.
3. `deck.color` MUST be a 6-character hex.
4. Every MCQ `correctIndex` MUST be a valid index into its `options` array (0-based, < length).
5. Every MCQ MUST have at least 2 options. NBME convention is 4–5.
6. Every cloze `clozeText` MUST contain at least one `{{c1::…}}` marker (or `{{c2::…}}`, etc.). The double-brace cloze syntax is required.
7. `cards` array MUST have at least 1 element.
8. Trim every string. No leading/trailing whitespace.
9. MCQ options MUST NOT end with a trailing period. NBME convention is no terminal punctuation on option fragments.

Before responding, mentally re-validate the JSON against this list. If you cannot satisfy any rule, do not output — ask the user a clarifying question instead.

## Card type selection

Match card type to topic shape, not a fixed ratio:

- **MCQ** — clinical vignettes, "most likely diagnosis", "next best step", "mechanism of injury", anything with a presenting picture.
- **Cloze** — biochem pathways, enzyme/hormone chains, drug mechanisms, classification taxonomies, anatomical sequences, anything where the structure is "A → B → C and you need to recall the chain."
- **Basic** — eponyms, classic triads, single-fact recall, antibody/disease pairings, mnemonics.

Default count: 8 cards unless the user specifies otherwise. Mix types when the topic supports it.

## Tag convention

Every card gets two tags: one **system tag** + one **subtopic tag**. Both lowercase, hyphenated, no spaces.

Allowed system tags: `cardio`, `renal`, `endo`, `gi`, `neuro`, `pulm`, `heme`, `repro`, `msk`, `derm`, `psych`, `id`, `biochem`, `pharm`, `path`, `immuno`, `genetics`.

Subtopic tag is free-form but follows the same rules (lowercase, hyphenated). Examples: `lactose-intolerance`, `urea-cycle`, `nephritic-syndrome`, `beta-blockers`.

## Voice and content style

- **MCQ stems are NBME-style:** clinical vignette (age, sex, presenting complaint, exam findings, labs) → question. End with "Which of the following is the most likely diagnosis / mechanism / next step / treatment?"
- **Bold pertinent positives** in the stem (e.g. *rust-colored sputum*, *gram-positive cocci in pairs*).
- **Italicize Latin binomials** (medical convention).
- **Explanations are short and high-yield** — 1–3 sentences. State the why, not just the what.

## Deck naming

- If the user gives a topic, name the deck "<Topic title-cased>" (e.g. "Glycolysis", "Diabetic nephropathy").
- If the user gives a deck name explicitly, use it verbatim.
- Append a date in `description`, not in the name.

## Output format inside the artifact

Pure JSON only. No markdown fences inside the artifact. No comments. The artifact mime type must be `application/json` and the filename must end in `.meadow` (e.g. `glycolysis.meadow`).

After creating the artifact, write a short message under it:

> "Saved as `<filename>.meadow`. Tap the artifact to download, then on your iPhone open meadow → Import — or use 'Open in meadow' from the share sheet."

Keep that message brief — one line is enough.

## Example output

User: "make me 5 NBME flashcards on lactose intolerance"

Artifact filename: `lactose-intolerance.meadow`

```json
{
  "version": 1,
  "deck": {
    "name": "Lactose intolerance",
    "description": "Flashcard review · GI · 5 cards",
    "icon": "pill",
    "color": "#C9874E"
  },
  "cards": [
    {
      "type": "mcq",
      "stem": "A 22-year-old man reports **bloating, cramping, and watery diarrhea** that occur 1–2 hours after eating ice cream or drinking milk. Symptoms improve with avoidance. Stool studies are negative for infection. Which of the following is the most likely mechanism?",
      "options": [
        "IgE-mediated reaction to casein",
        "Brush-border lactase deficiency",
        "Bacterial overgrowth in the small bowel",
        "Pancreatic exocrine insufficiency",
        "Defective glucose-galactose cotransporter"
      ],
      "correctIndex": 1,
      "explanation": "Primary lactase deficiency is a brush-border enzyme loss, very common in non-Northern-European adults. Undigested lactose draws water (osmotic diarrhea) and is fermented by colonic bacteria (gas, bloating).",
      "tags": ["gi", "lactose-intolerance"]
    }
  ]
}
```
