typst-building-contract-generator
Source: .opencode/skills/typst-building-contract-generator/SKILL.md — site rebuilt 2026-09-05.
--- name: typst-building-contract-generator description: Generate commercial sub-contract agreements and building contracts in Typst with Scots Law execution blocks, definition blocks, and numbered clauses. Use when asked to draft or edit a building contract or commercial sub-contract.
Typst Building Contract & Commercial Sub-Contract Skill¶
MANDATORY: run typst-planner first. No contract is drafted or compiled until a typst-planner plan for this document has been emitted and signed off.
This skill governs the drafting, layout, variable binding, and Scots Law execution testing for commercial sub-contract agreements, main construction contracts, and building agreements in Typst.
1. Document Variable Bindings (Section 1 Header)¶
Contracts created with this skill declare primary parties and parameters at the top of the .typ file:
#let project-name = "Athronhill Phase 1 Groundworks"
#let contractor = "MacGillivray Groundworks Civil Engineering Limited"
#let contractor-co = "SC123456"
#let subcontractor = "Athronhill Developments Limited"
#let subcontractor-co = "SC654321"
#let contract-sum = "£120,000.00"
#let start-date = "14 July 2026"
#let ref-no = "BLP/APW/2026/CO-09"
2. Helper Functions¶
Scots Law Execution Block — #execution-block(party-name, company-number)¶
Renders a 2-column Scots law formal signing block with director/signatory details on the left and witness signature & address on the right:
#execution-block(contractor, contractor-co)
Term Definitions — #definition(term, definition)¶
Renders a 2-column grid (150pt fixed term column, 1fr definition):
#definition("The Contract Sum", [The fixed consideration of #contract-sum...])
Paragraph & Clause Helpers¶
#p("(1)", [Body text]): Hanging paragraph for parties and recitals (dx: -2.2cm).#cl("2.1.1", [Body text]): Multi-level contract clause engine.
3. Document Sequence¶
- Cover Page: Top-left GREYSCALE logo (
@preview/graynessimage-grayscale— never plain#image(...); the whole document is grey scale, no colour anywhere), right-aligned title block, right-aligned simplified metadata block (The Contractor, The Sub-Contractor, Date, Reference), imprint footer,#pagebreak(). - Body Geometry: Margin
(left: 4.5cm, right: 2.5cm, top: 3.5cm, bottom: 3.5cm). Page counter reset#counter(page).update(1). - Parties & Background: Recitals
(1),(2)and(A),(B). - Substantive Sections: Definitions, Obligations, Payment Architecture, Variations, Dispute Resolution & Governing Law.
- Scots Law Execution Section:
#pagebreak()followed by#execution-block(...). - Schedules & Appendices:
#pagebreak()before Schedule 1 (Works) and Appendix A (Drawing Register).
4. Typst Manual & Reference¶
Before drafting or when unsure of any Typst function, parameter, or syntax, consult the local, searchable mirror of the official Typst documentation at:
..\_typst-manual\
- Function/element/type reference (e.g.
#counter,#align,#block,#grid,#set,#pagebreak,#text,#image,v,h): search the Rust doc comments under_typst-manual\typst-src\crates\typst-library\src\— every library item's full documentation and examples live there directly above its definition. - Language / syntax / scripting (
#let,#set,#show, markup, math,context):_typst-manual\typst-src\docs\content\reference\language\*.typandtutorial\. - Tutorials & guides:
_typst-manual\typst-src\docs\content\tutorial\andguides\.
See _typst-manual\README.md for lookup guidance.
Self-Learning: Runtime Environment Probe (RUN FIRST)¶
Before generating ANY document, probe the actual environment so you never ship a font or package that does not exist (Typst silently falls back, causing font discrepancies between the preview and the intended design):
powershell -ExecutionPolicy Bypass -File "..\_typst-manual\probe-fonts.ps1"
Read the output and the persisted report _typst-manual\font-probe-report.json. Then:
- Rewrite every font stack so its FIRST member is an installed font from the report
(e.g. this machine lacks
Liberation Sans/Linux Libertine/Liberation Serif, so prefer an installedArial/Libertinus Serif/Georgia/Cambria/Times New Roman). Never leave a missing font as the leading choice. - Verify each
@preview/...import is reported as cached; if missing, note that compilation needs network or the package must be cached first. - Only after resolving fonts/packages should you compile and generate the preview.
5. Compilation & Native Preview Workflow¶
Whenever generating or editing a building contract with this skill, you MUST compile the document into high-resolution PNGs and generate an interactive Carousel Artifact so the user can preview it natively in a local previews\ folder:
Step 1: Compile to PNG in Artifact Directory
typst compile contract.typ "previews\contract-page-{0p}.png" --ppi 144
Step 2: Create a Markdown Artifact (document_preview.md)
Set UserFacing: true and output a markdown preview referencing the PNGs by relative path.
# Native Document Preview
````carousel

<!-- slide -->

````