Document Creation Workflow
One prompt → one publication-quality document. Internal quality loop runs automatically.
Format Selection
- User specifies format explicitly → use that
- User doesn't specify → detect from project context:
- Has
Slides/ directory → Beamer LaTeX
- Has
Source/ or mainly .typ files → Typst
- Has
Quarto/ directory → Quarto
- Default for new projects → Typst (preferred modern format)
Format Detection (for .typ)
Detect document type from user request keywords:
- resume, CV → CV template
- slides, presentation, lecture → touying slides (see
typst/references/touying-guide.md)
- essay, paper → essay template
- guide, study guide, reference → study guide
- report, business → business report
- reference card, cheat sheet → dense reference layout
CONSTRAINTS (Non-Negotiable, All Formats)
- Read the knowledge base FIRST — notation registry, narrative arc, applications database
- Every new symbol MUST be checked against the notation registry
- Motivation before formalism — no exceptions
- Worked example within 2 slides/pages of every definition
- Max 2 colored boxes/callouts per slide or page
- Transition slides at major conceptual pivots (for slide decks)
- All citations verified against the bibliography
WHEN TO PAUSE (the ONLY case)
Request is genuinely ambiguous AND no project context to disambiguate:
- No sibling
.typ files, no PDFs, no clear topic in the prompt
- Example: user says "make something" with zero context
In this case: ONE AskUserQuestion (topic + type), then proceed autonomously.
For everything else — proceed without asking. Template auto-selection is correct 90%+ of the time; user can re-invoke with explicit overrides if wrong.
PIPELINE
Phase 0: Auto-Discover (silent — no pause)
Run all of these silently before drafting:
- Scan project for related materials
- Glob for
*.pdf, *.md, *.typ, images/ in the project directory
- If PDFs found → check for
.parsed.md next to each; read if exists
- If no
.parsed.md → parse using PDF handling rules (background for large files)
- Detect document type from keywords + project context (see Format Detection above)
- Auto-select template — no confirmation needed
- Style inheritance: if sibling
.typ files exist in the project:
- Read first 30 lines of the most recent sibling
- Match fonts, colors, qk preset
- Only inherit from files that use
@local/qk presets; ignore raw inline styles
- Build context: materials found, template chosen, style detected
Phase 1: Draft (autonomous — full document at once)
For Typst Documents (.typ):
Always import @local/qk:2.0.0 and set smart defaults
Apply qk components per the typst skill's component auto-use table:
- Warning paragraph →
#warning[...]
- Key takeaway →
#keypoint[...]
- Actionable advice →
#tip[...]
- Common mistake →
#trap[...]
- Memory aid →
#memorize[...]
Visual auto-detection (proactive): as content is drafted, match patterns to the best tool. Route by content type: diagrams → native Typst (fletcher/chronos/timeliney/herodot, NEVER Python); charts → cetz-plot (simple, < 3 series) / plotnine (faceted/grammar) / matplotlib+seaborn (statistical/complex) — generate SVG, embed; images → /image-search / /mindmap / gemini-generate-image MCP.
| Content pattern |
Visual |
Tool |
| Comparison of 2+ items, attribute grids |
Table or grid |
Typst native |
| Callout boxes, styled layouts |
rect(), block() |
Typst native |
| Sequential process, decision logic |
Flowchart / decision tree |
fletcher |
| System architecture, ER diagrams |
Block / entity diagram |
fletcher |
| Hierarchy or taxonomy |
Tree diagram |
fletcher or /mindmap |
| Topic overview, concept map |
Mind map |
/mindmap |
| Request-response, API flows |
Sequence diagram |
chronos |
| Project schedule, phases |
Gantt chart |
timeliney |
| Historical events, evolution |
Timeline |
herodot |
| Simple data chart (< 3 series, < 20 pts) |
Line/bar/scatter chart |
cetz-plot (Typst native, qk-cycle) |
| Statistical chart (violin, kde, heatmap) |
Statistical plot |
matplotlib+seaborn (use(), SVG) |
| Faceted / grammar-of-graphics chart |
Layered plot |
plotnine (theme_qk(), SVG) |
| Complex chart (4+ series, annotations) |
Publication chart |
matplotlib (full API, SVG) |
| Company logo, brand mark |
Logo |
/image-search --logo |
| Real-world photo |
Photo |
/image-search |
| Conceptual illustration, metaphor |
AI-generated image |
gemini-generate-image MCP |
See typst/references/tool-routing.md for full details, examples, and fallback chains.
Always add alt: text on all images
Always #set figure(placement: auto)
Write COMPLETE .typ file — not batches
For large docs (>30 pages): write in sections but don't pause between them
For Beamer Slides (.tex):
- Check notation, apply creation patterns
- No
\pause or overlay commands (check project rules)
- Write complete slide deck at once
For Quarto Slides (.qmd):
- Standard RevealJS YAML with theme, bibliography
- Environment parity with CSS classes
- Plotly for Python-generated plots
Phase 2: Verify + Auto-Fix (autonomous — max 3 rounds)
- Compile:
typst compile FILE.typ (or format-appropriate command)
- Hard gate: exit code must be 0
- Render sample PNGs:
- Documents <=3 pages → all pages
- Documents >3 pages → page 1, middle page, last page
- Presentations <30 slides → all slides
- Presentations 30+ → first 3, middle 3, last 3
- Command:
typst compile FILE.typ /tmp/create-preview-{0p}.png --pages [SAMPLE]
- Visual inspection — Read each PNG and check:
- Content overflow / cut off?
- Blank half-pages?
- Font fallback squares (missing font)?
- Missing images / broken references?
- Cramped text / unbalanced layout?
- Structural query:
typst query for heading count, figure count
- If issues found → fix → re-compile → re-render → re-check
- Cap at 3 lightweight fix rounds
Phase 3: Present (final output to user)
Deliver a summary:
## Created: [filename]
| Metric | Value |
|--------|-------|
| Pages | [N] |
| Sections | [N] |
| Visuals | [N figures, N diagrams] |
| Compile | PASS |
| Visual check | PASS / [issues noted] |
| Template | [template used] |
| Style inherited from | [sibling file or "none"] |
| Materials discovered | [list or "none"] |
**What could break:** [list risks]
**Next steps:** `/review` for deep audit · `/finish` for full pipeline · `/excellence` for milestone
Figures & Code
- Python scripts for data-driven content (plotly for Quarto only; matplotlib/plotnine for Typst charts)
- Diagrams: TikZ in Beamer source, fletcher/chronos/timeliney in Typst (NEVER Python), SVG for Quarto
- Save outputs as
.svg for Typst embedding (preferred), .png for raster, .parquet for data persistence
Post-Creation Checklist
[ ] Document compiles without errors
[ ] No overflow issues (verified via PNG)
[ ] All citations resolve
[ ] Every definition has motivation + worked example
[ ] Max 2 colored boxes/callouts per slide/page
[ ] 2-3 Socratic questions embedded (for slides)
[ ] Transition slides between sections (for slides)
[ ] Visual aids present where content benefits from them
[ ] New notation added to knowledge base
Format-Specific Notes
Typst Pedagogical Constraints (for slides)
- Motivation before formalism
- Max 2 boxes/slide
- Worked example within 2 slides of definition
- Fragment reveals with
#pause (touying) — max 2-3 per slide
- Speaker notes with
#speaker-note[...] for presenter context
- Use touying themes via qk-slides (see
typst/references/touying-guide.md)
Beamer Pedagogical Constraints
- Same as Typst but using LaTeX environments
- No
\pause or overlay commands
Devil's Advocate for Non-Slide Documents
- For guides: "Is this section ordering optimal for the reader?"
- For CVs: "Is this ATS-compatible? Is the hierarchy clear?"
- For pitch decks: "Does the narrative build to a clear ask?"
- For essays: "Is the argument structure compelling?"
1---2name: create-document3description: Create new documents in any format — Beamer slides, Typst documents, or Quarto slides. Autonomous pipeline from prompt to publication-quality output.4---56# Document Creation Workflow78One prompt → one publication-quality document. Internal quality loop runs automatically.910---1112## Format Selection1314- User specifies format explicitly → use that15- User doesn't specify → detect from project context:16 - Has `Slides/` directory → Beamer LaTeX17 - Has `Source/` or mainly `.typ` files → Typst18 - Has `Quarto/` directory → Quarto19- Default for new projects → Typst (preferred modern format)2021## Format Detection (for `.typ`)2223Detect document type from user request keywords:24- resume, CV → CV template25- slides, presentation, lecture → touying slides (see `typst/references/touying-guide.md`)26- essay, paper → essay template27- guide, study guide, reference → study guide28- report, business → business report29- reference card, cheat sheet → dense reference layout3031---3233## CONSTRAINTS (Non-Negotiable, All Formats)34351. **Read the knowledge base FIRST** — notation registry, narrative arc, applications database362. Every new symbol MUST be checked against the notation registry373. Motivation before formalism — no exceptions384. Worked example within 2 slides/pages of every definition395. Max 2 colored boxes/callouts per slide or page406. Transition slides at major conceptual pivots (for slide decks)417. All citations verified against the bibliography4243---4445## WHEN TO PAUSE (the ONLY case)4647Request is genuinely ambiguous AND no project context to disambiguate:48- No sibling `.typ` files, no PDFs, no clear topic in the prompt49- Example: user says "make something" with zero context5051In this case: ONE `AskUserQuestion` (topic + type), then proceed autonomously.5253For everything else — proceed without asking. Template auto-selection is correct 90%+ of the time; user can re-invoke with explicit overrides if wrong.5455---5657## PIPELINE5859### Phase 0: Auto-Discover (silent — no pause)6061Run all of these silently before drafting:62631. **Scan project for related materials**64 - Glob for `*.pdf`, `*.md`, `*.typ`, `images/` in the project directory65 - If PDFs found → check for `.parsed.md` next to each; read if exists66 - If no `.parsed.md` → parse using PDF handling rules (background for large files)672. **Detect document type** from keywords + project context (see Format Detection above)683. **Auto-select template** — no confirmation needed694. **Style inheritance**: if sibling `.typ` files exist in the project:70 - Read first 30 lines of the most recent sibling71 - Match fonts, colors, qk preset72 - Only inherit from files that use `@local/qk` presets; ignore raw inline styles735. **Build context**: materials found, template chosen, style detected7475### Phase 1: Draft (autonomous — full document at once)7677#### For Typst Documents (.typ):78- Always import `@local/qk:2.0.0` and set smart defaults79- Apply qk components per the typst skill's component auto-use table:80 - Warning paragraph → `#warning[...]`81 - Key takeaway → `#keypoint[...]`82 - Actionable advice → `#tip[...]`83 - Common mistake → `#trap[...]`84 - Memory aid → `#memorize[...]`85- **Visual auto-detection** (proactive): as content is drafted, match patterns to the best tool. Route by content type: diagrams → native Typst (fletcher/chronos/timeliney/herodot, NEVER Python); charts → cetz-plot (simple, < 3 series) / plotnine (faceted/grammar) / matplotlib+seaborn (statistical/complex) — generate SVG, embed; images → `/image-search` / `/mindmap` / `gemini-generate-image` MCP.8687 | Content pattern | Visual | Tool |88 |-----------------|--------|------|89 | Comparison of 2+ items, attribute grids | Table or grid | Typst native |90 | Callout boxes, styled layouts | `rect()`, `block()` | Typst native |91 | Sequential process, decision logic | Flowchart / decision tree | `fletcher` |92 | System architecture, ER diagrams | Block / entity diagram | `fletcher` |93 | Hierarchy or taxonomy | Tree diagram | `fletcher` or `/mindmap` |94 | Topic overview, concept map | Mind map | `/mindmap` |95 | Request-response, API flows | Sequence diagram | `chronos` |96 | Project schedule, phases | Gantt chart | `timeliney` |97 | Historical events, evolution | Timeline | `herodot` |98 | Simple data chart (< 3 series, < 20 pts) | Line/bar/scatter chart | `cetz-plot` (Typst native, `qk-cycle`) |99 | Statistical chart (violin, kde, heatmap) | Statistical plot | matplotlib+seaborn (`use()`, SVG) |100 | Faceted / grammar-of-graphics chart | Layered plot | plotnine (`theme_qk()`, SVG) |101 | Complex chart (4+ series, annotations) | Publication chart | matplotlib (full API, SVG) |102 | Company logo, brand mark | Logo | `/image-search --logo` |103 | Real-world photo | Photo | `/image-search` |104 | Conceptual illustration, metaphor | AI-generated image | `gemini-generate-image` MCP |105106 See `typst/references/tool-routing.md` for full details, examples, and fallback chains.107- Always add `alt:` text on all images108- Always `#set figure(placement: auto)`109- Write COMPLETE `.typ` file — not batches110- For large docs (>30 pages): write in sections but don't pause between them111112#### For Beamer Slides (.tex):113- Check notation, apply creation patterns114- No `\pause` or overlay commands (check project rules)115- Write complete slide deck at once116117#### For Quarto Slides (.qmd):118- Standard RevealJS YAML with theme, bibliography119- Environment parity with CSS classes120- Plotly for Python-generated plots121122### Phase 2: Verify + Auto-Fix (autonomous — max 3 rounds)1231241. **Compile**: `typst compile FILE.typ` (or format-appropriate command)125 - Hard gate: exit code must be 01262. **Render sample PNGs**:127 - Documents <=3 pages → all pages128 - Documents >3 pages → page 1, middle page, last page129 - Presentations <30 slides → all slides130 - Presentations 30+ → first 3, middle 3, last 3131 - Command: `typst compile FILE.typ /tmp/create-preview-{0p}.png --pages [SAMPLE]`1323. **Visual inspection** — Read each PNG and check:133 - Content overflow / cut off?134 - Blank half-pages?135 - Font fallback squares (missing font)?136 - Missing images / broken references?137 - Cramped text / unbalanced layout?1384. **Structural query**: `typst query` for heading count, figure count1395. **If issues found** → fix → re-compile → re-render → re-check1406. Cap at 3 lightweight fix rounds141142### Phase 3: Present (final output to user)143144Deliver a summary:145146```147## Created: [filename]148149| Metric | Value |150|--------|-------|151| Pages | [N] |152| Sections | [N] |153| Visuals | [N figures, N diagrams] |154| Compile | PASS |155| Visual check | PASS / [issues noted] |156| Template | [template used] |157| Style inherited from | [sibling file or "none"] |158| Materials discovered | [list or "none"] |159160**What could break:** [list risks]161162**Next steps:** `/review` for deep audit · `/finish` for full pipeline · `/excellence` for milestone163```164165---166167## Figures & Code168169- Python scripts for data-driven content (plotly for Quarto only; matplotlib/plotnine for Typst charts)170- Diagrams: TikZ in Beamer source, fletcher/chronos/timeliney in Typst (NEVER Python), SVG for Quarto171- Save outputs as `.svg` for Typst embedding (preferred), `.png` for raster, `.parquet` for data persistence172173---174175## Post-Creation Checklist176177```178[ ] Document compiles without errors179[ ] No overflow issues (verified via PNG)180[ ] All citations resolve181[ ] Every definition has motivation + worked example182[ ] Max 2 colored boxes/callouts per slide/page183[ ] 2-3 Socratic questions embedded (for slides)184[ ] Transition slides between sections (for slides)185[ ] Visual aids present where content benefits from them186[ ] New notation added to knowledge base187```188189---190191## Format-Specific Notes192193### Typst Pedagogical Constraints (for slides)194- Motivation before formalism195- Max 2 boxes/slide196- Worked example within 2 slides of definition197- Fragment reveals with `#pause` (touying) — max 2-3 per slide198- Speaker notes with `#speaker-note[...]` for presenter context199- Use touying themes via qk-slides (see `typst/references/touying-guide.md`)200201### Beamer Pedagogical Constraints202- Same as Typst but using LaTeX environments203- No `\pause` or overlay commands204205### Devil's Advocate for Non-Slide Documents206- For guides: "Is this section ordering optimal for the reader?"207- For CVs: "Is this ATS-compatible? Is the hierarchy clear?"208- For pitch decks: "Does the narrative build to a clear ask?"209- For essays: "Is the argument structure compelling?"