agentleFS
clearsmogclearsmog/claude-skills/typst/SKILL.md

typst

Skill2 starsChanged 9 months agoMITView on GitHub

Syntax guide and ecosystem reference for writing Typst (.typ) files. Use this skill when writing, editing, or debugging Typst documents. Covers core syntax, common errors, packages, and best practices.

11 other projects use a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

9 rules. 0 are common, 1 is distinctive, and 8 are very specific to this project.

  • 0

    Common

    Most of the 11 edited versions we read keep these.

  • 1

    Distinctive

    This author's own choices. Worth a look.

  • 8

    Very specific

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

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

    Use the qk-doc or qk-report preset

    line 16
  2. Very specific:

    Use touying for presentations (not raw page dimensions) — see references/touying-guide.md

    line 17
  3. Very specific:

    Add alt: to images — image("path.png", alt: "description")

    line 19
  4. Very specific:

    Import @local/qk:2.2.0 at top

    line 47
  5. Very specific:

    Use qk-doc or qk-report preset when applicable

    line 48
  6. Very specific:

    When writing content, automatically convert matching patterns to @local/qk:2.2.0 components:

    line 121
  7. Very specific:

    Add <label> + @ref for recurring concepts across sections.

    line 139
  8. Distinctive:

    Look up the exact signature before writing an unfamiliar function or parameter.

    line 177
  9. Very specific:

    --root flag: When a .typ file uses #import or #image() with paths outside its directory, set --root to the project root.

    line 225

“Common” is measured: kept by at least 6 in 10 of the 11 edited versions of this file we could read. “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

Typst Skill

Current version: Typst 0.15.x

Smart Defaults

Defaults, unless the user or the project's existing files say otherwise:

  1. Import @local/qk:2.2.0 — #import "@local/qk:2.2.0": *
  2. Use the qk-doc or qk-report preset
  3. Use touying for presentations (not raw page dimensions) — see references/touying-guide.md
  4. #set figure(placement: auto) — prevents blank half-pages
  5. Add alt: to images — image("path.png", alt: "description")
  6. Escape $ in content — scan for bare $ before compiling
  7. Default fonts: Libertinus Serif (body), Inter (headings), New Computer Modern Math (math), Fira Code (code)
  8. Default compile: typst compile --root .. Source/<file>.typ
  9. Template when the request doesn't settle it: Study Guide
  10. Visual tool when the content doesn't settle it: diagrams → fletcher; charts → see decision tree (default → lilaq; extremely simple → cetz-plot (rare); statistical kde/pair → matplotlib+seaborn; grammar → plotnine; complex with Python data → matplotlib)
  11. Scan the project for existing .typ files and match their style (fonts, colors, qk preset)

New Document Decision Tree

User request → scan for keywords:
  "resume/CV/job"           → CV / Résumé template
  "slides/presentation"     → Presentation (touying — metropolis default)
  "lecture/class/academic"   → Academic Lecture (touying — university theme)
  "essay/thesis/paper"      → Essay
  "report/brief/client"     → Business Report
  "research/analysis"       → Research Report
  "study guide/revision"    → Study Guide
  "reference/glossary"                      → Annotated Reference
  "cheatsheet/reference card/formula sheet" → Cheatsheet template
  "exam/problem set/homework"              → Exam template
  "flashcard/Q&A/quiz"                     → Flashcard template
  ambiguous?                → ask purpose + audience → pick template

Steps:

  1. Auto-detect template from keywords above
  2. Import @local/qk:2.2.0 at top
  3. Use qk-doc or qk-report preset when applicable
  4. Auto-select template. State choice in Phase 3 summary. User can re-invoke with explicit type override if wrong.
  5. Build from references/templates.md
  6. Custom styles are fine — templates are starting points, not constraints

Visual Tool Routing (compact)

Diagrams (always native Typst — NEVER Python):

NeedTool
Flowcharts, trees, ER, state diagramsfletcher
Sequence diagramschronos
Gantt chartstimeliney
Linear timelinesherodot

