cd /news/ai-tools/show-hn-pencil-llm-writes-whiteboard… · home › topics › ai-tools › article
[ARTICLE · art-173868] src=github.com ↗ pub= topic=ai-tools verified=true sentiment=↑ positive

Show HN: Pencil – LLM writes whiteboard lessons as JSON, a browser draws them

A developer released Pencil, an open-source tool that has a large language model write a whiteboard lesson as strict JSON, validates that JSON with a Node script, and plays it back in a single-file browser player that draws SVG figures in sync with narration by word index. The planner defaults to DeepSeek's deepseek-flash model, requires only the Python standard library, and prints token counts and per-lesson cost from user-supplied input and output token prices plus an --inr-per-usd rate of 88; an Anthropic provider path exists but is untested live. The project includes a repair loop that feeds validator issues back to the model, unit tests using a scripted fake model, and headless-Chrome player tests covering playback, quizzes, bad input and XSS safety.

key takeaway

Pencil validates LLM-generated lesson JSON with validator.js and loops validator issues back to the model for repair, while the planner prints token counts and cost per lesson from user-supplied per-1M-token prices.

read2 min views11 publishedNov 21, 2026
Show HN: Pencil – LLM writes whiteboard lessons as JSON, a browser draws them
Image: Michielbdejong (auto-discovered)

A small open-source take on the "AI teacher that draws on a whiteboard" idea: a model writes a lesson as strict JSON, code validates it, and a browser player draws it in time with the narration. Everything here (prompts, schema, player) is original code.

Live demo: a lesson written by DeepSeek, played by the single-file player (press Play, untick "Silent" for voice).

topic --> planner.py --(LLM)--> lesson.json --> validator.js --(issues)--> repair loop
                                                      |
                                                      v
                                       player.html (SVG draw-on + speech, cues by word index)
open player.html                       # plays the built-in rainbow sample (no server needed)
node validator.js samples/rainbow.json # exit 0 = valid; prints issues as JSON otherwise

export DEEPSEEK_API_KEY=...           # default provider; stdlib only, no pip install needed
python3 planner.py --topic "How tides work" --minutes 4 --out lesson.json \
    --price-in <USD per 1M input tokens> --price-out <USD per 1M output tokens> --inr-per-usd 88

--model (or env LESSON_MODEL) picks the model; the default is deepseek-flash. Prices are inputs on purpose: the planner prints tokens and cost per lesson so you can measure your real number. --topic - reads the topic from stdin; --research-file adds reference notes; --dry-run prints the prompts.

beats[] each hold narration plus ops[]: heading, paragraph, callout, definition, table, figure. A figure is parts[] of marks[] (circle, ellipse, rect, line, path, label). Each part has a cue: the index of the narration word at which it is drawn. Paths use absolute commands only. checks[] are end-of-lesson multiple-choice questions.

python3 -m unittest test_planner   # repair loop, parsing, cost math (fake LLM, no key needed)
python3 test_player.py             # headless Chrome: playback, quiz, bad input, XSS safety
python3 build.py                   # regenerate player.html from player.template.html
  • Unit tests use a scripted fake model; live runs have been done with DeepSeek (deepseek-flash ). The Anthropic path is untested live.
  • Narration uses the browser's built-in speech synthesis. Swap in an on-device TTS for a consistent voice.
  • The wobble effect is opt-in: the SVG displacement filter can leave small notches in thin strokes.
  • No accounts, storage, uploads, video export or billing.
── more in #ai-tools 4 stories · sorted by recency
── more on @pencil 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
→ Live at https://your-agent.zahid.host ✓
Get free account → Pricing
from €0/mo · no card required
LIVE [news/show-hn-pencil-llm-w…] indexed:0 read:2min 2026-11-21 · —