agentleFS
JlosevJlosev/agent-skills/skills/canvas-to-html/SKILL.md

canvas-to-html

Skill1 starsChanged 15 days agoMITView on GitHub

Export one Cursor Canvas (.canvas.tsx) to a standalone static directory (index.html + local CSS/JS). Triggers canvas-to-html, export canvas to html, canvas static export.

1 other project uses a version of this.

Adopted by

Most recently taken up by

  • Other versions1 project uses a version of this.

    Word for word · 0

    None found.

    Edited · 0

    None found.

    Wrote their own version · 1

    1. BitSteve/claude-skills★ 0same name

    How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.

  • In this repository6 other files it gives its agents.

The file

We split this skill into the rules it gives an agent

10 rules. About 0 are common, 5 are distinctive, and 5 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈5

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 5

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Theme: Default light. Export embeds light and dark tokens.

    line 24
  2. Distinctive:

    One canvas → one output dir: No monorepo, no extra entrypoints unless asked.

    line 27
  3. Very specific:

    If {OUTPUT_DIR} exists and is not empty – STOP, ask overwrite ack before Step 2.

    line 57
  4. Distinctive:

    If Out-of-scope v1 without fallback – STOP.

    line 64
  5. Very specific:

    Create {OUTPUT_DIR}/ per references/output-contract.md:

    line 70
  6. Distinctive:

    If HTML was assembled by a one-off script with hardcoded strings (not a live transpile), copy UI copy from the current canvas first, then:

    line 90
  7. Very specific:

    If sandbox blocks open – retry with full permissions.

    line 104
  8. Very specific:

    Do not: use external CDNs for CSS/JS/charts.

    line 115
  9. Distinctive:

    Do not: use absolute asset paths.

    line 116
  10. Distinctive:

    Do not: start a local HTTP server for preview.

    line 119

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Canvas to HTML

Exports one Cursor Canvas (.canvas.tsx) to a standalone static directory (index.html + local CSS/JS).

{SKILL_DIR} = directory of this SKILL.md.

Scope

In: one .canvas.tsx (path or name under ~/.cursor/projects/<ws>/canvases/); map cursor/canvas SDK → HTML/CSS/JS; inline/self-hosted charts; neutral light theme
Out: editing the canvas in the IDE; generating a canvas from scratch; wiki/CMS publish; interactivity that needs Cursor runtime (useCanvasAction, fetch)
Fallback: unsupported component → STOP + unsupported list; canvas not found → ask for a path

Gotchas

  • Output format. Entrypoint index.html, asset paths only relative (./styles.css, ./app.js), no absolute /foo.css.
  • Data inline. No fetch(), no external CDN for JS/CSS/charts. Charts – inline SVG or self-hosted .js in the output dir.
  • Theme. Default light. Export embeds light and dark tokens; a «Theme» button toggles html[data-theme].
  • Canvas runtime hooks. useCanvasAction – drop or a static stub. useCanvasState – freeze default values from source.
  • SDK surface. Full API – ~/.cursor/skills-cursor/canvas/sdk/index.d.ts. In-scope v1 – references/sdk-mapping.md. computeDAGLayout → baked SVG; other out-of-scope without fallback → STOP + ack.
  • One canvas → one output dir. No monorepo, no extra entrypoints unless asked.

Preconditions

  • Path to *.canvas.tsx or a canvas name (no extension) to search in canvases/.
  • Canvas source readable (Read).
  • Read references/sdk-mapping.md and references/output-contract.md.

Failure modes

ModeAction
Canvas not foundSTOP, ask for a full path
Read failedSTOP
Out-of-scope SDK without fallbackSTOP, list unsupported; wait for ack on a degraded export. Exception: computeDAGLayout + custom SVG → baked coordinates (degraded OK without ack)
{OUTPUT_DIR} exists and is not emptySTOP, ask ack to overwrite
verify_export.sh exit ≠ 0STOP, fix output to the contract

Algorithm

Step 0: Resolve input

InputAction
Absolute/relative path to *.canvas.tsxRead the file
Canvas name (kebab-case)search ~/.cursor/projects/*/canvases/<name>.canvas.tsx; if several workspaces – ask
Not foundSTOP, ask for a full path

Lock {CANVAS_PATH}, {CANVAS_STEM}, {OUTPUT_DIR} (default .tmp/canvas-export/{CANVAS_STEM}/ or a user path).

If {OUTPUT_DIR} exists and is not empty – STOP, ask overwrite ack before Step 2.

Step 1: Analyze canvas source

  1. Read {CANVAS_PATH} whole.
  2. Extract inline data, cursor/canvas imports, hooks.
  3. Match imports to In-scope v1 in references/sdk-mapping.md.
  4. If Out-of-scope v1 without fallback – STOP.

Reference SDK (read-only): ~/.cursor/skills-cursor/canvas/sdk/index.d.ts.

Step 2: Generate static files

Create {OUTPUT_DIR}/ per references/output-contract.md:

{OUTPUT_DIR}/
  index.html
  styles.css
  app.js          # optional
  assets/         # optional

Order: styles.css via scripts/canvas_export_lib.py → index.html → charts as inline SVG → theme on CSS vars (do not bake hex into SVG).

Forbidden in output: absolute paths, fetch() / XHR, Cursor IDE action links, external CDNs.

Step 3: Verify

bash "{SKILL_DIR}/scripts/verify_export.sh" "{OUTPUT_DIR}"

If HTML was assembled by a one-off script with hardcoded strings (not a live transpile), copy UI copy from the current canvas first, then:

python3 "{SKILL_DIR}/scripts/assert_export_matches_canvas.py" \
  "{CANVAS_PATH}" "{OUTPUT_DIR}"

Exit ≠ 0 → STOP. Then open preview in the system browser (do not ask):

open "{OUTPUT_DIR}/index.html"          # macOS
# xdg-open "{OUTPUT_DIR}/index.html"    # Linux

If sandbox blocks open – retry with full permissions. Skipping preview = fail DoD.

Forbidden: python3 -m http.server or any local static server.

Step 4: Report

Path, file list, SDK coverage, how it was opened.

Hard Stop Rules

  • Do not modify the source .canvas.tsx.
  • Do not use external CDNs for CSS/JS/charts.
  • Do not use absolute asset paths.
  • Do not continue on unsupported SDK without fallback / ack (except baked computeDAGLayout SVG).
  • Do not overwrite a non-empty {OUTPUT_DIR} without ack.
  • Do not start a local HTTP server for preview.

Definition of Done

  • {OUTPUT_DIR}/index.html exists and opens locally
  • Asset refs relative
  • Data inline; no network calls
  • In-scope v1 components mapped (or STOP with gaps)
  • Light theme via CSS vars (+ dark toggle)
  • Preview opened via open / xdg-open

Check commands

SKILL_DIR="<path-to-this-skill>"
test -f "$SKILL_DIR/references/sdk-mapping.md"
test -f "$SKILL_DIR/references/output-contract.md"
test -x "$SKILL_DIR/scripts/verify_export.sh"

Example

In: review.canvas.tsx in ~/.cursor/projects/…/canvases/
Out: .tmp/canvas-export/review/index.html + styles.css + inline SVG charts

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.