HTML Visualizer
Generate content-layer artifacts: standalone HTML files that feel like Claude-generated artifacts in usefulness, routing, interaction, and polish. Do not draw Claude's host chrome unless the user explicitly asks for a Claude UI mockup.
The output must be:
- independently understandable outside chat
- useful in the first viewport
- matched to the content type, not forced into one diagram style
- responsive, dark-mode aware, and visually restrained
- honest about AI, storage, publishing, and external services
- easy for a later agent to modify through stable structure and metadata
- verified with the bundled scripts whenever possible
Mandatory Reading
For every artifact-like task, read these first:
references/artifact-product-protocol.mdreferences/content-visualization-routing.mdreferences/visualization-routing-examples.mdreferences/artifact-kind-patterns.mdreferences/artifact-visual-effects.mdreferences/artifact-output-contract.mdreferences/typography-and-color.mdreferences/claude-official-alignment.mdreferences/claude-field-observations.md
Then read only the specific reference files needed for the selected kind, subject, or rendering technique.
For skill maintenance or “not Claude-like enough” feedback, also read:
- references/artifact-forward-test.md
- references/artifact-failure-remediation.md
- references/strategy-confidence-audit.md
- references/claude-field-research-protocol.md
- references/TESTING.md
- references/claude-official-alignment.md
- references/claude-field-observations.md
Core Workflow
Before writing HTML, form a routing brief. You do not need to show it unless useful, but the file must reflect it.
artifact_needed: yes/no, and why
artifact_kind: html-app / ai-app / visual-explainer / interactive-simulation / data-viz / courseware / ui-prototype / document / code-file / diagram-text
content_archetype: process / dynamic-flow / mechanism / state-machine / data-table / trend / comparison / composition / hierarchy / relationship / timeline / spatial / text-evidence / formula-parameter / ui-workflow / tool / ai-tool / lesson / document / code-system
experience_model: product-prototype / work-tool / ai-assistant / learning-game-lesson / data-analysis / mechanism-explainer / shareable-document
primary_user_value: what the user gets immediately in the first viewport
canvas_structure: single-visual / split-inspector / dashboard / workbench / courseware / document / prototype-stage / app-shell
interaction_intensity: static / guided / animated / manipulative / generative
visual_style_profile: default Claude-like neutral / user preference as accent / provided brand system, plus boundaries
primary_reference_files: exact references to follow
must_have_actions: copy / export / reset / history / download / pause / none
verification_focus: formulas, data, states, motion, accessibility, or viewport concerns to prove
rejected_alternatives: at least one tempting but wrong approach
Execution order:
- Run the artifact decision gate before creating files.
- If
artifact_needed:no, stop artifact generation: the deliverable is a direct answer in chat or a small code block; create no HTML file, HTML wrapper,artifact-meta, dashboard, fake canvas, or placeholder file. - If the user asked for current data, real images, file generation, code execution, web research, or connector/private data and the required source/tool/authorization is missing, route to the matching boundary reference instead of inventing an artifact.
- If
artifact_needed:yes, pickartifact_kind,content_archetype, andexperience_modelbefore choosing SVG/Canvas/Chart.js. - Match the closest example in
references/visualization-routing-examples.md. - Read the kind recipe in
references/artifact-kind-patterns.md. - Read visual, output, and typography references.
- Read only the domain-specific references needed by the selected route.
- Draft the page blueprint: first viewport, primary surface, support surface, states, actions, metadata.
- Generate the HTML.
- Run validation commands and fix failures before delivery.
Routing Rules
Use the user's real intent, not keywords alone:
| User intent | Preferred route | Avoid |
|---|---|---|
| Understand a mechanism | visual-explainer + mechanism-explainer |
generic steps or decorative cards |
| Watch a process happen | visual-explainer + dynamic-flow/state-machine + animated |
static topology |
| Explore parameters | interactive-simulation + learning-game-lesson or work-tool |
sliders that only change text |
| Analyze data | data-viz + data-analysis |
pie charts for trends, isolated charts without source data |
| Compare options | data-viz/document + comparison |
colored cards without criteria |
| Build a tool | html-app + work-tool |
static demo shell |
| Explore algorithmic/generative visuals | html-app + composition + work-tool + generative |
static poster only, unseeded random output, or image model claims |
| Build an AI tool | ai-app + ai-assistant |
fake realtime AI or browser API keys |
| Teach or explain a lesson | courseware + learning-game-lesson |
animation before reasoning |
| Prototype product UI | ui-prototype + product-prototype |
marketing landing page |
| Claude Design-like prototype/canvas | ui-prototype + product-prototype + design system boundary; include context attachments, chat vs inline comments, selected component inspector, responsive variants, export/handoff boundary, and known limitations |
fake Claude Design project, fake organization share link, fake PPTX/PDF/Canva export, fake Claude Code handoff |
| Share a report/spec | document + shareable-document |
poster/dashboard decoration |
| Provide a short code snippet | no artifact; direct code answer | HTML wrapper or dashboard |
| One-off inline custom visual in chat | no artifact + native-widget-boundary; produce compact chat visual/handoff only, and offer save/export upgrade only if requested |
full HTML artifact, artifact-meta, or persistent artifact by default |
| Weather, recipe, sports, or one-off data display | no artifact + native-widget-boundary; use source-backed data or fallback |
fake HTML widgets, maps, dashboards, or invented current data |
| Turn provided weather snapshots into a reusable planner | html-app + data-table + work-tool + guided + native-widget-boundary; include weather snapshot planner, weather data display boundary, source-backed snapshot, retrieved at, source/time, snapshot/live boundary, no fake Google Maps, no fake weather, activity planner, chart/table, and copy/export/reset |
static weather card only, fake Google Maps, fake weather, fake live refresh, current forecast without source |
| Turn interactive inputs into a reusable decision tool | html-app + tool + work-tool + manipulative; include interactive input upgrade, structured choices, multiple-choice, multi-select, ranking, manual reply fallback, and copy/export/reset |
chat-native input by default, fake Claude chat input, HTML form for one-off clarification, static choices without state |
| Turn a recipe card into a reusable planner | html-app + tool + work-tool + manipulative; include recipe workbench, serving scaler, metric US unit toggle, cook mode, local storage boundary, copy/export/reset, and recipe data display boundary |
static recipe card only, Bing image search result, nutrition facts verified, allergen-safe, live grocery availability |
| Save/iterate an inline custom visual or diagram | visual-explainer + code-file + native-widget-boundary upgrade; include diagram source, preview diagram, source-to-preview mapping, copy diagram source, download SVG/HTML boundary, and save as artifact boundary |
persistent artifact by default, uncopyable SVG-only boxes, fake Claude host save |
| Build a reusable code asset | code-file + product-prototype or work-tool |
generic dashboard without real code |
| Show file trees or steps to copy | diagram-text |
SVG boxes that cannot be copied |
Experience Model Standards
product-prototype: realistic task UI with at least two meaningful states such as empty, loading, error, success, selected.work-tool: usable controls, output, reset/clear, and copy/export/history when useful.work-toolfor algorithmic art: use a real Canvas/SVG composition withalgorithmic art,
visibleseed control,parameter controls,regenerate,reset, andexport PNG.
Include animage generation boundary: this is deterministic local rendering unless a
real image pipeline is invoked. Avoidstatic poster only, browser-side image API keys,
andunseeded random output.ai-assistant: input, mode strip, structured result, loading/error/empty, copy/history, and an honestbaked/host-live/external-backendboundary.learning-game-lesson: core relation first, then stepper, quiz, score, feedback, reveal, or simulation.data-analysis: KPI, main chart, insight cards, visiblesource table/源数据表heading or caption, units, and correct chart type.data-analysisfor mixed-scale trend data: include a visiblechart choice note, explicitmixed-scale handling, trend annotation,source table, andcopy summary; use dual-axis, normalized small multiples, or another justified comparison view, withno pie chartfor trend data and nosingle-axis flattening.work-toolfor provided weather snapshots: build aweather snapshot planneronly when the user asks to save/reuse/plan from provided data. Keepweather data display boundary,source-backed snapshot,retrieved at,source/time,snapshot/live boundary,no fake Google Maps,no fake weather,activity planner,chart/table, andcopy/export/resetvisible.mechanism-explainer: main diagram, inspector/evidence, state or flow where relevant.mechanism-explainerfor an inline visual converted to a durable artifact: show apreview diagram
tied todiagram source, keepsource-to-preview mapping, exposecopy diagram source,
state thedownload SVG/HTML boundaryandsave as artifact boundary, and include
no fake Claude host saveas a boundary when host persistence is unavailable.shareable-document: executive summary, outline or sections, copy actions, evidence tables when useful.
Output Contract
Every full artifact must include:
<main data-artifact-root>- a first-viewport
<section data-primary-surface>containing the actual work <section data-support-surface>when controls, evidence, history, or tables exist<section data-error-boundary>for JS-heavy artifacts<script type="application/json" id="artifact-meta">with fields fromreferences/artifact-output-contract.md, includingexperience_model
Keep editable material in DATA / CONFIG objects where possible. Use stable ids/classes and clear render/update/reset functions so later edits are local.
Visual Standards
Follow references/typography-and-color.md and references/artifact-visual-effects.md.
Use references/claude-official-alignment.md to calibrate Claude-like behavior:
route the artifact by content type, keep the work product in the first viewport,
use warm neutral surfaces and sparse semantic accents, and never copy Claude host
chrome unless the user explicitly asks for a Claude UI mockup.
Key defaults:
- first viewport shows the artifact's useful product, not a feature explanation
- mobile first viewport: data-primary-surface must start early enough to be
prominent in the first viewport; keep compact capability/status strips,
horizontally
scrollable, or move details to data-support-surface instead of stacking
long explanation chips above the workbench
- for data-viz / dashboard, KPI strip alone is never enough for data-primary-surface; the primary surface must include the main chart/table/work area
- every HTML artifact declares and uses these baseline semantic CSS tokens in light and dark mode: --ink, --muted, --paper, --soft, --line; aliases may exist, but these exact names are required for validators and later edits
- neutral base, 1 primary semantic color, 1 secondary semantic color; state colors only for state
- user style preferences such as "pink", "dark", "hand-drawn", or "Claude-like" must become a bounded style profile: keep the neutral base, use the requested style as an accent or documented brand system, and do not claim persistent Claude account memory
- when a visual preference affects an artifact, include style-preference-boundary and bounded style profile in artifact metadata/capabilities, and make style_profile explicitly name neutral base, the user accent such as pink accent, and semantic state colors
- if the user asks to remember a future visual style but also says not to generate a webpage/artifact, answer in chat as no-artifact; explicitly say the preference is bounded to the current context/project and use the phrase "not saved to the Claude account / 不是 Claude 账号级记忆"; do not claim global persistent memory unless project/global rules are actually edited
- do not create or modify AGENTS.md, memory, project rules, or global rules for a style preference unless the user explicitly asks to persist the preference there
- no decorative orbs, bokeh, glassmorphism, blurred backgrounds, or generic radial gradients
- do not use linear-gradient, box-shadow, backdrop-filter, or blurred decoration for normal content artifacts; use borders, spacing, tone contrast, and data-driven color instead
- cards are for repeated items, modals, and framed tools; avoid cards inside cards
- controls must look and behave like real controls
- primary surface and page background must have clear visual separation; a
workbench/editor stage should not rely on the same background color as the
page, because surfaceSeparated browser checks treat that as a weak canvas
- editor-canvas artifacts must expose data-toolbar, data-editor-canvas,
data-object-list, and data-inspector; metadata capabilities must include
editor-canvas and selection-state; inspector input[type="color"],
select, and property controls need at least min-height: 30px
- interactive SVG/chart marks must have a real hit target at least 30px by 30px; do not put role="button" or tabindex directly on thin SVG paths, arcs, ticks, or tiny dots unless a transparent hit target or external button/legend row carries the interaction
- hidden input[type="radio"] / input[type="checkbox"] controls inside a visible label or pill must either cover that visible label with inset:0, width:100%, height:100%, min-width: 30px, and min-height: 30px, or the visible input/label itself must be at least 30px by 30px
- source tables must have a visible source table / 源数据表 heading or caption; they must not widen the page: wrap wide tables in a max-width: 100% container with overflow-x: auto, and make row-select/action controls display: inline-flex with min-width: 30px and min-height: 30px
- every full HTML artifact must include an explicit overflow-x:hidden guard on html,body
- animation must explain change; long or continuous motion needs pause/reset and reduced-motion support
- mobile must not crop text, controls, or the primary surface
AI, Storage, Publish
Claude's host may provide AI, storage, publish, sharing, embed, and MCP. Local HTML does not.
Official host details that affect routing:
- roughly 15 lines is only a soft artifact threshold; independent canvas value
matters more than line count
- editing a prior user message creates a conversation fork; local version
controls are not Claude chat lineage
- Cowork live artifacts are host-local, currently private/non-shareable
workspaces with host version history
- AI-powered artifacts do not require user API keys in Claude, but usage counts
against the user's plan; current input is text-oriented and arbitrary external
APIs still require a connector or backend
- connector/local-file approval is per user and limited to the explicitly
approved scope
Use:
- ai_mode: none when no AI behavior exists
- ai_mode: baked for precomputed examples or rule-based local behavior
- ai_mode: host-live only when a host explicitly injects an AI adapter
- ai_mode: external-backend only after a real backend/API/key plan exists
Never hard-code vendor API endpoints, ask for browser-side API keys, or claim local HTML has Claude account capabilities.
Domain References
Read only what matches the route:
| Need | Read |
|---|---|
| artifact necessity / no-artifact decisions | references/artifact-necessity-threshold.md |
| vague artifact idea / problem refinement | references/artifact-problem-refinement.md |
| artifact gallery / inspiration library / saved-artifact index | references/artifact-discovery-library.md |
| native visual widgets / custom visuals / interactive inputs | references/native-visual-content-boundary.md |
| raster image / photo / PNG generation boundary | references/image-generation-boundary.md |
| data analysis / code execution / computed-result boundary | references/data-analysis-execution-boundary.md |
| web search / Research / citation source boundary | references/web-search-source-boundary.md |
| connector / MCP / external app authorization boundary | references/connector-authorization-boundary.md |
| custom charts / diagrams / interactive visuals integration | references/custom-visualizer-integration.md |
| reusable HTML skeleton and tokens | references/boilerplate.md |
| editing existing artifacts / versioning | references/artifact-iteration-versioning.md |
| AI-powered tools | references/ai-powered.md |
| programming syntax / code concept interactive learning board | references/programming-concept-artifact.md |
| persistent / host storage boundaries | references/persistent-storage-boundary.md |
| animated flows | references/animated-diagrams.md |
| diagrams and SVG structure | references/diagrams.md |
| data charts | references/charts.md |
| interaction, Canvas, simulation | references/interactive.md |
| UI mockups and dashboards | references/mockup.md |
| Claude Design-like prototype canvas | references/artifact-kind-patterns.md and references/artifact-product-protocol.md |
| presentation / slide decks | references/presentation-slide-artifacts.md |
| video scripts / storyboards / prompt packs / social creative | references/creative-media-artifact.md |
| steppers, timelines, tabs | references/steppers.md |
| text diagrams and file trees | references/text-diagrams.md |
| visual illustration | references/illustrative.md or references/art.md |
| Mermaid diagrams | references/mermaid.md |
| all courseware | references/courseware-blueprint.md plus relevant references/pedagogy/* |
| image question input | references/input/image-and-text.md |
| math/physics/chemistry/biology/history/English/Chinese | relevant references/subjects/* and references/validation/* |
| solid geometry / 3D coordinate-vector lesson | references/subjects/solid-geometry-3d.md, references/validation/computational-stem-kernel.md, references/scenes/stem-scene-mapping.md |
| analytic geometry / coordinate graph lesson | references/subjects/analytic-geometry-2d.md, references/validation/computational-stem-kernel.md, references/scenes/stem-scene-mapping.md |
| computational science labs / exact STEM kernels | references/validation/computational-stem-kernel.md, references/scenes/stem-scene-mapping.md, references/interactions/stem-interaction-patterns.md, references/validation/stem-common.md |
| fallback subjects | references/subjects/fallback-stem.md or references/subjects/fallback-humanities.md |
| complex React/Vite/shadcn artifacts | references/complex-web-artifact-build.md |
| Office/PDF/image file artifacts | references/file-artifact-creation-boundary.md |
Courseware Rules
For lesson or problem-solving tasks:
- Build a lesson blueprint before HTML.
- Identify subject, lesson type, input source, and core claims.
- For STEM problems, solve and verify reasoning before adding animation.
Computational STEM pages must define asource_of_truth:problem_spec,
computed_values,answer_bindings, and visual/model data all come from
the same source, not duplicated by hand in separate formula, chart, Canvas,
or 3D blocks. For science/engineering workbenches, also expose a deterministic
calculation kernel or formula model, units, model_points, live readout bindings,
and checks covering answer card == final step, visual readout == computed_values,
and model_points come from problem_spec. For exact/symbolic domains, follow
references/validation/computational-stem-kernel.md: use a deterministic
calculation kernel when it reduces correctness risk, but do not add a large
external dependency unless it is licensed, available, and worth the V1 cost. - Treat computational STEM as an explicit capability cluster: solid geometry,
analytic geometry, physics workbenches, chemistry workbenches, biology variable-control labs,
and intake/spec-review workbenches all follow the same product pattern.
Normalize text / image / random inputs into oneproblem_spec, review a recognized spec before
solving image-derived problems unless visible assumptions are explicitly allowed, and run
clean-answer resampling before rendering random practice. Borrow EduLab's structured spec/kernel/
render/check pattern where useful, but keep the current html-visualizer neutral base,
restrained semantic accents, and output contract. - For humanities/language tasks, use text evidence, annotation, structure, and answer framing instead of STEM-style flowcharts.
- Include a main visual plus guided interaction: stepper, quiz, reveal, slider, sorting, or prediction.
- Preserve answer checks, misconceptions, and verification logic.
Rendering Rules
- Standalone HTML may use normal CSS, but keep it inspectable and restrained.
- SVG viewBox default width is
860for standalone outputs unless the specific reference says otherwise. - Use CSS variables for colors and dark mode.
- SVG paths, arcs, and small glyphs are visuals first. If they are clickable, add an invisible
rect/wide stroke hit target of at least 30px by 30px, or make the adjacent HTML legend/list row the accessible button. - For Canvas/RAF simulations, use real elapsed time, fixed scale, locked parameters during playback, and pause/reset.
- For dynamic SVG flow, do not use
animateMotion; use JS-controlled transforms and keep paths inspectable. - For text/file-tree outputs, prefer copyable
<pre>or tables over graphical boxes.
Verification
After generating or modifying an artifact, run the strongest relevant checks:
python scripts/lint_artifact.py <artifact.html>
python scripts/check_artifact_visual_quality.py <artifact.html>
node scripts/check_artifact_actions.js <artifact.html>
node scripts/check_artifact_ai_flow.js <artifact.html> # for ai-app / ai-assistant
node scripts/check_artifact_interaction_flow.js <artifact.html>
node scripts/check_artifact_editor_canvas.js <artifact.html> # for editor/authoring canvas
node scripts/check_artifact_surface_quality.js <artifact.html>
node scripts/check_artifact_layout_polish.js <artifact.html>
node scripts/check_artifact_viewport.js <artifact.html> --width 390 --height 844
node scripts/check_artifact_viewport.js <artifact.html> --width 1024 --height 760
python scripts/check_stem_source_of_truth.py <artifact.html> # for STEM/math/physics/courseware
For skill-wide regression:
python validate_skill.py
python scripts/evaluate_forward_artifacts.py examples/forward-artifacts.sample.json
python scripts/evaluate_forward_artifacts.py examples/forward-artifacts.sample.json --score-draft
python scripts/check_routing_oracle.py examples/routing-oracle-cases.json --evidence examples/routing-oracle-evidence.json --summary
python scripts/check_coldstart_outputs.py examples/coldstart-eval-cases.json --init-manifest -
python scripts/check_forward_sample_quality.py examples/forward-artifacts.sample.json
node scripts/check_forward_sample_surface_quality.js examples/forward-artifacts.sample.json
node scripts/check_forward_sample_layout_polish.js examples/forward-artifacts.sample.json
node scripts/check_forward_sample_actions.js examples/forward-artifacts.sample.json
node scripts/check_forward_sample_ai_flows.js examples/forward-artifacts.sample.json
node scripts/check_forward_sample_interactions.js examples/forward-artifacts.sample.json
node scripts/check_forward_sample_editor_canvases.js examples/forward-artifacts.sample.json
node scripts/check_forward_sample_viewports.js examples/forward-artifacts.sample.json
python scripts/check_official_alignment_cases.py
python scripts/check_official_sample_coverage.py
python scripts/check_official_visual_diversity.py
node scripts/check_official_sample_artifacts.js
node scripts/check_official_sample_artifacts.js --viewports
node scripts/check_official_sample_viewports.js
If a check fails, fix the rule/source artifact first, then rerun the same check. Do not hand off a failing artifact as complete.
Delivery
Return the generated file path and a short verification summary. Mention unverified risks honestly. Do not claim Claude-host features unless the target host actually provides them.