About schema-dts
A guidance skill for developers authoring Schema.org JSON-LD with TypeScript. It focuses on compile-time type checking and covers graph structures, framework injection, and custom type generation.
Key features
- 01Type-check Schema.org JSON-LD
- 02Build WithContext and Graph documents
- 03Handle multi-type nodes and Action constraints
- 04Guide framework injection and safe serialization
- 05Generate types with schema-dts-gen
Use cases
- 01Create typed structured data for web pages
- 02Compose Graph documents with shared entities
- 03Generate TypeScript types for custom ontologies
Install
Copy the command and run it in a terminal.
$
npx skills add https:/ / github.com/ dobroslavradosavljevic/ skills --skill schema-dtsAfter installing, type/schema-dtsin Claude Code to confirm it loaded.
Bundled files
References and scripts installed along with SKILL.md.
agents/openai.yamlreferences/generator-migration.mdgraphs-merge-actions.mdpatterns-frameworks.mdsetup-core.mdsource-map.mdDetails
From the project READMEschema-dts
Use this skill when work touches schema-dts TypeScript types for Schema.org JSON-LD: building structured data objects, injecting <script type="application/ld+json">, multi-typed nodes, @graph documents, action input/output constraints, or regenerating typings with schema-dts-gen.
Workflow
- Inspect the local surface before changing code:
- Packages:
schema-dts(and optionallyschema-dts-gen,schema-dts-lib,react-schemaorg). - Version: target v2 (
[email protected]= Schema.org v30;[email protected]). Treat1.xas legacy. - Role: type-only compile-time checking (no runtime Schema.org validation).
- Shape: single
WithContext<T>node vsGraphwith@idstubs vs multi-@typeviaMergeLeafTypes. - Injection path: React/
react-schemaorg, NextScript, Astro/set:html, Svelte head, or vanilla DOM.
- Packages:
- Refresh docs when the user asks for latest behavior, the installed major is unclear, or work touches v2 helpers / generator output. Start from source-map.md.
- For install,
WithContext,Thingdiscrimination, DataTypes, and type-only imports, use setup-core.md. - For
Graph,IdReference,*Leaf,MergeLeafTypes, andWithActionConstraints, use graphs-merge-actions.md. - For common page schemas, XSS-safe serialization, and framework wiring, use patterns-frameworks.md.
- For
schema-dts-genCLI / programmatic generation and v1→v2 breaks, use generator-migration.md. - Implement in the existing project style:
- Prefer
import type { … } from 'schema-dts'. - Put
@context: 'https://schema.org'only on the document root (WithContextorGraph). - Prefer
bun/bunxin command examples when adding packages or running the generator.
- Prefer
Judgment
- Types only.
schema-dtscatches wrong@type/ unknown properties at compile time. It does not validate against Google Rich Results or Schema.org at runtime. - Ship core Schema.org from the prebuilt package. Pending / experimental layers need a custom
schema-dts-genrun, not hand-rolledascasts. - Always use
WithContext<T>(orGraph) for the top-level JSON-LD document so@contextis required and locked tohttps://schema.org. - Prefer the narrowest type that matches the page (
Product,Article,FAQPage) over typing everything asThing. - Use
*Leaf+MergeLeafTypesonly when@typeis genuinely an array of concrete types. Never pass union aliases likeProductintoMergeLeafTypes. - Use a
*Leafinterface when a class mustimplementsa Schema.org shape; union aliases cannot be implemented. - Run
schema-dts-gen2.0.1+ for any custom or third-party ontology.2.0.0letrdfs:commenttext inject code into generated output (GHSA-c4f4-pq98-f2p2). - Cross-link repeated entities with
@id+IdReferencestubs inside aGraphinstead of duplicating nested objects. - For sitelinks search box / Action markup, wrap or cast with
WithActionConstraintssoquery-input(and other*-input/*-output) type-check. - When injecting into HTML, escape
<,>,&,'in the JSON string (or usereact-schemaorg'sJsonLd). - Prefer absolute HTTPS URLs for
url,image,logo,sameAs, and@idvalues that crawlers resolve.
Verification
Prefer the repo's existing checks. For meaningful schema-dts work, include the relevant subset:
- Typecheck the JSON-LD builders and any framework wrappers.
- Confirm root objects use
WithContext/Graphand nested nodes omit@context. - Smoke-render the page and inspect the
application/ld+jsonscript(s) in the DOM / view-source. - Optionally paste output into Google Rich Results Test or Schema Markup Validator when SEO eligibility matters.
- After upgrading to v2, re-check Role-shaped properties,
Quantityassignments, multi-type nodes, and any customschema-dts-genoutput (now importsschema-dts-lib).
Comments
Markdown supported