1
---
2
name: scaffold-exercises
3
description: Create exercise directory structures with sections, problems, solutions, and explainers that pass linting. Use when user wants to scaffold exercises, create exercise stubs, or set up a new course section.
4
---
5
6
# Scaffold Exercises
7
8
Create exercise directory structures that pass `pnpm ai-hero-cli internal lint`, then commit with `git commit`.
9
10
## Directory naming
11
12
- **Sections**: `XX-section-name/` inside `exercises/` (e.g., `01-retrieval-skill-building`)
13
- **Exercises**: `XX.YY-exercise-name/` inside a section (e.g., `01.03-retrieval-with-bm25`)
14
- Section number = `XX`, exercise number = `XX.YY`
15
- Names are dash-case (lowercase, hyphens)
16
17
## Exercise variants
18
19
Each exercise needs at least one of these subfolders:
20
21
- `problem/` - student workspace with TODOs
22
- `solution/` - reference implementation
23
- `explainer/` - conceptual material, no TODOs
24
25
When stubbing, default to `explainer/` unless the plan specifies otherwise.
26
27
## Required files
28
29
Each subfolder (`problem/`, `solution/`, `explainer/`) needs a `readme.md` that:
30
31
- Is **not empty** (must have real content, even a single title line works)
32
- Has no broken links
33
34
When stubbing, create a minimal readme with a title and a description:
35
36
```md
37
# Exercise Title
38
39
Description here
40
```
41
42
If the subfolder has code, it also needs a `main.ts` (>1 line). But for stubs, a readme-only exercise is fine.
43
44
## Workflow
45
46
1. **Parse the plan** - extract section names, exercise names, and variant types
47
2. **Create directories** - `mkdir -p` for each path
48
3. **Create stub readmes** - one `readme.md` per variant folder with a title
49
4. **Run lint** - `pnpm ai-hero-cli internal lint` to validate
50
5. **Fix any errors** - iterate until lint passes
51
52
## Lint rules summary
53
54
The linter (`pnpm ai-hero-cli internal lint`) checks:
55
56
- Each exercise has subfolders (`problem/`, `solution/`, `explainer/`)
57
- At least one of `problem/`, `explainer/`, or `explainer.1/` exists
58
- `readme.md` exists and is non-empty in the primary subfolder
59
- No `.gitkeep` files
60
- No `speaker-notes.md` files
61
- No broken links in readmes
62
- No `pnpm run exercise` commands in readmes
63
- `main.ts` required per subfolder unless it's readme-only
64
65
## Moving/renaming exercises
66
67
When renumbering or moving exercises:
68
69
1. Use `git mv` (not `mv`) to rename directories - preserves git history
70
2. Update the numeric prefix to maintain order
71
3. Re-run lint after moves
72
73
Example:
74
75
```bash
76
git mv exercises/01-retrieval/01.03-embeddings exercises/01-retrieval/01.04-embeddings
77
```
78
79
## Example: stubbing from a plan
80
81
Given a plan like:
82
83
```
84
Section 05: Memory Skill Building
85
- 05.01 Introduction to Memory
86
- 05.02 Short-term Memory (explainer + problem + solution)
87
- 05.03 Long-term Memory
88
```
89
90
Create:
91
92
```bash
93
mkdir -p exercises/05-memory-skill-building/05.01-introduction-to-memory/explainer
94
mkdir -p exercises/05-memory-skill-building/05.02-short-term-memory/{explainer,problem,solution}
95
mkdir -p exercises/05-memory-skill-building/05.03-long-term-memory/explainer
96
```
97
98
Then create readme stubs:
99
100
```
101
exercises/05-memory-skill-building/05.01-introduction-to-memory/explainer/readme.md -> "# Introduction to Memory"
102
exercises/05-memory-skill-building/05.02-short-term-memory/explainer/readme.md -> "# Short-term Memory"
103
exercises/05-memory-skill-building/05.02-short-term-memory/problem/readme.md -> "# Short-term Memory"
104
exercises/05-memory-skill-building/05.02-short-term-memory/solution/readme.md -> "# Short-term Memory"
105
exercises/05-memory-skill-building/05.03-long-term-memory/explainer/readme.md -> "# Long-term Memory"
106
```
107