Specialized Content Rules: Kanji and Programming Lessons

Claude Rules Workflow

Chapter 5 · Specialized Content Rules: Kanji and Programming Lessons

Chapter 4 covered rules for lessons in a spoken language. This chapter covers two more content families that each needed their own dedicated rule set, for two genuinely different reasons: kanji pages are interactive and dual-purpose in a way no other content type on the site is, and programming lessons needed L2's own convention generalized beyond Python to any language without losing Python's already-established, carefully-tuned format.

K1 — The Stroke Animation Method

Every kanji page includes a stroke-order animation. K1's own rule is narrow but firm: build it with a self-hosted stroke-data library, never a CDN-script approach that makes the page's own functionality depend on some third party's server staying online forever. A kanji page should work exactly the same whether that external service is reachable or not — because it never talks to one in the first place.

K2 — Dual-Write: One Page, Two Locations

Every kanji page gets written to two places at once, kept identical: an archive copy that's deliberately excluded from the live site's own routing (a pure reference folder), and the live copy actually served to visitors. Skipping either half isn't a shortcut — it either breaks the live site or silently stops maintaining the permanent archive, so K2 treats the second write as a cheap, non-optional step rather than an afterthought.

K3 — Keeping the Tiles Page in Sync

A newly generated kanji page is useless if nothing links to it. K3 requires the kanji tiles grid's own kanjiList array to be updated in the very same step a kanji page is written or rewritten — character, meaning, and href, all added together, never as a separate follow-up task.

A real, previously-broken sitewide link, found and fixed
K3 also documents its own back-link convention — every individual kanji page's own "← Kanji Grid" link should point at the tiles page's real, fixed live URL. A previous version of that same rule instead pointed at a stale, now-nonexistent old-site URL, and every single kanji page's own back-link was broken sitewide as a result — not a hypothetical risk, an actual bug that existed until the 2026-08 rules review caught and fixed it. It's a concrete illustration of exactly the kind of drift Chapter 7 covers more generally: a rule can describe the right behaviour perfectly and still go stale the moment the thing it's pointing at moves.

K4 — The World of Kanji Book Cross-Reference

The user owns a printed kanji reference book indexed by number rather than page. K4 lets a generated page link back to that number as one more tag alongside the page's existing JLPT-level and stroke-count badges — but only when a real number is actually supplied. A request with no reference number at all should be met with a direct question rather than a guess, and an explicit 0 is treated as "no reference," not as a literal reference number 0 — the tag is simply omitted in that case, never left as an empty placeholder.

Programming Lessons: P8 and PL1–PL3

A separate, unrelated content family: standalone, one-off lessons on a single programming topic — closer in spirit to Chapter 4's own language lessons than to a numbered course, since there's no fixed chapter count and no Fundamentals/Intermediate/Advanced track.

RuleCovers
P8The original Python-specific format: a "Coming from Java/JavaScript" callout, a concept-card grid, worked examples, a quick-reference table, and a closing gotchas box
PL1Generalizes P8's own shape to any programming language, reusing L2's colon syntax — disambiguated from a natural-language lesson purely by whether the word before the colon names a programming language or a spoken one
PL2Two modifiers — "no exercises" and "exercises only" — controlling whether a companion exercise chapter is generated alongside the main lesson
PL3The exercise chapter's own format: a separate file, at least 10 real, meaty challenges, each linked to its own worked .txt solution

By default, a PL1 request produces two files — the lesson and its exercise companion — unless a modifier says otherwise. That default matters because it's the one place in this chapter where a single prompt silently expands into two pieces of generated content rather than one.

python: and Python (the language) are handled by PL1, not L2 — despite reusing L2's own colon syntax
python: for loops and japanese:directions look identical in shape, but only one of them is a Chapter 4 language lesson. The disambiguation is entirely by the word before the colon — if it names a language already in the L1 spoken-language table, it's L2; if it names a programming language, it's PL1. The two systems share a prompt shape on purpose, but never share output, and there's currently no real name collision to worry about between the two tables.
AspectKanji Pages (K1–K4)Programming Lessons (P8/PL1–3)
StorageDual-write: archive copy + live copySingle copy under content/programming/.../
PDF?None — interactive content doesn't translate to a static PDFYes, one per lesson, plus one for its exercise companion
Sync obligationThe tiles page's own kanjiList array, every timeNone comparable — no shared index page to update
Default outputOne page per kanjiTwo files by default (lesson + exercises), unless a modifier says one
Both families exist because a shared, generic template genuinely didn't fit
Neither kanji pages nor programming lessons could have simply reused the numbered-course template (P1–P13) or the language-lesson template (L1–L7) as-is — a kanji page needs a live stroke animation and a permanent, non-routed archive twin that no course chapter needs; a programming lesson needs a companion exercise file with real, substantial challenges that a spoken-language lesson's own 20-word vocabulary table has no equivalent of. Each specialized rule family exists to cover exactly the gap the more general rules left open.

Coding Challenges

Challenge 1

A kanji page is generated and written to its live-site location only, with the archive copy skipped "to save a step." Using K2, explain exactly what real, concrete problem this creates later.

📄 View solution
Challenge 2

A user sends the prompt "python: dictionaries exercises only." Explain what this should produce, and why the wording of the modifier matters based on PL2.

📄 View solution
Challenge 3

Explain, using this chapter's own comparison table, why kanji pages have no PDF at all while every programming lesson gets one — what's the underlying reasoning, not just the fact itself?

📄 View solution

Chapter 5 Quick Reference

  • K1 — self-hosted stroke animation, never a CDN dependency
  • K2 — every kanji page written to both an archive copy AND the live copy, kept identical
  • K3 — the tiles page's kanjiList array updated in the same step, plus a correct back-link to the real live tiles URL
  • K4 — the World of Kanji book number tag, added only when a real number is given; 0 means "omit it," not "literal reference 0"
  • P8 — the original Python-specific weekly-lesson format
  • PL1 — generalizes P8/L2's colon syntax to any programming language
  • PL2 — "no exercises" / "exercises only" modifiers control whether one or two files get generated
  • PL3 — the exercise-chapter format: 10+ real challenges, each with its own worked .txt solution
  • Next chapter: the Sidebar unification — Links, My Tools, Sidebar Lessons, and Cheat Sheets