htmlize
The name is the invocation, not the product. Keep htmlize because it
is discoverable and existing callers know it; do not describe the result
as "an HTML." The product is an artifact when one page answers one
job, and a technical briefing site when several reader questions must
cohere without being forced into one scroll.
HTML is the material. Explanation is the work.
Two modes:
- Create: turn task evidence and technical reasoning into a reading
experience.
- Review: diagnose an existing artifact or briefing site against the
same contracts.
The protocol is Gate -> Frame -> Map -> Build -> Check. Review mode runs
Check first, then repairs only the failed contracts.
1 -- Gate
Ask two questions in order: does this deserve HTML, and if so, does it
deserve a site?
Stay in markdown when any of these hold:
| Signal |
Why markdown wins |
| The answer fits in one screen |
A page would be ceremony |
| The deliverable is code or shell instructions |
Fences are already the right interface |
| It belongs in git and humans will edit the prose |
Markdown diffs and edits cleanly |
| It is read once, top to bottom |
Navigation would add no leverage |
| The structure is headings plus paragraphs |
HTML would only impersonate layout |
Use HTML when spatial comparison, diagrams, navigation, direct
manipulation, or a purpose-built view carries meaning prose would bury.
Length is supporting evidence, never the reason by itself.
Then choose the scale:
| Scale |
Contract |
| Page |
One reader question, one linear argument, one share target |
| Site |
Several independently useful questions, more than one reading path, or overview and implementation detail that should not compete in one scroll |
| Tool |
The reader changes, filters, tunes, or classifies data; export is the result |
| Deck |
A presenter controls sequence in a room; one idea per screen |
A site must earn at least three real pages. Do not split one essay at
arbitrary word counts. Split when each page has a distinct question,
can be linked on its own, and leaves the reader knowing what the next
page adds. Keep the primary navigation to 3-7 items; beyond that, the
model is probably a knowledge base and belongs to wiki-it.
If the gate says markdown, stop and deliver markdown. Saying no is the
protocol working.
2 -- Frame
Before markup, write four lines in working notes:
- Purpose: the decision or understanding this deliverable enables.
- Reader: who arrives, and what they already know.
- Thesis: the most important conclusion, in one sentence.
- Boundary: what system and time horizon are in scope.
If the thesis is unknown, investigate before designing. Navigation
cannot rescue unresolved thinking.
For a technical explanation, establish the whole before the parts:
- the problem and why it matters;
- the system boundary and architecture;
- component responsibilities and relationships;
- runtime mechanics, data flow, and invariants;
- alternatives, the selected design, and rejected options;
- failure modes, edge cases, tradeoffs, and verification;
- the resulting system and its limits.
This is a reasoning order, not a mandatory table of contents. Merge thin
ideas. Promote a subject into its own page only when the split improves
orientation or independent use.
Mark epistemic standing where it changes trust: observed fact,
measurement, inference, or design judgment. Link claims to evidence near
the claim; a bibliography cannot reveal which sentence it supports.
Done when the purpose, reader, thesis, and boundary are unambiguous.
3 -- Map
Choose the shape before styling:
| Job |
Shape |
| Compare approaches |
Exploration grid |
| Plan, RFC, implementation writeup |
Plan document or briefing site |
| Explain a system or subsystem |
Technical briefing site when non-linear; report when linear |
| Review a PR or code path |
Code review board |
| Status, incident, benchmark |
Report / explainer |
| Present to a room |
Arrow-key deck |
| Triage, reorder, tag, tune |
One-off editor |
Load patterns.md for every build. Load
sites.md in site mode; it defines the question map,
page anatomy, navigation, source bundle, and split/merge tests. Editors
also load export.md. Diagrams past a handful of
nodes load diagrams.md. When a decision rests
on numbers, load report.md.
One deliverable, one thesis. A site is not a folder of related pages; it
is one explanation whose pages answer different questions. Write the
page map in site.json before writing page bodies. The map is done when:
- every page title is a reader question in disguise;
- every page has a one-sentence job and an explicit next step;
- two useful reading paths can be named (for example reviewer and
implementer); and
- no page exists merely because a template supplied it.
4 -- Build
Start from the matching asset:
assets/templates/document.html -- single-page plans, reports,
reviews, and explainers;
assets/templates/site/ -- multi-page technical briefing;
assets/templates/tool.html -- editors and micro-tools;
assets/templates/deck.html -- presentations.
For a site, run scripts/scaffold-site.sh <output-dir>, replace the
SLOT: markers, remove unearned pages, synchronize site.json and every
primary nav, then run scripts/check-site.py <output-dir>. The site is a
self-contained bundle: shared local CSS and JS are correct; network
dependencies are not. A single-page artifact remains one self-contained
.html file.
Build to these invariants:
- Five-second orientation. Title, thesis, scope, and the useful next
choice appear before decoration or detail.
- Real information architecture. Pages divide questions; sections
divide one answer. No client-side router, tab maze, or pagination by
length. Real links survive reload, sharing, print, and no JavaScript.
- Whole to parts. Overview first, system map second, mechanisms and
evidence after. Do not make readers infer the whole from component
pages.
- Calm typography and semantic layout. Serif body for documents,
sans for tools, 60-75ch measure. Use tables for tabular data, code
elements for code, inline SVG for diagrams, and columns only for real
comparison.
- Color carries meaning. Status, category, or emphasis only. Mood
gradients, ornamental cards, and emoji headings reduce trust.
- Safe DOM construction. Variables enter through
textContent,
attributes, or createElement; never variable innerHTML. No
localStorage or sessionStorage.
- Progressive enhancement. Core reading and navigation work without
JavaScript. JS may add active navigation, diagram inspection, and
export ergonomics; it may not contain the explanation.
- Inspectable diagrams. Render complex diagrams to inline SVG at
build time.
figure.diagram gains optional 50%-500% zoom and a
viewport-filling mode while preserving selectable text and a fitted
no-JS baseline.
- Responsive, dark, reduced-motion, print. Phone layouts preserve
sequence; print expands hidden detail and fits diagrams; dark mode
remaps rendered SVG palettes.
- Evidence travels. Fill the colophon. A durable briefing includes
its markdown reasoning source and editable diagram sources under
sources/; HTML is the view, not the only record.
- No placeholders. Use the task's real data. A visible
SLOT:,
lorem ipsum, empty editor, or generic option is unfinished work.
- Descriptive paths.
queue-architecture/decisions.html, not
output/page-3.html. Page filenames name concepts, not sequence.
Interactive state lives in memory and leaves through an explicit export.
The export contract is in export.md.
5 -- Check
Read the result as three people: a first-time reader seeking the thesis,
a reviewer challenging the design, and an implementer looking for exact
mechanics. Each must find their next page without guessing.
In site mode run:
python3 scripts/check-site.py path/to/site
It checks the manifest, page/nav agreement, local links and fragments,
duplicate IDs, semantic landmarks, source presence, external
subresources, unsafe browser APIs, and unfinished markers. It does not
judge whether the explanation is true; verify that against the sources.
Review mode reports one row per violation:
| Issue |
Fix |
Why |
| One scroll contains several independent questions |
Split by question into a briefing site |
Page boundaries restore orientation and shareable context |
| Site pages are chapters named Part 1 / Part 2 |
Name pages for the question or concept |
Navigation should predict the answer behind the link |
| Overview is a link list with no thesis |
State problem, system boundary, architecture, result |
A map without an argument does not orient |
| The same navigation differs between pages |
Make site.json canonical and synchronize every nav |
A moving map destroys spatial memory |
| Essential content exists only behind JS |
Render it in HTML; enhance behavior only |
Links, print, accessibility, and file viewing must survive JS failure |
innerHTML receives a variable |
textContent + createElement |
Prevents injection from task data |
| Storage APIs retain throwaway state |
In-memory state + explicit export |
Sandboxed access can throw; artifacts should leave no residue |
| External script, stylesheet, font, or image |
Bundle it locally or inline it |
The deliverable must outlive another server |
| Diagram is unreadable at fitted width |
Add the diagram viewer; split hairballs at ~15 nodes |
Browser zoom should not be the inspection interface |
| Diagram controls lack keyboard/focus behavior |
Real buttons, labeled range, focus trap and return |
Fullscreen must not strand keyboard users |
| Hand-drawn complex SVG |
Render .dot, .d2, or .mmd at build time |
Layout and edge routing are computation |
| SVG text collides with shapes |
Resize shapes or use wrapped HTML in foreignObject |
SVG text does not wrap |
| Numeric columns are ragged or axes mislead |
Apply report.md's units, precision, spread, and zero-baseline rules |
Visual polish cannot repair untrustworthy evidence |
| Stacked prose, ornamental cards, gradient hero |
Use spatial structure or return to markdown |
HTML without information shape is cost without leverage |
| Artifact breaks on phone, dark mode, or print |
Repair all three modes |
Briefings travel across surfaces |
| Durable reasoning exists only in HTML |
Include markdown and diagram sources |
HTML is a generated view, not an editable record |
Done when the mechanical checker passes, every link and interaction has
been exercised, and the thesis remains clear when skimming only titles,
diagrams, captions, and decision statements.
Boundaries
- kiln owns production product interfaces. htmlize owns finite agent
deliverables and the micro-tools used to inspect them.
- wiki-it owns a growing, interlinked, maintained corpus. A briefing
site has one thesis, a finite page map, and a completion state.
- animate-it owns motion craft. Artifacts keep motion to functional
150-250ms transitions and honor reduced motion.
- drop owns publishing and review URLs. htmlize produces the local
bundle; drop re-checks privacy before it leaves the machine.
- Hand-maintained README, CONTRIBUTING, and product docs stay in
markdown or their existing documentation system.
Accessibility and privacy
Color never acts alone. Controls are native elements with visible focus.
Each page has one h1, ordered headings, a skip link, landmarks, and a
plain-link path forward. Fullscreen diagram inspection returns focus to
its trigger and permits Escape at all times.
Artifacts carry real ticket text, code, names, and configuration. Treat
the bundle as data: do not commit it to a public repository or publish it
without checking every included file. A link is publication.
Output
Create mode reports:
## Gate
[markdown, page, site, tool, or deck -- and why]
## Frame
[purpose, reader, thesis, boundary]
## Map
[shape; for sites, page questions and reading paths]
## Deliverable
[path to the file or site index]
## Check
[mechanical result, interaction checks, intentional tradeoffs]
Review mode reports the violation table, then the repaired path when
repairs were requested.
References
| File |
Load when |
| patterns.md |
Building any artifact |
| sites.md |
Building or reviewing a multi-page briefing |
| style.md |
Writing or extending CSS |
| diagrams.md |
A flow, architecture, sequence, or state diagram appears |
| report.md |
A decision rests on numbers |
| export.md |
The artifact is interactive or affects durable docs |
| prior-art.md |
Studying lineage and alternatives; not an operational dependency |
Bundled tooling renders diagrams (render-diagram.sh), scaffolds a
briefing (scaffold-site.sh), and checks its integrity
(check-site.py).
1---2name: htmlize3description: Technical explanation and HTML artifact protocol. Decides whether a deliverable beats markdown, models the reader's questions, chooses a single page or multi-page briefing site, builds it against a craft baseline, and reviews existing artifacts. Fires on three branches: an explicit ask for an HTML, visual, interactive, or site-level deliverable; a plan, report, system explainer, comparison, deck, or diagram whose structure is lost in linear markdown; and improving an HTML deliverable that looks generic, fragmented, or hard to navigate. Production frontend is kiln's territory; a growing knowledge base is wiki-it's; hand-maintained project docs should remain markdown.4---56# htmlize78The name is the invocation, not the product. Keep `htmlize` because it9is discoverable and existing callers know it; do not describe the result10as "an HTML." The product is an **artifact** when one page answers one11job, and a **technical briefing site** when several reader questions must12cohere without being forced into one scroll.1314HTML is the material. Explanation is the work.1516Two modes:1718- **Create:** turn task evidence and technical reasoning into a reading19 experience.20- **Review:** diagnose an existing artifact or briefing site against the21 same contracts.2223The protocol is Gate -> Frame -> Map -> Build -> Check. Review mode runs24Check first, then repairs only the failed contracts.2526## 1 -- Gate2728Ask two questions in order: does this deserve HTML, and if so, does it29deserve a site?3031Stay in markdown when any of these hold:3233| Signal | Why markdown wins |34|---|---|35| The answer fits in one screen | A page would be ceremony |36| The deliverable is code or shell instructions | Fences are already the right interface |37| It belongs in git and humans will edit the prose | Markdown diffs and edits cleanly |38| It is read once, top to bottom | Navigation would add no leverage |39| The structure is headings plus paragraphs | HTML would only impersonate layout |4041Use HTML when spatial comparison, diagrams, navigation, direct42manipulation, or a purpose-built view carries meaning prose would bury.43Length is supporting evidence, never the reason by itself.4445Then choose the scale:4647| Scale | Contract |48|---|---|49| **Page** | One reader question, one linear argument, one share target |50| **Site** | Several independently useful questions, more than one reading path, or overview and implementation detail that should not compete in one scroll |51| **Tool** | The reader changes, filters, tunes, or classifies data; export is the result |52| **Deck** | A presenter controls sequence in a room; one idea per screen |5354A site must earn at least three real pages. Do not split one essay at55arbitrary word counts. Split when each page has a distinct question,56can be linked on its own, and leaves the reader knowing what the next57page adds. Keep the primary navigation to 3-7 items; beyond that, the58model is probably a knowledge base and belongs to wiki-it.5960If the gate says markdown, stop and deliver markdown. Saying no is the61protocol working.6263## 2 -- Frame6465Before markup, write four lines in working notes:66671. **Purpose:** the decision or understanding this deliverable enables.682. **Reader:** who arrives, and what they already know.693. **Thesis:** the most important conclusion, in one sentence.704. **Boundary:** what system and time horizon are in scope.7172If the thesis is unknown, investigate before designing. Navigation73cannot rescue unresolved thinking.7475For a technical explanation, establish the whole before the parts:76771. the problem and why it matters;782. the system boundary and architecture;793. component responsibilities and relationships;804. runtime mechanics, data flow, and invariants;815. alternatives, the selected design, and rejected options;826. failure modes, edge cases, tradeoffs, and verification;837. the resulting system and its limits.8485This is a reasoning order, not a mandatory table of contents. Merge thin86ideas. Promote a subject into its own page only when the split improves87orientation or independent use.8889Mark epistemic standing where it changes trust: observed fact,90measurement, inference, or design judgment. Link claims to evidence near91the claim; a bibliography cannot reveal which sentence it supports.9293Done when the purpose, reader, thesis, and boundary are unambiguous.9495## 3 -- Map9697Choose the shape before styling:9899| Job | Shape |100|---|---|101| Compare approaches | Exploration grid |102| Plan, RFC, implementation writeup | Plan document or briefing site |103| Explain a system or subsystem | Technical briefing site when non-linear; report when linear |104| Review a PR or code path | Code review board |105| Status, incident, benchmark | Report / explainer |106| Present to a room | Arrow-key deck |107| Triage, reorder, tag, tune | One-off editor |108109Load [patterns.md](references/patterns.md) for every build. Load110[sites.md](references/sites.md) in site mode; it defines the question map,111page anatomy, navigation, source bundle, and split/merge tests. Editors112also load [export.md](references/export.md). Diagrams past a handful of113nodes load [diagrams.md](references/diagrams.md). When a decision rests114on numbers, load [report.md](references/report.md).115116One deliverable, one thesis. A site is not a folder of related pages; it117is one explanation whose pages answer different questions. Write the118page map in `site.json` before writing page bodies. The map is done when:119120- every page title is a reader question in disguise;121- every page has a one-sentence job and an explicit next step;122- two useful reading paths can be named (for example reviewer and123 implementer); and124- no page exists merely because a template supplied it.125126## 4 -- Build127128Start from the matching asset:129130- `assets/templates/document.html` -- single-page plans, reports,131 reviews, and explainers;132- `assets/templates/site/` -- multi-page technical briefing;133- `assets/templates/tool.html` -- editors and micro-tools;134- `assets/templates/deck.html` -- presentations.135136For a site, run `scripts/scaffold-site.sh <output-dir>`, replace the137`SLOT:` markers, remove unearned pages, synchronize `site.json` and every138primary nav, then run `scripts/check-site.py <output-dir>`. The site is a139self-contained **bundle**: shared local CSS and JS are correct; network140dependencies are not. A single-page artifact remains one self-contained141`.html` file.142143Build to these invariants:1441451. **Five-second orientation.** Title, thesis, scope, and the useful next146 choice appear before decoration or detail.1472. **Real information architecture.** Pages divide questions; sections148 divide one answer. No client-side router, tab maze, or pagination by149 length. Real links survive reload, sharing, print, and no JavaScript.1503. **Whole to parts.** Overview first, system map second, mechanisms and151 evidence after. Do not make readers infer the whole from component152 pages.1534. **Calm typography and semantic layout.** Serif body for documents,154 sans for tools, 60-75ch measure. Use tables for tabular data, code155 elements for code, inline SVG for diagrams, and columns only for real156 comparison.1575. **Color carries meaning.** Status, category, or emphasis only. Mood158 gradients, ornamental cards, and emoji headings reduce trust.1596. **Safe DOM construction.** Variables enter through `textContent`,160 attributes, or `createElement`; never variable `innerHTML`. No161 `localStorage` or `sessionStorage`.1627. **Progressive enhancement.** Core reading and navigation work without163 JavaScript. JS may add active navigation, diagram inspection, and164 export ergonomics; it may not contain the explanation.1658. **Inspectable diagrams.** Render complex diagrams to inline SVG at166 build time. `figure.diagram` gains optional 50%-500% zoom and a167 viewport-filling mode while preserving selectable text and a fitted168 no-JS baseline.1699. **Responsive, dark, reduced-motion, print.** Phone layouts preserve170 sequence; print expands hidden detail and fits diagrams; dark mode171 remaps rendered SVG palettes.17210. **Evidence travels.** Fill the colophon. A durable briefing includes173 its markdown reasoning source and editable diagram sources under174 `sources/`; HTML is the view, not the only record.17511. **No placeholders.** Use the task's real data. A visible `SLOT:`,176 lorem ipsum, empty editor, or generic option is unfinished work.17712. **Descriptive paths.** `queue-architecture/decisions.html`, not178 `output/page-3.html`. Page filenames name concepts, not sequence.179180Interactive state lives in memory and leaves through an explicit export.181The export contract is in [export.md](references/export.md).182183## 5 -- Check184185Read the result as three people: a first-time reader seeking the thesis,186a reviewer challenging the design, and an implementer looking for exact187mechanics. Each must find their next page without guessing.188189In site mode run:190191```bash192python3 scripts/check-site.py path/to/site193```194195It checks the manifest, page/nav agreement, local links and fragments,196duplicate IDs, semantic landmarks, source presence, external197subresources, unsafe browser APIs, and unfinished markers. It does not198judge whether the explanation is true; verify that against the sources.199200Review mode reports one row per violation:201202| Issue | Fix | Why |203|---|---|---|204| One scroll contains several independent questions | Split by question into a briefing site | Page boundaries restore orientation and shareable context |205| Site pages are chapters named Part 1 / Part 2 | Name pages for the question or concept | Navigation should predict the answer behind the link |206| Overview is a link list with no thesis | State problem, system boundary, architecture, result | A map without an argument does not orient |207| The same navigation differs between pages | Make `site.json` canonical and synchronize every nav | A moving map destroys spatial memory |208| Essential content exists only behind JS | Render it in HTML; enhance behavior only | Links, print, accessibility, and file viewing must survive JS failure |209| `innerHTML` receives a variable | `textContent` + `createElement` | Prevents injection from task data |210| Storage APIs retain throwaway state | In-memory state + explicit export | Sandboxed access can throw; artifacts should leave no residue |211| External script, stylesheet, font, or image | Bundle it locally or inline it | The deliverable must outlive another server |212| Diagram is unreadable at fitted width | Add the diagram viewer; split hairballs at ~15 nodes | Browser zoom should not be the inspection interface |213| Diagram controls lack keyboard/focus behavior | Real buttons, labeled range, focus trap and return | Fullscreen must not strand keyboard users |214| Hand-drawn complex SVG | Render `.dot`, `.d2`, or `.mmd` at build time | Layout and edge routing are computation |215| SVG text collides with shapes | Resize shapes or use wrapped HTML in `foreignObject` | SVG text does not wrap |216| Numeric columns are ragged or axes mislead | Apply report.md's units, precision, spread, and zero-baseline rules | Visual polish cannot repair untrustworthy evidence |217| Stacked prose, ornamental cards, gradient hero | Use spatial structure or return to markdown | HTML without information shape is cost without leverage |218| Artifact breaks on phone, dark mode, or print | Repair all three modes | Briefings travel across surfaces |219| Durable reasoning exists only in HTML | Include markdown and diagram sources | HTML is a generated view, not an editable record |220221Done when the mechanical checker passes, every link and interaction has222been exercised, and the thesis remains clear when skimming only titles,223diagrams, captions, and decision statements.224225## Boundaries226227- **kiln** owns production product interfaces. htmlize owns finite agent228 deliverables and the micro-tools used to inspect them.229- **wiki-it** owns a growing, interlinked, maintained corpus. A briefing230 site has one thesis, a finite page map, and a completion state.231- **animate-it** owns motion craft. Artifacts keep motion to functional232 150-250ms transitions and honor reduced motion.233- **drop** owns publishing and review URLs. htmlize produces the local234 bundle; drop re-checks privacy before it leaves the machine.235- Hand-maintained README, CONTRIBUTING, and product docs stay in236 markdown or their existing documentation system.237238## Accessibility and privacy239240Color never acts alone. Controls are native elements with visible focus.241Each page has one `h1`, ordered headings, a skip link, landmarks, and a242plain-link path forward. Fullscreen diagram inspection returns focus to243its trigger and permits Escape at all times.244245Artifacts carry real ticket text, code, names, and configuration. Treat246the bundle as data: do not commit it to a public repository or publish it247without checking every included file. A link is publication.248249## Output250251Create mode reports:252253```text254## Gate255[markdown, page, site, tool, or deck -- and why]256257## Frame258[purpose, reader, thesis, boundary]259260## Map261[shape; for sites, page questions and reading paths]262263## Deliverable264[path to the file or site index]265266## Check267[mechanical result, interaction checks, intentional tradeoffs]268```269270Review mode reports the violation table, then the repaired path when271repairs were requested.272273## References274275| File | Load when |276|---|---|277| [patterns.md](references/patterns.md) | Building any artifact |278| [sites.md](references/sites.md) | Building or reviewing a multi-page briefing |279| [style.md](references/style.md) | Writing or extending CSS |280| [diagrams.md](references/diagrams.md) | A flow, architecture, sequence, or state diagram appears |281| [report.md](references/report.md) | A decision rests on numbers |282| [export.md](references/export.md) | The artifact is interactive or affects durable docs |283| [prior-art.md](references/prior-art.md) | Studying lineage and alternatives; not an operational dependency |284285Bundled tooling renders diagrams (`render-diagram.sh`), scaffolds a286briefing (`scaffold-site.sh`), and checks its integrity287(`check-site.py`).