scottish-court-form-builder
Generate Scottish Sheriff Court civil forms (Ordinary Cause & Commercial Actions) and collateral documents (intimations, certificates, oppositions, citations) with case-ref enforcement and Sheriffdom suggestions. Also drafts substantive pleading documents — initial writs, defences/answers, adjustments, (closed) records, inventories of productions, witness lists, joint minutes — using the court-filed exemplar library. Use when asked to build a court form like Form G1, G6, G7, O1-O7, or to draft an initial writ, defences, adjusted record, closed record, inventory of productions, list of witnesses, or joint minute.
Source: .opencode/skills/scottish-court-form-builder/SKILL.md — site rebuilt 2026-09-05.
Scottish Sheriff Court Form & Collateral Document Builder¶
Overview¶
This skill extracts case details (Case Reference, Sheriffdom, Court Location, Pursuer, Defender, Subject Matter) from a user-specified case directory and automatically generates both the Primary Court Form and all Collateral/Dependent Forms mapped under the Open Knowledge Format (OKF) index of the Act of Sederunt (Sheriff Court Ordinary Cause Rules) 1993.
Critical Protocol: Suggestion & User Verification¶
[!IMPORTANT] Always Suggest & Request Verification: The agent MUST suggest extracted/inferred values (especially Sheriffdom, Court Location, and Case Reference) and ask the user to check and confirm the answer before submitting or filing documents. Never assume inferred values are final without user review.
Key Requirements & Jurisdiction Protocol¶
- Mandatory Case Reference: Every generated form must include the official court Case Reference number.
- Sheriffdom & Court Jurisdiction Resolution:
- Every court form requires specifying the official Sheriffdom and Sheriff Court location (e.g. Sheriffdom of Glasgow and Strathkelvin at Glasgow, Sheriffdom of Lothian and Borders at Edinburgh).
- If starting a new action, look up or query
scotcourts.gov.ukto find candidate Sheriffdoms based on defender address or contractual jurisdiction. -
Always present the inferred Sheriffdom to the user as a suggestion and ask them to verify.
-
Green's Litigation Styles (GLS) Augmentation Layer:
- The style library located at
C:\Users\antho\OneDrive - The Building Law Practice\STYLES\Greens Litigation Styles\GLSis registered as an augmentation reference layer. - Augment, Do Not Override: Use GLS templates to enrich legal phrasing (e.g., standard craves, condescendence jurisdictional clauses under CJJA 1982, pleas-in-law, interlocutor terms) without overriding SCTS statutory form rules, warrant signature rules, or firm address defaults (
Greenlaw Works, 6 S Greenlaw Way, Newton Mearns, G77 6EF). -
Party Designation & Capacity Layout: Reference GLS to resolve exact text placement for corporate designations, company registration numbers, registered offices, partnership/executor capacities, and representative designations whenever standard form prompt boundaries are ambiguous.
-
Macphail Pleading Doctrine Layer:
resources/Macphail_pleadings.md(Macphail, Macphail's Sheriff Court Practice, 4th edn (2006) — verbatim Ch 9 Written Pleadings paras 9.01–9.43, printed pp 679–686+; top-of-file Contents/TOC plus in-file paragraph index) is registered as a content doctrine layer for the substantive sections of generated forms: CRAVE, CONDESCENDENCE, PLEAS-IN-LAW, and DEFENCES content (Form G1/G7).- Find paragraphs via the index:
resources/Macphail_index.md(table) /resources/Macphail_index.csv(machine-readable:para, printed_page, section, text, flag, chapter) — lookup by topic (section column: Nature and Functions of Pleadings / Principal Rules of Pleading / Specification / Relevancy / The need to be concise / Further minutes of amendment / Appeal / Section VII - Deletion of Scandalous and Irrelevant Averments). - Consult before drafting section text — key paras: nature/functions & fair notice 9.01–9.12; rules of pleading (facts not evidence/law, admissions, deemed admissions) 9.14–9.27; specification and relevancy (plea of no specification, irrelevancy, alternative averments) 9.28–9.43; pleader's duties 9.13.
- NOT INDEXED: paras 9.07 and 9.21 are blank in the transcription (
flag=y); Macphail Ch 10 (amendment procedure) is only available as 10.55–10.58 — leave-to-amend/minutes-of-amendment questions must be verified against the print book or the current OCR/RCS text before reliance. - Cite as
Macphail para 9.xxin anySources:/advice footer; quote verbatim; never invent a paragraph or page number. -
For full drafting guidance beyond form scaffolding, also load the OKF
pleadingskill (AArchive\Documents\OKF\.opencode\skills\pleading\), which adds Black, Braid, Scullion & Johnston 2nd edn (2025) with PB-indexed paragraphs. -
Court Document Exemplar Layer:
- A library of real, court-filed documents lives at
references/Court_Document_Exemplars/(indexed inCATALOG.md), covering the seven substantive document families: initial writs (01_Initial_Writs), defences/answers (02_Defences), adjustments (03_Adjustments), closed records (04_Closed_Records), inventories of productions (05_Inventories_of_Productions), witness lists (06_Witness_Lists), and joint minutes (07_Joint_Minutes). - FORM ONLY — zero content weight. These exemplars exist solely as patterns of layout: header/court-ref block, instance & party designation placement, crave/answer/plea numbering layout, section order and headings, adjustment mark-up layout (strike-through/underscore), inventory table columns, witness list columns, signature blocks. Their substantive content (wording, amounts, facts, legal propositions) carries no weight whatsoever and must never be echoed, adapted, or relied on when drafting.
- Never copy exemplar content: party names, sums, dates, facts, wording, or legal phrasing must never be taken from an exemplar — even rephrased — because it belongs to other matters and other cases. Substantive drafting content comes only from the doctrine layers (Macphail, layer 4), GLS styles (layer 3), and the OKF
pleadingskill. - Exemplars are internal reference material, never client content: do not send an exemplar itself to a client, court, or opponent.
- Subordination: exemplars only inform visual/formal structure; they are subordinate to the SCTS statutory forms, Macphail doctrine, GLS styles, and the firm address/signature defaults.
Master Formatting Standards (Official Template HTML & Playwright Engine)¶
- Forms render from the OFFICIAL SCTS Word templates (
resources/templates_html/— the 9 O/G templates exported once fromH:\My Drive\Court Forms\Forms_Word_Templatesas Word-filtered HTML, now fully local — no H: read at runtime). Population is field-schema regex + table-cell filling + token fallback (scripts/form_renderer.py) — deterministic, no Word COM at runtime, no docx paragraph surgery. Every un-matched pattern reports!! NO MATCHloudly rather than silently emitting an unpopulated form. Encoding is repaired (£/�/U+FFFDnormalised) before render. - Native fonts, official layout: forms keep the template's native Arial layout exactly (O3's own Symbol/Times artifacts and its Letter CSS are preserved in structure but forced to A4 at render). No firm-branding, no house-style typography — the official layout is the standard.
- A4 enforcement: the official O3 template ships as US Letter (
@page 612x792pt); rendering now coerces it to595.3x841.9ptin HTML and forcesformat="A4"in Playwright (per-template margins from the template's@page), so Brother A4 prints without clipping. - Mandatory Case Reference: every generated form must include the official court Case Reference (O1/O2 get a
Court Ref No:line inserted before the warrant text; O3/O4/O5/O7 have their own ref cells). Reference is sanitised for filenames (/->_). - Uppercase Bold Capacities: party names are normalised to CAPS (e.g.
ESSEL SECURITIES PLC... PURSUER). - No hardcoded matter data in the generator: party names, addresses, dates, fees, solicitor blocks, defender-solicitor blocks (O7 signature) all come from CLI args /
matter.yaml/ case-directory scan / firm defaults.scan_case_directoryis generic (readsmatter.yamlfirst, then directory-name PAI/SC patterns, then README/Chronology text); the Essel folder is retained only as a silent back-compat fallback that fills blanks without early return. - Every render is audited by
form_renderer.audit_pdf(A4 pages, Arial-only fonts, no leftover placeholders, parties/ref/dates present, single solicitor docquet, clean instance, clean £ glyph, no forbidden-text leaks) — a FAIL verdict blocks delivery; fix and re-render until PASS. Letter paper (size:612x792pt) is coerced to A4 at render. - Cover letters are compiled by
generate_typst_cover_letters(Typst letterhead, localresources/Word Letterhead Template Greyscale.png+ bundledapw signature.png);Our Refis derived from the case folder/case_ref, not a hard-coded Essel ref. Court address usesCOURT_HOUSESfor all sheriffdoms or the explicit--court-address.
Collateral Document Generation¶
Automatically generates dependent forms whenever a primary action is requested:
- Motion (Form G6 / G6A) $\rightarrow$ generates Form G7 (Intimation), Form G8 (Certificate of Intimation), and Form G9 (Notice of Opposition).
- Initial Writ (Form G1 / G1A) $\rightarrow$ generates Form O1/O2 (Warrants), Form O3 (Notice to Defender), Form O4/O5 (Citations), Form O6 (Certificate of Citation), and Form O7 (Notice of Intention to Defend).
- Minute $\rightarrow$ generates Form G7A/G7B/G7C (Intimations), Form G8, and Form G9.
- Commission & Diligence $\rightarrow$ generates Form G11/G11D, Form G11A (Intimation), Form G11B (Receipt to Haver), and Form G11C.
- Witness Citation $\rightarrow$ generates Form G13, Form G12 (Certificate of Citation), and Form G14/G15 (Oaths & Affirmations).
Substantive Pleading Document Generation¶
When the user asks for a pleading document (not a statutory form), draft it from the doctrine layers (Macphail layer 4, GLS layer 3, OKF pleading skill) and use the exemplar library (layer 5) only to replicate formal layout — never its content:
- Initial Writ ($\rightarrow$
Form G1): craves, condescendence, pleas-in-law — see01_Initial_Writsfor layout of crave numbering, sums-in-words/figures columns, interest craves, witness+production domestic crave. - Defences / Answers ($\rightarrow$
Form G2): answers by article of condescendence, pleas-in-law — see02_Defencesfor layout in single/multi-defender and counterclaim situations. - Adjustments / Open Record: strike-through/underscore mark-up layout against the last lodged version — see
03_Adjustments(the refused-late-adjustments exemplar shows the layout of a superseded draft). - Closed Record: layout of consolidated instance, craves, condescendence + answers, pleas-in-law, dated record heading — see
04_Closed_Records. - Inventory of Productions: court cover page layout, numbered items with descriptions and pagination, production numbers/bundle references — see
05_Inventories_of_Productions; for highlighting/bundle building use the OKFokf-inventoryskill. - List of Witnesses ($\rightarrow$
Form G10): layout of names, occupations, addresses — see06_Witness_Lists(including supplementary lists). - Joint Minute / Joint Motion: layout of crave, agreed facts, agreed productions, motion paragraphs — see
07_Joint_Minutes(signed exemplars + motion to interpone authority).
Every pleading document keeps the Master Formatting Standards (section above), includes the case reference, and follows the Sequential Documents Protocol: an initial writ generates the warrant/citation set ($\rightarrow$ Form O1–O7); a joint minute generates the motion to interpone authority and its intimations; a witness list coordinates with witness citations (Form G13).
Utility Script Usage¶
Run the Python builder script via python:
python "C:\Users\antho\.config\opencode\skills\scottish-court-form-builder\scripts\court_form_builder.py" \
--case-dir "h:\My Drive\<Case_Folder_Name>" \
--form-type "initial_writ" \
--service-date "01-08-2026" \
--notice-days 21 \
--crave "to grant decree against the Defender for payment of the sum of £149,500 with interest and expenses"
Script Options¶
--case-dir: (Required) Path to target case directory.--form-type: (Required)motion,initial_writ,minute,commission,witness.--case-ref: (Optional) Manual override for Case Reference.--sheriffdom: (Optional) Manual override for Sheriffdom.--court-location: (Optional) Manual override for Court Location.--court-address: (Optional) Sheriff Clerk / Sheriff Court House address (used by O5/O7; known addresses for all 22 sheriff courts otherwise derived fromCOURT_HOUSES).--pursuer/--defender: (Optional) Party names (normalised to CAPS).--pursuer-address/--defender-address: (Optional) Party designation addresses.--service-date: (Optional) Date of citation/service asDD-MM-YYYY(default today). Expiry of notice is computed as service + notice days.--notice-days: (Optional) Period of notice in days (default 21).--fee: (Optional) Court fee in pounds (default 142) - not the crave sum.--crave/--cond/--plea: (Optional) Substance of the initial writ; defaults are generated from the party names.--defender-solicitor: (Optional) Defender solicitor block for the O7 PART B signature (multi-line).--defender-pronoun: (Optional) Pronoun for the Defender in warrants/notices (itdefault for companies;him/herfor natural persons).--output-dir: (Optional) Custom destination folder for generated.pdfforms (defaultGenerated_Court_Formsinside the case folder - neverH:directly).--dry-run: (Optional) Populate HTML only, skip Playwright PDF render (fast verify - writes*.htmlnext to PDFs).--verify-only: (Optional) Scanmatter.yaml+ case folder and print suggested values only, no files written.
Every form is audited after rendering; the final JSON reports generated_pdf_files, available_forms, unavailable_forms and failed_audit (which must be empty before filing). Unavailable forms (e.g. Form G6 until tokenised) are SKIP with a notice.
Signature Protocol¶
The skill automatically embeds your official signature image (apw signature.png from APW Signature or Typst repository) across generated documents:
- Typst Cover Letters (.pdf): Embedded via #image("apw signature.png", width: 4.5cm) at the end of the letter block. Letters use the GREYSCALE letterhead Word Letterhead Template Greyscale.png as page-1 background (house style — never the colour Word Letterhead Template.pdf).
- Court forms: the solicitor docquet is typed text (Anthony Paul Wallace, Partner / The Building Law Practice Limited / Greenlaw Works... / Tel: 0141 378 7451 | Ref: <case ref>), per the official form signature lines — the rendered PDFs are unsigned and ready for wet/PDF signature as the court practice requires.
Critical Protocol: Non-PDF Text Draft Review First¶
[!IMPORTANT] Always Present Non-PDF Text Preview First: Whenever creating or updating a letter, the agent MUST first output a non-PDF text draft preview directly in the response so the user can verify all details (Recipient Address, Case Ref, Dates, Subject, Paragraphs, Enclosures) BEFORE or ALONGSIDE PDF compilation.
Cover Letter Generation¶
After generating the court forms, you must ALWAYS draft and compile the accompanying Typst cover letter for the court (or opponent) detailing the enclosures and necessary action.
- Write the dynamic content of the letter into a temporary
.typfile. - Use standard numbered lists (e.g.
1.,2.) for the main content, not the1.1.grid-based section commands unless specifically required. - If exact details (e.g., specific Sheriff Court address, contact names) are missing, insert clear placeholders like
[SHERIFF COURT NAME HERE]rather than failing or asking the user. - Compile the final PDF using the helper script:
python "C:\Users\antho\.config\opencode\skills\scottish-court-form-builder\scripts\generate_cover_letter.py" \
--case-dir "h:\My Drive\<Case_Folder_Name>" \
--body-file "C:\path\to\your\temp_body.typ"
Workflow for the Agent¶
- Extract Details: Scan case folder for Case Reference, Sheriffdom, Pursuer, and Defender.
- Suggest & Ask User to Check: Present extracted/inferred values clearly to the user (e.g. "Suggested Sheriffdom: Tayside, Central and Fife at Stirling. Please check and confirm if this is correct.").
- Consult the Doctrine Layer: Before drafting the CRAVE/CONDESCENDENCE/PLEAS-IN-LAW text, read the applicable Macphail paras (see layer 4 above); keep GLS phrasing for styles.
- Consult the Exemplar Layer: For pleading documents (writ, defences, adjustments, records, inventories, witness lists, joint minutes), check the matching exemplar sidecar (layer 5) for formal layout only — never for content or wording.
- Execute Form Generation: Call
court_form_builder.pywith confirmed/suggested inputs (PDF output; audit gate built in —failed_auditmust be empty). - Draft Letter Body: Write the dynamic body of the Typst cover letter to a temporary text file, listing the forms generated as enclosures.
- Generate Final Letter: Execute
generate_cover_letter.pyusing the temporary file. - Deliver Output Files: Provide links to generated primary
.pdfforms, collateral forms, and the final.pdfcover letter.