# Lesson files

> Every field of a course and a lesson, the level blocks and the slots filled from the learner's project.

Applies to: the Sypnia engine (open source, self-hosted) and Sypnia Cloud (paid service).  
Source: https://learn.docs.sypnia.com/lessons/the-lesson-format/

For agents: Format 1 (MIT). Course folder: learn/<course>/course.yaml {format: 1, id, title, description, level[], language (first), languages[], lessons[] (ids in order), checkpoints[]} + one <lesson>.lesson.md per lesson (+ <lesson>.es.lesson.md per extra language) + media/ (video, captions .vtt, images). Lesson frontmatter: id (kebab), title, goal (one sentence: what you can do after), level[] (starter|builder|developer|senior), step (idea|map|contract|design|data|code|publish|production), needs[] (lesson ids), minutes, video {file, captions{es,en}, chapters[]}, uses {<slot>: selector} (case: {has: failures|where|writes: 2}, table: {rls: true}, trace: {error: true}, promise: true; fallback: sample), exercise {brief, branch (default learn/<id>), checks[]}. Body: Markdown; level blocks ':::level starter builder' … ':::'; slots {{case.title}}, {{case.id}}, {{case.failures[0].name}}, {{table.name}}; questions ':::question' blocks. Unknown fields kept with warnings; x- prefix for extensions. learn lint validates.

## A course: `learn/<course>/course.yaml`

`learn/use-cases-first/course.yaml`

```yaml
format: 1
id: use-cases-first
title: Your app as use cases
description: Describe what people can do in your app, and what can go wrong.
level: [starter, builder]
language: es
languages: [es, en]
lessons: [what-is-a-use-case, failures-have-names, journeys, the-map-is-the-scope]
checkpoints: [the-map-is-the-scope]
```

| Field                        | Type  | What it is                                                   |
| ---------------------------- | ----- | ------------------------------------------------------------ |
| `format`                     | `1`   | the format version; tools refuse one they do not know        |
| `id`, `title`, `description` | text  | the course; `id` matches `^[a-z][a-z0-9-]{1,62}$`            |
| `level`                      | list  | the levels it is written for                                 |
| `language`, `languages`      | codes | the language it was made in first, and every language it has |
| `lessons`                    | list  | lesson ids, in order                                         |
| `checkpoints`                | list  | lessons that, once passed, let Learn propose the next level  |

## A lesson: `learn/<course>/<lesson>.lesson.md`

`learn/use-cases-first/failures-have-names.lesson.md`

```markdown
---
id: failures-have-names
title: Failures have names
goal: You can name what can go wrong in a case, and what the person is told.
level: [starter, builder]
step: map
needs: [what-is-a-use-case]
minutes: 8
video:
  file: media/failures-have-names.mp4
  captions: { es: media/failures-have-names.es.vtt, en: media/failures-have-names.en.vtt }
  chapters: [{ at: 0, title: A case that can fail }, { at: 95, title: What the customer reads }]
uses:
  case: { has: failures }
exercise:
  brief: Add a case where a customer cancels an order, with the failure that says it is too late.
  checks:
    - cases-check
    - case: { exists: true, has: failures }
    - question: why-name-it
---

Your case «{{case.title}}» can end badly: {{case.failures[0].name}}.

:::level starter
Think of what your customer reads when that happens. That sentence is part of your app.
:::

:::level builder
The failure's `name` is what the code and the traces use; its `tell` is what the person reads.
:::

:::question why-name-it
Why give a failure a name instead of showing «Error»?
- [x] So the person knows what happened and what to do
- [ ] So the app looks more technical
:::
```

## The header

| Field         | Required | What it is                                                                                                                                                            |
| ------------- | -------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `id`, `title` | yes      | a stable id and the title people see                                                                                                                                  |
| `goal`        | yes      | one sentence: what you can do after the lesson                                                                                                                        |
| `level`       | yes      | the levels it is written for                                                                                                                                          |
| `step`        | yes      | where it sits in [the Sypnia way](https://learn.docs.sypnia.com/paths/the-sypnia-way): `idea`, `map`, `contract`, `design`, `data`, `code`, `publish` or `production` |
| `needs`       | no       | lessons it expects you to have done; shown, never enforced                                                                                                            |
| `minutes`     | no       | about how long it takes                                                                                                                                               |
| `video`       | no       | the file, its captions per language and its chapters                                                                                                                  |
| `uses`        | no       | what to take from the learner's project, by slot ([Lessons on your project](https://learn.docs.sypnia.com/courses/lessons-on-your-project))                           |
| `exercise`    | no       | the `brief`, the `branch` (default `learn/<id>`) and the `checks` ([Checks](https://learn.docs.sypnia.com/lessons/checks))                                            |

## Selectors in `uses`

| Slot      | Selector                                   | Picks                                                                         |
| --------- | ------------------------------------------ | ----------------------------------------------------------------------------- |
| `case`    | `has: failures`, `has: where`, `writes: 2` | a case with failures, with a place in the app, or writing at least two tables |
| `table`   | `rls: true`                                | a table with row-level security                                               |
| `trace`   | `error: true`                              | a trace that ended in a failure (preview or test by default)                  |
| `promise` | `true`                                     | a promise of the landing page with its cases                                  |

With no match, the slot is filled from the sample project, La Espiga.

## The body

- **Markdown**, with the slots `{{case.title}}`, `{{case.id}}`, `{{case.failures[0].name}}`, `{{table.name}}`, `{{trace.case}}` filled from the chosen items.
- **Level blocks** `:::level starter builder` … `:::` appear only for those levels. Text outside them is for everyone.
- **Questions** `:::question <id>` … `:::` with options; `[x]` marks the right ones. A question can be a check.

## Rules

- **One file per language**: `failures-have-names.lesson.md` is the course's first language, `failures-have-names.en.lesson.md` another one. Same header fields; only text changes.
- **Unknown fields** are kept and reported as warnings. Your own fields start with `x-`.
- `npx @sypnia/learn lint <folder>` checks everything above.
