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.
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.
| Rule | Covers |
|---|---|
| P8 | The 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 |
| PL1 | Generalizes 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 |
| PL2 | Two modifiers — "no exercises" and "exercises only" — controlling whether a companion exercise chapter is generated alongside the main lesson |
| PL3 | The 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: 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.
| Aspect | Kanji Pages (K1–K4) | Programming Lessons (P8/PL1–3) |
|---|---|---|
| Storage | Dual-write: archive copy + live copy | Single copy under content/programming/.../ |
| PDF? | None — interactive content doesn't translate to a static PDF | Yes, one per lesson, plus one for its exercise companion |
| Sync obligation | The tiles page's own kanjiList array, every time | None comparable — no shared index page to update |
| Default output | One page per kanji | Two files by default (lesson + exercises), unless a modifier says one |
Coding Challenges
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 solutionA 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 solutionExplain, 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 solutionChapter 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