scaffold-exercises
Scaffold Exercises
Section titled “Scaffold Exercises”创建能通过 pnpm ai-hero-cli internal lint 检查的练习目录结构,然后用 git commit 提交。
- 章节:放在
exercises/里的XX-section-name/(例如01-retrieval-skill-building) - 练习:放在章节目录里的
XX.YY-exercise-name/(例如01.03-retrieval-with-bm25) - 章节编号 =
XX,练习编号 =XX.YY - 名称使用短横线格式(小写字母,用连字符分隔)
每个练习至少需要以下子目录之一:
problem/:供学生使用的工作区,包含 TODOsolution/:参考实现explainer/:概念讲解材料,不含 TODO
创建占位内容时,默认使用 explainer/,除非计划另有说明。
每个子目录(problem/、solution/、explainer/)都需要一个 readme.md,并且要满足以下要求:
- 不能为空(必须有实际内容,哪怕只有一行标题也可以)
- 不能有失效链接
创建占位内容时,写一个包含标题和说明的最简 readme:
# Exercise Title
Description here如果子目录包含代码,还需要一个超过一行的 main.ts。不过,占位练习只包含 readme 也可以。
- 解析计划:提取章节名称、练习名称和变体类型
- 创建目录:为每个路径运行
mkdir -p - 创建占位 readme:每个变体目录放一个
readme.md,里面写个标题 - 运行 lint:运行
pnpm ai-hero-cli internal lint进行检查 - 修复错误:反复修改,直到 lint 通过
Lint 规则摘要
Section titled “Lint 规则摘要”Lint 工具(pnpm ai-hero-cli internal lint)会检查:
- 每个练习都有子目录(
problem/、solution/、explainer/) - 至少有一个
problem/、explainer/或explainer.1/ - 主要子目录中存在非空的
readme.md - 没有
.gitkeep文件 - 没有
speaker-notes.md文件 - readme 中没有失效链接
- readme 中没有
pnpm run exercise命令 - 除非子目录只有 readme,否则必须有
main.ts
移动或重命名练习
Section titled “移动或重命名练习”调整练习编号或移动练习时:
- 使用
git mv(不要用mv)重命名目录,以保留 Git 历史 - 更新数字前缀,保持顺序
- 移动后重新运行 lint
示例:
git mv exercises/01-retrieval/01.03-embeddings exercises/01-retrieval/01.04-embeddings示例:根据计划创建占位内容
Section titled “示例:根据计划创建占位内容”假设计划如下:
Section 05: Memory Skill Building- 05.01 Introduction to Memory- 05.02 Short-term Memory (explainer + problem + solution)- 05.03 Long-term Memory创建以下目录:
mkdir -p exercises/05-memory-skill-building/05.01-introduction-to-memory/explainermkdir -p exercises/05-memory-skill-building/05.02-short-term-memory/{explainer,problem,solution}mkdir -p exercises/05-memory-skill-building/05.03-long-term-memory/explainer然后创建占位 readme:
exercises/05-memory-skill-building/05.01-introduction-to-memory/explainer/readme.md -> "# Introduction to Memory"exercises/05-memory-skill-building/05.02-short-term-memory/explainer/readme.md -> "# Short-term Memory"exercises/05-memory-skill-building/05.02-short-term-memory/problem/readme.md -> "# Short-term Memory"exercises/05-memory-skill-building/05.02-short-term-memory/solution/readme.md -> "# Short-term Memory"exercises/05-memory-skill-building/05.03-long-term-memory/explainer/readme.md -> "# Long-term Memory"原文链接和 commit
Section titled “原文链接和 commit”读者可以点名用它,模型也可以自己调用它。它不在 Claude Code 插件里。
创建符合 lint 规则的练习目录、占位文件和变体结构,并按流程验证及调整。
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.- 仓库 mattpocock/skills
- 文件
skills/misc/scaffold-exercises/SKILL.md - 提交
d81f3a1 - 原仓库里这一则没有单独的说明页。
- 同目录文件
skills/misc/scaffold-exercises/agents/openai.yaml
英文 SKILL.md
---name: scaffold-exercisesdescription: 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.---
# Scaffold Exercises
Create exercise directory structures that pass `pnpm ai-hero-cli internal lint`, then commit with `git commit`.
## Directory naming
- **Sections**: `XX-section-name/` inside `exercises/` (e.g., `01-retrieval-skill-building`)- **Exercises**: `XX.YY-exercise-name/` inside a section (e.g., `01.03-retrieval-with-bm25`)- Section number = `XX`, exercise number = `XX.YY`- Names are dash-case (lowercase, hyphens)
## Exercise variants
Each exercise needs at least one of these subfolders:
- `problem/` - student workspace with TODOs- `solution/` - reference implementation- `explainer/` - conceptual material, no TODOs
When stubbing, default to `explainer/` unless the plan specifies otherwise.
## Required files
Each subfolder (`problem/`, `solution/`, `explainer/`) needs a `readme.md` that:
- Is **not empty** (must have real content, even a single title line works)- Has no broken links
When stubbing, create a minimal readme with a title and a description:
```md# Exercise Title
Description here```
If the subfolder has code, it also needs a `main.ts` (>1 line). But for stubs, a readme-only exercise is fine.
## Workflow
1. **Parse the plan** - extract section names, exercise names, and variant types2. **Create directories** - `mkdir -p` for each path3. **Create stub readmes** - one `readme.md` per variant folder with a title4. **Run lint** - `pnpm ai-hero-cli internal lint` to validate5. **Fix any errors** - iterate until lint passes
## Lint rules summary
The linter (`pnpm ai-hero-cli internal lint`) checks:
- Each exercise has subfolders (`problem/`, `solution/`, `explainer/`)- At least one of `problem/`, `explainer/`, or `explainer.1/` exists- `readme.md` exists and is non-empty in the primary subfolder- No `.gitkeep` files- No `speaker-notes.md` files- No broken links in readmes- No `pnpm run exercise` commands in readmes- `main.ts` required per subfolder unless it's readme-only
## Moving/renaming exercises
When renumbering or moving exercises:
1. Use `git mv` (not `mv`) to rename directories - preserves git history2. Update the numeric prefix to maintain order3. Re-run lint after moves
Example:
```bashgit mv exercises/01-retrieval/01.03-embeddings exercises/01-retrieval/01.04-embeddings```
## Example: stubbing from a plan
Given a plan like:
```Section 05: Memory Skill Building- 05.01 Introduction to Memory- 05.02 Short-term Memory (explainer + problem + solution)- 05.03 Long-term Memory```
Create:
```bashmkdir -p exercises/05-memory-skill-building/05.01-introduction-to-memory/explainermkdir -p exercises/05-memory-skill-building/05.02-short-term-memory/{explainer,problem,solution}mkdir -p exercises/05-memory-skill-building/05.03-long-term-memory/explainer```
Then create readme stubs:
```exercises/05-memory-skill-building/05.01-introduction-to-memory/explainer/readme.md -> "# Introduction to Memory"exercises/05-memory-skill-building/05.02-short-term-memory/explainer/readme.md -> "# Short-term Memory"exercises/05-memory-skill-building/05.02-short-term-memory/problem/readme.md -> "# Short-term Memory"exercises/05-memory-skill-building/05.02-short-term-memory/solution/readme.md -> "# Short-term Memory"exercises/05-memory-skill-building/05.03-long-term-memory/explainer/readme.md -> "# Long-term Memory"```非官方学习站,与 Matt Pocock 和 AI Hero 没有隶属关系。本站不提供可安装的中文技能包。
技能原文采用 MIT 许可。Copyright (c) 2026 Matt Pocock