typst-author
jihe520/mathmodelagent
Generate, edit, and troubleshoot Typst documents with syntax guidance and best practices.
What is typst-author?
This skill helps agents create and modify Typst (.typ) files with idiomatic code generation, debugging, and reference support. Use it when working with Typst documents, templates, styling, or when users explicitly request document creation, editing, or compilation assistance.
- Generate idiomatic Typst code from scratch or modify existing .typ files
- Answer Typst syntax, reference, and styling questions using bundled documentation
- Troubleshoot compilation errors and validate documents with typst compile
- Apply formatting checks and style fixes using typstyle when available
- Provide quick-start templates and minimal working examples
How to install typst-author
npx skills add https://github.com/jihe520/mathmodelagent --skill typst-author- Typst compiler installed (typst command available)
- Optional: typstyle formatter for post-edit formatting checks
- Access to local Typst documentation in docs/ folder
How to use typst-author
- 1.Describe your Typst document goal or provide the .typ file to edit
- 2.The skill will consult bundled documentation to verify syntax and best practices
- 3.Generate or modify the .typ source code according to your request
- 4.Run post-edit formatting checks with typstyle if available
- 5.Validate the document with typst compile when requested or after modifications
Use cases
- Creating a new Typst document project from a minimal template
- Editing existing .typ files and applying styling or layout changes
- Debugging Typst syntax errors and compilation failures
- Converting or adapting content into Typst markup format
- Implementing custom themes, show/set rules, and document templates
- Technical writers and documentation authors
- Students and researchers writing academic papers or theses
- Anyone migrating from LaTeX or Markdown to Typst
- Developers building Typst-based document generation workflows
typst-author FAQ
Yes, use # to start code expressions inside markup or content blocks (e.g., #figure[...], #image(...)). Do not use # inside code contexts like argument lists.
Set rules configure optional parameters on element functions (style defaults). Show rules target selected elements and apply transformations or replacements. Use set for common styling and show for selective or structural changes.
Use the .at() method, not bracket notation. For example, use arr.at(0) instead of arr[0].
No. Typst has its own syntax and does not support LaTeX commands like \begin{...} or \section. Use Typst's native markup and functions instead.
Stop and ask the user before applying formatting. Only apply typstyle -i when changes are limited to code you created or edited in the current task.
Full instructions (SKILL.md)
Source of truth, from jihe520/mathmodelagent.
name: typst-author description: Generate idiomatic Typst (.typ) code, edit and troubleshoot Typst documents and projects, and answer Typst syntax/reference questions. Use when working with .typ files or when the user explicitly asks for Typst document creation, editing, debugging, compilation, formatting, template work, or package usage.
typst-author skill
Overview
This skill helps agents generate, edit, and reason about Typst documents. It provides quick‑start examples, detailed workflows, and links to the full Typst documentation (guides, tutorials, reference).
Minimal document example
#set document(title: "My Document", author: "Author Name")
#set page(numbering: "1")
#set text(lang: "en")
// Enable paragraph justification and character-level justification
#set par(
justify: true,
justification-limits: (
tracking: (min: -0.012em, max: 0.012em),
spacing: (min: 75%, max: 120%),
)
)
#title[My Document]
= Heading 1
This is a paragraph in Typst.
== Heading 2
#lorem(50)
Workflows
- Creating a new Typst project: Use the "Minimal document example" above as a starting point. Skim the tutorial for the basics (docs/tutorial/writing-in-typst.md), then create the
.typfile(s). After each.typedit, follow the post-edit formatting checks below whentypstyleis available. - Editing existing content: Locate the target text and apply changes; confirm syntax against the reference when needed (docs/reference/). After each modified
.typfile, follow the post-edit formatting checks below. - Formatting & Styling: Consult the styling guide (docs/reference/styling.md) for
set rule,show rule, and custom themes.
Documentation
- Syntax & foundations:
docs/reference/syntax.md - Styling & show/set rules:
docs/reference/styling.md - Scripting & runtime behavior:
docs/reference/scripting.md - Page setup & tables:
docs/guides/page-setup.mdanddocs/guides/tables.md - Task-oriented authoring help:
docs/tutorial/writing-in-typst.md,docs/guides/*.md, anddocs/reference/**/*.md
Detailed instructions
- PRIORITY: Trust local documentation. Your internal training data regarding Typst may be outdated or hallucinated. Always verify function names, parameters, and syntax against the local
docs/folder before generating code. - Read the relevant documentation using local file search and open tools on the paths above.
- Use local docs for syntax and reference questions. Verify syntax, function names, parameters, and reference behavior from the bundled docs. Run a minimal Typst probe only when runtime or evaluation behavior remains unclear after checking the docs.
- Generate or modify the
.typsource according to the user's request. - Run the post-edit formatting checks below for every
.typfile you created or edited in that pass. - Validate with
typst compileafter the formatting decision is complete when you created or edited.typfiles, or when the user explicitly asks for verification (if tool access is allowed). - Summarize touched files and outcomes. Provide full
.typcontent only when the user requests it or when direct editing is not possible, and optionally include a rendered preview (PDF/HTML).
Probing uncertain behavior
- Use a probe when the bundled docs do not settle runtime or evaluation behavior.
- Model the case with Typst scripting as described in docs/reference/scripting.md.
- When a probe is necessary, prefer a fileless probe through stdin instead of creating scratch
.typfiles. Expose the value withmetadata(...) <probe>and read it withtypst query - "<probe>" --field value --one. See docs/reference/introspection/query.md and docs/reference/introspection/metadata.md. - Example:
printf '#metadata(1 + 2) <probe>\n' | typst query - "<probe>" --field value --one
Post-edit formatting checks
- Check whether
typstyleis available withcommand -v typstyle. If it is unavailable, skip the remaining formatting checks. - After each
.typfile modification, runtypstyle --check <file>for the file you just created or edited. - If
typstyle --checkfails, inspect the formatter changes withtypstyle --diff <file>before deciding what to do. - Apply formatting with
typstyle -i <file>only when the formatter changes are limited to a newly created file or to code you created or edited in the current task. - Stop and ask the user when formatting would change untouched pre-existing code. If the diff reaches outside your own edits, or if you cannot confidently prove that every formatter change is limited to your edits, ask instead of formatting.
Quick syntax reference
Critical distinctions
- Arrays:
(item1, item2)(parentheses). See docs/reference/foundations/array.md. - Dictionaries:
(key: value, key2: value2)(parentheses with colons). See docs/reference/foundations/dictionary.md. - Content blocks:
[markup content](square brackets). See docs/reference/foundations/content.md. - NO tuples: Typst only has arrays.
Hash usage (markup vs code)
- Use
#to start a code expression inside markup or content blocks; it disambiguates code from text. This is required for content-producing function calls and field access in markup:#figure[...],#image("file.png"),text(...)[#numbering(...)]. - Do not use
#inside code contexts (argument lists, code blocks, show-rule bodies). Example:#figure(image("file.png"))(no#beforeimage). - Reference: docs/reference/scripting.md, docs/tutorial/writing-in-typst.md
// Incorrect (missing # inside content block)
text(...)[(numbering(...))]
// Correct
text(...)[(#numbering(...))]
Styling rules: set vs show
set: Set rule to configure optional parameters on element functions (style defaults scoped to the current block or file).show: Show rule to target selected elements and apply a set rule or transform/replace the element output.- Use
setfor common styling; useshowfor selective or structural changes (e.g.,heading.where(level: 1), labels, text, regex).
// Set rule: configure optional parameters for an element type
#set heading(numbering: "I.")
#set text(font: "New Computer Modern")
// Show-set rule: apply a set rule only to selected elements
#show heading: set text(navy)
// Show transform rule: replace/reshape element output
#show heading: it => block[#emph(it.body)]
Common mistakes to avoid
- Calling things "tuples" (Typst only has arrays).
- Using
[]for arrays (use()instead). - Accessing array elements with
arr[0](usearr.at(0)). - Omitting
#in markup/content blocks (e.g.,text(...)[numbering(...)]should betext(...)[#numbering(...)]). - Using
#inside code contexts (e.g.,figure(#image("x.png"))in an argument list). - Mixing up content blocks
[]with code blocks{}. - Forgetting to include the namespace when accessing imported variables/functions (e.g., use
color.hslinstead of justhsl). - Using LaTeX syntax (do NOT use
\begin{...},\section, or other LaTeX commands). - Hallucinating environments (e.g.,
tabulardoes not exist; usetable).
Advanced features
- Custom themes: See docs/reference/styling.md for theme creation.
- Scripting: Use Typst's scripting capabilities (docs/reference/scripting.md) for automatic generation.
- Math and visualisation: Reference docs/reference/math/ and docs/reference/visualize/ for formulas and diagrams.
For large projects
When working on large projects, consider organizing the project across multiple files.
- Use
#include "file.typ"to split into multiple files - Relevant documentation: docs/reference/foundations/module.md
Troubleshooting
Missing font warnings
If you see "unknown font family" warnings, remove the font specification to use system defaults. Note: Font warnings don't prevent compilation; the document will use fallback fonts.
Template/Package not found
If import fails with "package not found":
- Verify exact package name and version on Typst Universe.
- Check for typos in
@preview/package:versionsyntax.
Compilation errors
Common fixes:
- "expected content, found ...": You're using code where markup is expected - wrap in
#{ }or use proper syntax. - "expected expression, found ...": Missing
#(or#(...)) in markup/content blocks. - "unknown variable": Check spelling, ensure imports are correct.
- Array/dictionary errors: Review syntax - use
()for both, dictionaries needkey: value, singleton arrays are(elem,).
Related skills
More from jihe520/mathmodelagent and the wider catalog.

1start-mathmodel
Orchestrate mathematical modeling competition workflows from problem analysis through paper submission.

2analysis-modeling
Analyze math competition problems and design solution models with structured decomposition and implementation planning.

3coding-visual
Implement mathematical models, run solvers, and generate publication-ready data-driven charts from analysis reports.

4drawio
Generate non-data diagrams (flowcharts, roadmaps, model structures) for mathematical modeling papers using DrawIO.

claude-design
Create high-fidelity design artifacts in HTML—landing pages, decks, prototypes, animations, and visual explorations.

chinese-content-writing-guideline
>-