Skip to content

Claude Code guide in three levels, Beginner to Advanced: hands-on lessons with checked exercises, every volatile fact cited to its source. Independent community guide.

chore: let the lesson-quotes check compare the learning app's code blocks with the lesson's fenced blocks (#128)

Wesam Abousaidcc52a4c70619
diff --git a/.github/scripts/fixtures/lesson-quotes-block-changed/fixture.json b/.github/scripts/fixtures/lesson-quotes-block-changed/fixture.json
new file mode 100644
index 0000000..a7cbd34
--- /dev/null
+++ b/.github/scripts/fixtures/lesson-quotes-block-changed/fixture.json
@@ -0,0 +1,12 @@
+{
+ "rule": "lesson-quotes",
+ "expect": "fail",
+ "env": {
+ "LEARN_DIR": "practice"
+ },
+ "about": "The lesson changed a line of a fenced block that the lesson file shows as a code block, and that a later lesson's warm-up shows from it, though the later lesson's own page still has the old block.",
+ "output": [
+ "b-1\\.md shows a code block starting \"#!/bin/bash\" \\(W2 \\| Worked example step 2 of 3 \\| A script\\), which is no longer in the lesson\\.",
+ "b-2\\.md shows a code block starting \"#!/bin/bash\" \\(R1 \\| Warm-up \\| The script, from docs/beginner/01-demo\\.md\\), which is no longer in that lesson\\."
+ ]
+}
diff --git a/.github/scripts/fixtures/lesson-quotes-block-changed/tree/.github/compat/learn.txt b/.github/scripts/fixtures/lesson-quotes-block-changed/tree/.github/compat/learn.txt
new file mode 100644
index 0000000..d72ca41
--- /dev/null
+++ b/.github/scripts/fixtures/lesson-quotes-block-changed/tree/.github/compat/learn.txt
@@ -0,0 +1,2 @@
+b-1 docs/beginner/01-demo.md
+b-2 docs/beginner/02-demo.md
diff --git a/.github/scripts/fixtures/lesson-quotes-block-changed/tree/docs/beginner/01-demo.md b/.github/scripts/fixtures/lesson-quotes-block-changed/tree/docs/beginner/01-demo.md
new file mode 100644
index 0000000..0ea3660
--- /dev/null
+++ b/.github/scripts/fixtures/lesson-quotes-block-changed/tree/docs/beginner/01-demo.md
@@ -0,0 +1,25 @@
+# Demo lesson
+
+<sub>**Beginner** · Lesson 1 of 5 · about 20 minutes · Verified against Claude Code v2.1.285 (stable) on 2026-10-05</sub>
+
+## Worked example
+
+1. Type `/status`.
+2. Save this script as `check.sh`:
+
+ ```bash
+ #!/bin/bash
+ set -e
+
+ claude --version > .practice/version.txt
+ ```
+
+3. End the session with `/exit`.
+
+## Your turn
+
+1. Ask a question of your own.
+
+## Check
+
+Run the check.
diff --git a/.github/scripts/fixtures/lesson-quotes-block-changed/tree/docs/beginner/02-demo.md b/.github/scripts/fixtures/lesson-quotes-block-changed/tree/docs/beginner/02-demo.md
new file mode 100644
index 0000000..7315f28
--- /dev/null
+++ b/.github/scripts/fixtures/lesson-quotes-block-changed/tree/docs/beginner/02-demo.md
@@ -0,0 +1,22 @@
+# Second demo
+
+<sub>**Beginner** · Lesson 2 of 5 · about 20 minutes · Verified against Claude Code v2.1.285 (stable) on 2026-10-05</sub>
+
+## Worked example
+
+1. Open the script you saved as `check.sh`:
+
+ ```bash
+ #!/bin/bash
+ set -e
+
+ claude --version
+ ```
+
+## Your turn
+
+1. Ask for a change.
+
+## Check
+
+Run the check.
diff --git a/.github/scripts/fixtures/lesson-quotes-block-changed/tree/practice/b-1.md b/.github/scripts/fixtures/lesson-quotes-block-changed/tree/practice/b-1.md
new file mode 100644
index 0000000..9d236af
--- /dev/null
+++ b/.github/scripts/fixtures/lesson-quotes-block-changed/tree/practice/b-1.md
@@ -0,0 +1,41 @@
+---
+lesson: b-1
+title: "Demo lesson"
+stamp: "Verified against Claude Code v2.1.285 (stable) on 2026-10-05"
+---
+
+## intro
+- minutes: "about 20 minutes"
+
+## steps
+
+### W1 | Worked example step 1 of 3 | Look at /status
+- tier: guided
+- skill: status
+- where: claude
+- beat: do
+- verify: self
+- do: "Type `/status`."
+
+### W2 | Worked example step 2 of 3 | A script
+- tier: guided
+- skill: script
+- where: editor
+- beat: do
+- verify: self
+- do: "Save this script as `check.sh`:"
+- code: point 4
+```bash
+#!/bin/bash
+set -e
+
+claude --version
+```
+
+### Y1 | Your turn step 1 of 1 | Your own question
+- tier: hinted
+- skill: ask
+- where: claude
+- beat: do
+- verify: self
+- goal: "Ask a question of your own."
diff --git a/.github/scripts/fixtures/lesson-quotes-block-changed/tree/practice/b-2.md b/.github/scripts/fixtures/lesson-quotes-block-changed/tree/practice/b-2.md
new file mode 100644
index 0000000..8024abc
--- /dev/null
+++ b/.github/scripts/fixtures/lesson-quotes-block-changed/tree/practice/b-2.md
@@ -0,0 +1,44 @@
+---
+lesson: b-2
+title: "Second demo"
+stamp: "Verified against Claude Code v2.1.285 (stable) on 2026-10-05"
+---
+
+## intro
+- minutes: "about 20 minutes"
+
+## warm-up
+
+### R1 | Warm-up | The script
+- tier: challenge
+- skill: script
+- from: b-1
+- beat: ask
+- code: point 4
+```bash
+#!/bin/bash
+set -e
+
+claude --version
+```
+- ask: What does the last line run?
+- right: "`claude --version`"
+- wrong: "`/exit`"
+
+## steps
+
+### W1 | Worked example step 1 of 1 | The script again
+- tier: guided
+- skill: script
+- where: editor
+- beat: do
+- verify: self
+- do: "Open the script you saved as `check.sh`:"
+
+### Y1 | Your turn step 1 of 1 | Your own change
+- tier: hinted
+- skill: plan-ask
+- where: claude
+- beat: do
+- verify: self
+- goal: "Ask for a change."
diff --git a/.github/scripts/fixtures/lesson-quotes-block-match/fixture.json b/.github/scripts/fixtures/lesson-quotes-block-match/fixture.json
new file mode 100644
index 0000000..3efdc25
--- /dev/null
+++ b/.github/scripts/fixtures/lesson-quotes-block-match/fixture.json
@@ -0,0 +1,8 @@
+{
+ "rule": "lesson-quotes",
+ "expect": "pass",
+ "env": {
+ "LEARN_DIR": "practice"
+ },
+ "about": "Each code block equals a fenced block of its lesson, less the indent of a fence inside a numbered step, blank lines included; a warm-up's block matches the earlier lesson; a tilde block holds a three-backtick line; and a heading or a from line inside a block is code, not the lesson file's own."
+}
diff --git a/.github/scripts/fixtures/lesson-quotes-block-match/tree/.github/compat/learn.txt b/.github/scripts/fixtures/lesson-quotes-block-match/tree/.github/compat/learn.txt
new file mode 100644
index 0000000..d72ca41
--- /dev/null
+++ b/.github/scripts/fixtures/lesson-quotes-block-match/tree/.github/compat/learn.txt
@@ -0,0 +1,2 @@
+b-1 docs/beginner/01-demo.md
+b-2 docs/beginner/02-demo.md
diff --git a/.github/scripts/fixtures/lesson-quotes-block-match/tree/docs/beginner/01-demo.md b/.github/scripts/fixtures/lesson-quotes-block-match/tree/docs/beginner/01-demo.md
new file mode 100644
index 0000000..6164812
--- /dev/null
+++ b/.github/scripts/fixtures/lesson-quotes-block-match/tree/docs/beginner/01-demo.md
@@ -0,0 +1,44 @@
+# Demo lesson
+
+<sub>**Beginner** · Lesson 1 of 5 · about 20 minutes · Verified against Claude Code v2.1.285 (stable) on 2026-10-05</sub>
+
+## Worked example
+
+1. Type `/status`.
+2. Save this script as `check.sh`:
+
+ ```bash
+ #!/bin/bash
+ set -e
+
+ claude --version > .practice/version.txt
+ ```
+
+3. End the session with `/exit`.
+
+Your `CLAUDE.md` can name the test command:
+
+````markdown
+## Commands
+
+```bash
+npm test
+```
+````
+
+A warm-up in a lesson file names the lesson it comes from:
+
+~~~markdown
+- from: b-0
+```bash
+npm test
+```
+~~~
+
+## Your turn
+
+1. Ask a question of your own.
+
+## Check
+
+Run the check.
diff --git a/.github/scripts/fixtures/lesson-quotes-block-match/tree/docs/beginner/02-demo.md b/.github/scripts/fixtures/lesson-quotes-block-match/tree/docs/beginner/02-demo.md
new file mode 100644
index 0000000..3054a89
--- /dev/null
+++ b/.github/scripts/fixtures/lesson-quotes-block-match/tree/docs/beginner/02-demo.md
@@ -0,0 +1,15 @@
+# Second demo
+
+<sub>**Beginner** · Lesson 2 of 5 · about 20 minutes · Verified against Claude Code v2.1.285 (stable) on 2026-10-05</sub>
+
+## Worked example
+
+1. Press `Shift+Tab` until the status bar reads plan mode.
+
+## Your turn
+
+1. Ask for a change.
+
+## Check
+
+Run the check.
diff --git a/.github/scripts/fixtures/lesson-quotes-block-match/tree/practice/b-1.md b/.github/scripts/fixtures/lesson-quotes-block-match/tree/practice/b-1.md
new file mode 100644
index 0000000..1a64881
--- /dev/null
+++ b/.github/scripts/fixtures/lesson-quotes-block-match/tree/practice/b-1.md
@@ -0,0 +1,56 @@
+---
+lesson: b-1
+title: "Demo lesson"
+stamp: "Verified against Claude Code v2.1.285 (stable) on 2026-10-05"
+---
+
+## intro
+- minutes: "about 20 minutes"
+
+## steps
+
+### W1 | Worked example step 1 of 3 | Look at /status
+- tier: guided
+- skill: status
+- where: claude
+- beat: do
+- verify: self
+- do: "Type `/status`."
+
+### W2 | Worked example step 2 of 3 | A script
+- tier: guided
+- skill: script
+- where: editor
+- beat: do
+- verify: self
+- do: "Save this script as `check.sh`:"
+- code: point 4
+```bash
+#!/bin/bash
+set -e
+
+claude --version > .practice/version.txt
+```
+
+### W3 | Worked example step 3 of 3 | Leave
+- tier: guided
+- skill: exit
+- where: claude
+- beat: do
+- verify: self
+- do: "End the session with `/exit`."
+- code: point 1
+~~~markdown
+- from: b-0
+```bash
+npm test
+```
+~~~
+
+### Y1 | Your turn step 1 of 1 | Your own question
+- tier: hinted
+- skill: ask
+- where: claude
+- beat: do
+- verify: self
+- goal: "Ask a question of your own."
diff --git a/.github/scripts/fixtures/lesson-quotes-block-match/tree/practice/b-2.md b/.github/scripts/fixtures/lesson-quotes-block-match/tree/practice/b-2.md
new file mode 100644
index 0000000..26ed1a7
--- /dev/null
+++ b/.github/scripts/fixtures/lesson-quotes-block-match/tree/practice/b-2.md
@@ -0,0 +1,46 @@
+---
+lesson: b-2
+title: "Second demo"
+stamp: "Verified against Claude Code v2.1.285 (stable) on 2026-10-05"
+---
+
+## intro
+- minutes: "about 20 minutes"
+
+## warm-up
+
+### R1 | Warm-up | Test command
+- tier: challenge
+- skill: memory
+- from: b-1
+- beat: ask
+- code: point 4
+````markdown
+## Commands
+
+```bash
+npm test
+```
+````
+- ask: What does this file name?
+- right: "the test command"
+- wrong: "`/exit`"
+- because: "Your `CLAUDE.md` can name the test command:"
+
+## steps
+
+### W1 | Worked example step 1 of 1 | Plan mode
+- tier: guided
+- skill: plan-mode
+- where: claude
+- beat: do
+- verify: self
+- do: "Press `Shift+Tab` until the status bar reads plan mode."
+
+### Y1 | Your turn step 1 of 1 | Your own change
+- tier: hinted
+- skill: plan-ask
+- where: claude
+- beat: do
+- verify: self
+- goal: "Ask for a change."
diff --git a/.github/scripts/fixtures/lesson-quotes-block-unclosed/fixture.json b/.github/scripts/fixtures/lesson-quotes-block-unclosed/fixture.json
new file mode 100644
index 0000000..6bc1fc0
--- /dev/null
+++ b/.github/scripts/fixtures/lesson-quotes-block-unclosed/fixture.json
@@ -0,0 +1,11 @@
+{
+ "rule": "lesson-quotes",
+ "expect": "fail",
+ "env": {
+ "LEARN_DIR": "practice"
+ },
+ "about": "A code block in the lesson file opens on four backticks and never closes: a three-backtick line inside it is the block's own line, not its end.",
+ "output": [
+ "b-1\\.md has a code block \\(W1 \\| Worked example step 1 of 2 \\| Look at /status\\) with no closing fence\\."
+ ]
+}
diff --git a/.github/scripts/fixtures/lesson-quotes-block-unclosed/tree/.github/compat/learn.txt b/.github/scripts/fixtures/lesson-quotes-block-unclosed/tree/.github/compat/learn.txt
new file mode 100644
index 0000000..1d980f9
--- /dev/null
+++ b/.github/scripts/fixtures/lesson-quotes-block-unclosed/tree/.github/compat/learn.txt
@@ -0,0 +1 @@
+b-1 docs/beginner/01-demo.md
diff --git a/.github/scripts/fixtures/lesson-quotes-block-unclosed/tree/docs/beginner/01-demo.md b/.github/scripts/fixtures/lesson-quotes-block-unclosed/tree/docs/beginner/01-demo.md
new file mode 100644
index 0000000..00e8538
--- /dev/null
+++ b/.github/scripts/fixtures/lesson-quotes-block-unclosed/tree/docs/beginner/01-demo.md
@@ -0,0 +1,26 @@
+# Demo lesson
+
+<sub>**Beginner** · Lesson 1 of 5 · about 20 minutes · Verified against Claude Code v2.1.285 (stable) on 2026-10-05</sub>
+
+## Worked example
+
+1. Type `/status`.
+2. End the session with `/exit`.
+
+Your `CLAUDE.md` can name the test command:
+
+````markdown
+# Project notes
+
+```bash
+npm test
+```
+````
+
+## Your turn
+
+1. Ask a question of your own.
+
+## Check
+
+Run the check.
diff --git a/.github/scripts/fixtures/lesson-quotes-block-unclosed/tree/practice/b-1.md b/.github/scripts/fixtures/lesson-quotes-block-unclosed/tree/practice/b-1.md
new file mode 100644
index 0000000..e47e59d
--- /dev/null
+++ b/.github/scripts/fixtures/lesson-quotes-block-unclosed/tree/practice/b-1.md
@@ -0,0 +1,33 @@
+---
+lesson: b-1
+title: "Demo lesson"
+stamp: "Verified against Claude Code v2.1.285 (stable) on 2026-10-05"
+---
+
+## intro
+- minutes: "about 20 minutes"
+
+## steps
+
+### W1 | Worked example step 1 of 2 | Look at /status
+- tier: guided
+- skill: status
+- where: claude
+- beat: do
+- verify: self
+- do: "Type `/status`."
+- code: point 3
+````markdown
+# Project notes
+
+```bash
+npm test
+```
+
+### Y1 | Your turn step 1 of 1 | Your own question
+- tier: hinted
+- skill: ask
+- where: claude
+- beat: do
+- verify: self
+- goal: "Ask a question of your own."
diff --git a/.github/scripts/lib/markdown.mjs b/.github/scripts/lib/markdown.mjs
index 6562dce..e500403 100644
--- a/.github/scripts/lib/markdown.mjs
+++ b/.github/scripts/lib/markdown.mjs
@@ -55,6 +55,31 @@ export function outsideFences(markdown) {
return out;
}
+// The lines of each fenced code block, without its fences, less the indent
+// its opening fence has, as CommonMark reads them: a fence three spaces in,
+// inside a numbered step, drops up to three spaces from each of its lines. A
+// block left open runs to the end of the page. Like outsideFences, it sees
+// only a fence indented at most three spaces and outside a blockquote, so a
+// fence four or more spaces in (as under step 10 or a nested bullet) or in an
+// alert isn't a block here, though GitHub shows it as one.
+export function fencedBlocks(markdown) {
+ const blocks = [];
+ let fence = null;
+ for (const line of markdown.split(/\r?\n/)) {
+ const f = line.match(FENCE);
+ if (fence) {
+ if (f && f[1][0] === fence.mark[0] && f[1].length >= fence.mark.length && /^\s*[`~]+\s*$/.test(line)) fence = null;
+ else fence.lines.push(line.replace(new RegExp(`^ {0,${fence.indent}}`), ''));
+ continue;
+ }
+ if (f) {
+ fence = { mark: f[1], indent: line.length - line.trimStart().length, lines: [] };
+ blocks.push(fence.lines);
+ }
+ }
+ return blocks;
+}
+
export function pageIds(markdown) {
const ids = [];
const seen = new Map();
diff --git a/.github/scripts/rules/lesson-quotes.mjs b/.github/scripts/rules/lesson-quotes.mjs
index c91e9f3..aec2c51 100644
--- a/.github/scripts/rules/lesson-quotes.mjs
+++ b/.github/scripts/rules/lesson-quotes.mjs
@@ -3,8 +3,11 @@
// template); .github/compat/learn.txt lists them. In a lesson file, every
// double-quoted `- key: "…"` value is the lesson's own text, except in a
// warm-up block, whose `- from: <lesson>` line points its quotes at that
-// earlier lesson's page. This rule fails when such a quote, the title, the
-// Stamp or a step count no longer matches its lesson. It reads each line and
+// earlier lesson's page. A fenced code block in a lesson file is a block of
+// that page, line for line, less the indent the page's fence has, and the
+// lines inside it are code, never quotes or headings. This rule fails when
+// such a quote or block, the title, the Stamp or a step count no longer
+// matches its lesson, or a block doesn't close. It reads each line and
// the front matter as the app does (learn/lib/content.mjs and
// checks/frontmatter.mjs in the template), so no spacing, quoting or line
// ending the app accepts can hide a quote. It needs the template's lesson
@@ -16,7 +19,7 @@ import { existsSync, readFileSync } from 'node:fs';
import { join, resolve } from 'node:path';
import { readText } from '../lib/tree.mjs';
import { changedFiles } from '../lib/git.mjs';
-import { outsideFences } from '../lib/markdown.mjs';
+import { fencedBlocks, outsideFences } from '../lib/markdown.mjs';
import { STAMP } from '../lib/stamps.mjs';
export const id = 'lesson-quotes';
@@ -25,6 +28,17 @@ export const modes = ['pr', 'scheduled'];
const LIST = '.github/compat/learn.txt';
const RAW = 'https://raw.githubusercontent.com/wesammustafa/claude-code-practice/main/learn/lessons';
const flat = (text) => text.replace(/\s+/g, ' ').trim();
+// A code block in a lesson file opens on a fence at the first column, three
+// backticks or tildes or more, and closes on a fence of the same character,
+// at least as long, as the app reads it (learn/lib/content.mjs in the
+// template). The app never shows the fence's info string, so only the
+// block's lines are compared.
+const LESSON_FENCE = /^(`{3,}|~{3,})([^`]*)$/;
+const closes = (fence, line) => {
+ const m = line.match(/^(`{3,}|~{3,})[ \t]*$/);
+ return Boolean(m) && m[1][0] === fence[0] && m[1].length >= fence.length;
+};
+const sameLines = (a, b) => a.length === b.length && a.every((line, i) => line === b[i]);
// The front matter as the app reads it: a copy of checks/frontmatter.mjs in
// the template (`key: value` lines, quoted or not, a trailing ` # comment`,
@@ -107,14 +121,14 @@ function stepCount(text, name) {
return count;
}
-// `pages` maps every listed lesson id to its page and text, for warm-ups;
-// `listed` holds every listed lesson id.
+// `pages` maps every listed lesson id whose page exists to its page, text and
+// fenced blocks, for the lesson itself and for warm-ups; `listed` holds every
+// listed lesson id.
function compare(lesson, page, rawPage, rawFile, pages, listed) {
const pageText = rawPage.replace(/\r\n?/g, '\n');
const file = rawFile.replace(/\r\n?/g, '\n');
const problems = [];
const say = (msg) => problems.push(`${page}: the app's learn/lessons/${lesson}.md ${msg}`);
- const body = flat(pageText);
const stamp = pageText.match(STAMP)?.[0];
const fields = frontmatter(rawFile);
const theirs = fields.stamp;
@@ -126,7 +140,29 @@ function compare(lesson, page, rawPage, rawFile, pages, listed) {
let heading = '(front matter)';
let from = null;
let warmup = false;
- for (const line of file.split('\n')) {
+ const lines = file.split('\n');
+ for (let i = 0; i < lines.length; i += 1) {
+ const line = lines[i];
+ // What a block or quote on this line is compared with: the lesson's own
+ // page, or in a warm-up the earlier lesson its `from` line names.
+ const source = pages.get(from ?? lesson);
+ const where = from ? `, from ${source?.page}` : '';
+ const that = from ? 'that lesson' : 'the lesson';
+ const open = line.match(LESSON_FENCE);
+ if (open) {
+ const end = lines.findIndex((l, k) => k > i && closes(open[1], l));
+ if (end === -1) {
+ say(`has a code block (${heading}) with no closing fence.`);
+ break;
+ }
+ const block = lines.slice(i + 1, end);
+ i = end;
+ if (source && !source.blocks.some((b) => sameLines(b, block))) {
+ const first = block.find((l) => l.trim());
+ say(`shows ${first === undefined ? 'an empty code block' : `a code block starting "${first}"`} (${heading}${where}), which is no longer in ${that}.`);
+ }
+ continue;
+ }
const h = line.match(/^#{2,3} (.+)$/);
if (h) {
heading = h[1];
@@ -147,11 +183,7 @@ function compare(lesson, page, rawPage, rawFile, pages, listed) {
continue;
}
const q = line.match(/^- [a-z-]+: (.+)$/)?.[1].trim().match(/^"(.*)"$/);
- if (!q) continue;
- if (from) {
- const source = pages.get(from);
- if (source && !source.body.includes(flat(q[1]))) say(`quotes "${q[1]}" (${heading}, from ${source.page}), which is no longer in that lesson.`);
- } else if (!body.includes(flat(q[1]))) say(`quotes "${q[1]}" (${heading}), which is no longer in the lesson.`);
+ if (q && source && !source.body.includes(flat(q[1]))) say(`quotes "${q[1]}" (${heading}${where}), which is no longer in ${that}.`);
}
return problems;
}
@@ -171,7 +203,10 @@ export async function run(ctx) {
}
const problems = [];
const pages = new Map(lessons.filter((l) => existsSync(join(ctx.root, l.page)))
- .map((l) => [l.lesson, { page: l.page, body: flat(readText(ctx.root, l.page).replace(/\r\n?/g, '\n')) }]));
+ .map((l) => {
+ const text = readText(ctx.root, l.page).replace(/\r\n?/g, '\n');
+ return [l.lesson, { page: l.page, body: flat(text), blocks: fencedBlocks(text) }];
+ }));
for (const { lesson, page } of lessons) {
if (!existsSync(join(ctx.root, page))) {
problems.push(`${LIST} lists ${page}, which doesn't exist`);
diff --git a/.github/scripts/test/checks.test.mjs b/.github/scripts/test/checks.test.mjs
index 71bfc1c..2d7d6a7 100644
--- a/.github/scripts/test/checks.test.mjs
+++ b/.github/scripts/test/checks.test.mjs
@@ -1,5 +1,6 @@
// Self-test for the guide checks: every committed fixture must get the
-// verdict it declares from the rule it names, and the real tree must pass.
+// verdict it declares from the rule it names, with any output it lists, and
+// the real tree must pass.
import { test } from 'node:test';
import assert from 'node:assert/strict';
import { readdirSync, readFileSync, existsSync } from 'node:fs';
@@ -35,6 +36,9 @@ for (const name of readdirSync(fixturesDir).sort()) {
assert.equal(code, 0, output);
assert.doesNotMatch(output, /^FAIL /m, output);
}
+ // `output` lists patterns the run's output must also match, so a fixture
+ // fails for its own reason, not for any problem the rule finds.
+ for (const pattern of spec.output ?? []) assert.match(output, new RegExp(pattern), output);
} finally {
tree.cleanup();
}
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 0ac996e..c149b81 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -218,9 +218,9 @@ It needs Node.js LTS, git, Ruby (for YAML), jq (for the examples' smoke tests),
| `static-validation` | JSON, YAML, skill or agent frontmatter, a workflow script or a shell script does not parse or lint |
| `inertness` | `examples/` holds a path Claude Code can load on its own, or a marketplace manifest not renamed to `dot-claude-plugin/`, or the repository root holds a `.claude-plugin/` folder |
| `smoke-tests` | An example's `test.sh` fails (only when the change touches `examples/`) |
-| `lesson-quotes` | With `LEARN_DIR` set to a practice template checkout's `learn/lessons` folder, or in the weekly run: a quoted line, the title, the Stamp or a step count in a lesson file of the template's learning app no longer matches its lesson (a warm-up's quotes, the earlier lesson its `from` line names). On a pull request that changes a lesson listed in `learn.txt`, it only warns |
+| `lesson-quotes` | With `LEARN_DIR` set to a practice template checkout's `learn/lessons` folder, or in the weekly run: a quoted line, a code block, the title, the Stamp or a step count in a lesson file of the template's learning app no longer matches its lesson (a warm-up's quotes and code blocks, the earlier lesson its `from` line names), or a code block has no closing fence. A code block must equal a fenced block of the lesson line for line, blank lines included, less the indent of the lesson's fence, which must be at most three spaces and outside a quote or alert. On a pull request that changes a lesson listed in `learn.txt`, it only warns |
-Each rule has known-bad fixtures under `.github/scripts/fixtures/`, one folder per case: `fixture.json` names the rule and the expected result, `tree/` holds the files, `base/` the state before a change, and `generate.mjs` writes anything that would be live Claude Code config if committed. If you change a rule, run the self-test too:
+Each rule has known-bad fixtures under `.github/scripts/fixtures/`, one folder per case: `fixture.json` names the rule, the expected result and, optionally, `output` patterns the check's output must match, `tree/` holds the files, `base/` the state before a change, and `generate.mjs` writes anything that would be live Claude Code config if committed. If you change a rule, run the self-test too:
```bash
node --test '.github/scripts/test/**/*.test.mjs'