Charts (generate SVG, embed with #figure(image(...))):

NeedTool
Extremely simple charts where lilaq is overkill (rare)cetz-plot (Typst native, qk-cycle colors)
Most charts (line, bar, scatter, violin, heatmap, contour, subplots)lilaq (Typst native, font-matched, as lq)
Statistical plots (kde, pair plots)matplotlib + seaborn (use(), SVG)
Grammar-of-graphics / faceted plotsplotnine (theme_qk(), SVG)
Complex charts with Python data pipelinematplotlib (full API, SVG)

Images & layout:

NeedTool
Tables, boxes, gridsTypst native
Mind maps/mindmap (auto-invoke)
Conceptual illustrationsgemini-generate-image MCP (auto-invoke)
Real photos, logos/image-search (auto-invoke)

Detail and examples in references/tool-routing.md.

Proactive Behaviors

Visual Auto-detection

When writing Typst documents, add a visual wherever it makes the content clearer, without waiting to be asked. Route by content type: diagrams → native Typst (fletcher/chronos/timeliney/herodot); charts → follow the Charts table above (cetz-plot for very simple, lilaq for most, matplotlib/seaborn/plotnine for statistical or grammar-of-graphics) — generate SVG, embed; images → /image-search / /mindmap / gemini-generate-image MCP.

Content patternVisual to addTool
Comparison grids, attribute tablesStyled tableTypst native
Callout boxes, styled layoutsrect() / block()Typst native
Sequential steps, decision logicFlowchart / decision treefletcher
Process with inputs/outputsWorkflow diagramfletcher
System architecture, ER diagramsBlock / entity diagramfletcher
Hierarchy or taxonomyTree diagramfletcher or /mindmap
Topic overview, concept mapMind map/mindmap
Request-response, API flowsSequence diagramchronos
Project schedule, phasesGantt charttimeliney
Historical events, evolutionTimelineherodot or timeliney
Extremely simple chart where lilaq is overkill (rare)Line/bar/scatter chartcetz-plot (Typst native)
Most charts (multi-series, subplots, violin, heatmap, contour)Data visualizationlilaq (Typst native, font-matched)
Statistical chart (kde, pair plots)Statistical plotmatplotlib+seaborn (SVG)
Faceted / grammar chartLayered plotplotnine (SVG)
Company logo, brand markLogo image/image-search --logo
Real-world photographPhoto/image-search
Concept with analogy, metaphorAI illustrationgemini-generate-image MCP

See references/tool-routing.md for full examples, fallback chains, and auto-invoke rules.

Content Structure

  • Suggest TOC (#outline()) at 4+ sections
  • Suggest file split at 40+ pages — see references/common-patterns.md "Large Documents"
  • Convert prose lists to tables when 3+ items with attributes

Component Library Auto-use

When writing content, automatically convert matching patterns to @local/qk:2.2.0 components:

Content patternUse instead
Warning paragraphwarning[...]
Key point / takeawaykeypoint[...]
Tip or best practicetip[...]
Common mistake / traptrap[...]
Step-by-step procedurestep-box("Title", [...])
Key equation / formulaformula-box("Title", [...])
KPI or metric highlightstat-card("value", "label")
Frequency indicatorfreq-badge("HIGH") / freq-badge("MEDIUM") / freq-badge("LOW")
MCQ answer explanationanswerbox("A", "why", "trap", "concept")
Analogy / intuitionanalogy[...]
"Why this matters"whycare[...]

Cross-referencing

Add <label> + @ref for recurring concepts across sections.

Accessibility (Typst 0.14+)

  • alt: on all figures — image("path.png", alt: "description")
  • Semantic heading hierarchy — don't skip levels
  • table.header() for repeating headers — improves PDF/UA accessibility

Fallback Chains

If this fails...Try...
gemini-generate-image MCPPlaceholder #rect(width: 100%, height: 4cm, fill: luma(240))[Image placeholder]
/image-searchgemini-generate-image MCP with descriptive prompt
/mindmapfletcher tree diagram
matplotlibCheck .venv → uv venv .venv.nosync && ln -s .venv.nosync .venv
typst compileIsolate with /* ... */, compile incrementally

Reference File Index

When you need...Read...
Syntax, errors, special charsreferences/quick-ref.md
@local/qk:2.2.0 APIreferences/component-library.md
Visual tool details, examples, fallbacksreferences/tool-routing.md
Document preamblesreferences/templates.md
Table patterns, show rules, large docsreferences/common-patterns.md
Page layout, spacing, figures, curvesreferences/layout-patterns.md
Math mode trapsreferences/math-pitfalls.md
Package importsreferences/packages.md
Touying presentations (themes, slides, speaker notes)references/touying-guide.md
Visual verification (PNG rendering, spot-checks)references/visual-verification.md
Quality gates, rubrics, dispatch tablereferences/quality-gates.md
Data-driven generation (JSON, CSV, batch, variants)references/data-driven.md
sym.* symbolsreferences/symbols.md

Offline API and Package Search

Look up the exact signature before writing an unfamiliar function or parameter; don't guess from memory. Index covers Typst 0.15.1 (the installed version).

python3 -I ${CLAUDE_SKILL_DIR}/scripts/search-api.py --name text            # exact: text, str.position, table.cell
python3 -I ${CLAUDE_SKILL_DIR}/scripts/search-api.py "rotate content angle" --top 5
python3 -I ${CLAUDE_SKILL_DIR}/scripts/search-packages.py "gantt chart" -n 5   # Typst Universe, filtered to installed compiler
python3 -I ${CLAUDE_SKILL_DIR}/scripts/search-packages.py --category cv -n 5

Scripts and data/ come from lucifer1004/claude-skill-typst (MIT). After a Typst upgrade, or to refresh the package index, copy skills/typst/data/{api,api-bm25,packages,packages-bm25}.json from that repo into ${CLAUDE_SKILL_DIR}/data/.

Text-level check without rendering: typst compile doc.typ /dev/stdout -f html --features html 2>/dev/null dumps headings, paragraphs and tables as HTML — cheaper than PNG when only content or structure needs checking.

Version Notes (0.13–0.15)

FeatureVerDescription
Variable fonts0.15Supported at last — axis selection via text(variations: (...)); Apple variable fonts (New York, SF NS) now load
within selector0.15Match elements inside a container — simplifies introspection
divider element0.15Thematic break (templates can customize)
Multiple bibliographies0.15Independent bibliographies via bibliography(target:, group:)
MathML HTML export0.15Equations export to web (was a hard limitation before)
typst eval0.15General CLI introspection — supersedes typst query
Tagged PDFs, PDF/UA-10.14Accessible PDFs by default
figure.alt / image(alt:)0.14Alt text for screen readers
pdf.attach0.14Attach files (replaces pdf.embed)
PDF as image format0.14image("file.pdf")
Multiple table headers0.14Hierarchical headers repeat across pages
curve function0.13Bezier drawing (replaces path)

Removed in 0.15 (were deprecated, now gone): path element → use curve · pdf.embed → pdf.attach · image.decode / scoped decode fns → pass bytes directly · pattern type → tiling Other migrations: polylux:0.3.1 → polylux:0.4.0 or touying Breaking (0.15): file paths must use forward slashes only (no backslashes)

| touying 0.8.0 | 0.6+ | Presentation framework — #show: theme.with(...) API (not the old register() pattern) |

CLI Commands

typst compile document.typ                     # Compile to PDF
typst compile document.typ --root ..           # Set project root
typst compile document.typ out.pdf --pages 1-5 # Specific pages
typst watch document.typ                       # Watch and recompile
typst fonts                                    # List available fonts
typst eval doc.typ "heading.where(level: 1)"   # Introspect structure (supersedes `typst query`)
typst query doc.typ "heading.where(level: 1)"  # Older form — still works

--root flag: When a .typ file uses #import or #image() with paths outside its directory, set --root to the project root.

Batch compile: for f in *.typ; do typst compile "$f"; done

Conventions

  • Source files in Source/, compiled PDFs in PDFs/
  • Compile with --root .. when .typ references parent directory assets
  • For multi-file projects: main.typ + #include sections + shared lib.typ
  • File naming: lowercase-kebab-case (e.g., portfolio-theory-guide.typ)

Fonts

FontStyleNotes
New Computer ModernAcademic serifDefault; bundled with Typst
GeorgiaReadable serifSafe on macOS
Helvetica NeueClean sans-serifmacOS only

Variable fonts (supported since 0.15): Apple variable fonts and others now load directly — no need to install static .otf/.ttf versions. Select an axis with #set text(font: "New York", variations: (wght: 600)). The "Variable"/"Var"/"VF" suffix in a font's name is trimmed automatically, so reference the base family name. Note Apple's exposed family names differ from marketing names: San Francisco is SF NS (not "SF Pro"), and the serif is New York — run typst fonts to confirm. (On Typst ≤ 0.14 these failed with "variable fonts are not currently supported" — only relevant if pinned to an old binary.)

CJK fallback: #set text(font: ("New Computer Modern", "Songti SC"))

Documentation

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.