typst
Typst document creation and package development. Use when: (1) Working with .typ files, (2) User mentions typst, typst.toml, or typst-cli, (3) Creating or using Typst packages, (4) Developing document templates, (5) Converting Markdown/LaTeX to Typst
What this skill does
# Typst
## Compilation
```bash
typst compile document.typ # compile once → PDF
typst compile document.typ output.pdf # explicit output path
typst compile document.typ -f png # export as PNG image
typst compile src/main.typ --root . # set project root for /path imports
typst watch document.typ # recompile on change
typst query document.typ "<label>" # extract metadata as JSON (see query.md)
```
For command options beyond this quick reference, see [cli.md](cli.md).
Agent verification — choose by what you need to check (see [debug.md](debug.md) for details):
| Method | Command | Best for |
| ----------- | ----------------------------------------------------------------------- | ----------------------------------------- |
| HTML export | `typst compile doc.typ /dev/stdout -f html --features html 2>/dev/null` | Text content, structure, headings, tables |
| PNG export | `typst compile doc.typ page-{p}.png -f png` | Visual layout, alignment, spacing, fonts |
| pdftotext | `typst compile doc.typ && pdftotext doc.pdf -` | Fallback for page-specific content |
## Minimal Document
```typst
#set page(paper: "a4", margin: 2cm)
#set text(size: 11pt)
= Title
Content goes here.
```
## Writing Documents
**Starting a new document?** Copy the closest recipe from [Examples](#examples) below — it's faster than starting blank and each row names the docs to read next.
| When you need to... | Read |
| -------------------------------------------------- | ------------------------------ |
| Learn syntax, imports, functions, control flow | [basics.md](basics.md) |
| Learn data types, operators, string/array methods | [types.md](types.md) |
| Style pages, headings, figures, layout | [styling.md](styling.md) |
| Tables, grids, cell spans, borders, data tables | [tables.md](tables.md) |
| Academic papers, bibliography, theorems, equations | [academic.md](academic.md) |
| Convert from Markdown or LaTeX | [conversion.md](conversion.md) |
| Use Typst CLI commands and build options | [cli.md](cli.md) |
| Extract data from documents, multi-pass builds | [query.md](query.md) |
## Developing Packages and Templates
| When you need to... | Read |
| ------------------------------------------- | -------------------------- |
| State, counters, in-document `query()`, XML | [advanced.md](advanced.md) |
| CLI query, metadata export, multi-pass | [query.md](query.md) |
| Create a reusable template function | [template.md](template.md) |
| Create or publish a package | [package.md](package.md) |
| Verify output (HTML/PNG/pdftotext, repr) | [debug.md](debug.md) |
| Profile performance (--timings, hotspots) | [perf.md](perf.md) |
[basics.md](basics.md) and [types.md](types.md) are also the foundation for developers.
## Finding Packages
Search the embedded index of Typst Universe packages (updated weekly):
```bash
python3 scripts/search-packages.py "what you need"
python3 scripts/search-packages.py "chart" --category visualization
python3 scripts/search-packages.py --category cv --top 5
python3 scripts/search-packages.py --list-categories
```
## Common Errors
| Error | Cause | Fix |
| ------------------------------------------------ | ---------------------------- | ---------------------------------------------------- |
| "unknown variable" | Undefined identifier | Check spelling, ensure `#let` before use |
| "expected X, found Y" | Type mismatch | Check function signature in docs |
| "file not found" | Bad import path | Paths resolve relative to current file |
| "unknown font" | Font not installed | Use system fonts or web-safe alternatives |
| "maximum function call depth exceeded" | Deep recursion | Use iteration instead |
| "can only be used when context is known" | Missing `context` wrapper | Wrap in `context { ... }` |
| "unexpected argument" | `=` instead of `:` for args | Named args use `:` syntax: `func(name: value)` |
| "variables from outside are read-only" | Mutating captured variable | Use loop accumulation or `state()` — see advanced.md |
| "expected content, found string" (or vice versa) | Content/string type mismatch | Use `[#str-var]` to embed string in content |
| set/show rule has no effect | Rule placed after content | Place set/show rules before the content they target |
## Examples
Copy the closest starter, adjust, compile. For CVs, letters, or slides, search packages: `python3 scripts/search-packages.py --category cv` (or `letter`, `presentation`).
| Example | Start here when you want... | Next read |
| --------------------------------------------------- | ---------------------------------------- | ------------------------------------------------ |
| [basic-document.typ](examples/basic-document.typ) | A short note or memo | [basics.md](basics.md), [styling.md](styling.md) |
| [styled-document.typ](examples/styled-document.typ) | A multi-section report with page styling | [styling.md](styling.md), [tables.md](tables.md) |
| [template-report.typ](examples/template-report.typ) | A reusable template for a series | [template.md](template.md) |
| [tables-showcase.typ](examples/tables-showcase.typ) | A data-heavy doc (tables, CSV/JSON) | [tables.md](tables.md), [types.md](types.md) |
| [academic-paper.typ](examples/academic-paper.typ) | A paper with citations, theorems, math | [academic.md](academic.md) |
| [query-export.typ](examples/query-export.typ) | Metadata export or multi-pass builds | [query.md](query.md) |
| [package-example/](examples/package-example/) | A publishable package | [package.md](package.md) |
## Dependencies
- **typst CLI**: Install from https://typst.app or via package manager
- macOS: `brew install typst`
- Linux: `cargo install typst-cli`
- Windows: `winget install typst`
- **pdftotext** (optional): For text-level output verification
- **Python 3.10+** (optional): For package search and validation scripts
- **jq** (optional): For parsing JSON output from `typst query` in shell scripts
## API Reference Search
Search the embedded index of Typst API functions, methods, and constructors:
```bash
python3 scripts/search-api.py "image width fit"
python3 scripts/search-api.py "color lighten" --kind method
python3 scripts/search-api.py --name str.position -v
python3 scripts/search-api.py "rightarrow" --kind symbol # LaTeX names work
python3 scripts/search-api.py --list-categories
```
## Ecosystem Tools
Ecosystem tools: **tinymist** (LSP/editor), **typstyle** (formatter), **typst-package-check** (package validator), **tytanic** (visual test runner). For package tooling details, see [package.md](package.md).
Related in Writing & Docs
jax-development
IncludedUse this skill when the user is writing, debugging, profiling, refactoring, reviewing, benchmarking, parallelising, exporting, or explaining JAX code, or when they mention JAX, jax.numpy, jit, grad, value_and_grad, vmap, scan, lax, random keys, pytrees, jax.Array, sharding, Mesh, PartitionSpec, NamedSharding, pmap, shard_map, Pallas, XLA, StableHLO, checkify, profiler, or the JAX repo. It helps turn NumPy or PyTorch-style code into pure functional JAX, fix tracer/control-flow/shape/PRNG bugs, remove recompiles and host-device syncs, choose transforms and sharding strategies, inspect jaxpr/lowering/IR, and benchmark compiled code correctly.
nature-article-writer
IncludedDrafts, rewrites, diagnostically critiques, and style-calibrates primary research manuscripts for Nature and Nature Portfolio journals. Use when the user wants a Nature-style title, summary paragraph or abstract, introduction, results, discussion, methods, figure legends, presubmission enquiry, cover letter, reviewer response, or when a scientific draft sounds generic, jargon-heavy, structurally weak, or AI-ish and needs precise, broad-reader-friendly prose without inventing data, analyses, or references. Best for primary research articles and letters rather than reviews or press releases unless explicitly adapting one.
deckrd
IncludedDocument-driven framework that derives requirements, specifications, implementation plans, and executable tasks from goals through structured AI dialogue. Use when user says "write requirements", "create spec", "plan implementation", "derive tasks", "structure this feature", "break down into tasks", or "document this module". Also use for reverse engineering existing code into docs (/deckrd rev). Do NOT use for direct code writing — use /deckrd-coder after tasks are generated. Do NOT use when the user only wants to run or fix existing code without planning.
clinical-decision-support
IncludedGenerate professional clinical decision support (CDS) documents for pharmaceutical and clinical research settings, including patient cohort analyses (biomarker-stratified with outcomes) and treatment recommendation reports (evidence-based guidelines with decision algorithms). Supports GRADE evidence grading, statistical analysis (hazard ratios, survival curves, waterfall plots), biomarker integration, and regulatory compliance. Outputs publication-ready LaTeX/PDF format optimized for drug development, clinical research, and evidence synthesis.
handling-sf-data
IncludedSalesforce data operations with 130-point scoring. Use this skill to create, update, delete, bulk import/export, generate test data, and clean up org records using sf CLI and anonymous Apex. TRIGGER when: user creates test data, performs bulk import/export, uses sf data CLI commands, needs data factory patterns for Apex tests, or needs to seed/clean records in a Salesforce org. DO NOT TRIGGER when: SOQL query writing only (use querying-soql), Apex test execution (use running-apex-tests), or metadata deployment (use deploying-metadata).
accelint-ac-to-playwright
IncludedConvert and validate acceptance criteria for Playwright test automation. Use when user asks to (1) review/evaluate/check if AC are ready for automation, (2) assess if AC can be converted as-is, (3) validate AC quality for Playwright, (4) turn AC into tests, (5) generate tests from acceptance criteria, (6) convert .md bullets or .feature Gherkin files to Playwright specs, (7) create test automation from requirements. Handles both bullet-style markdown and Gherkin syntax with JSON test plan generation and validation.