Skip to content

DEVELOPER IMPLEMENTATION GUIDE

Reference Consumer, Discovery Order, and CLI Guide

Build an agent or crawler client that discovers SKU.md v1.0.0 catalogs conservatively, enforces strict byte and SSRF bounds, cites exact Sources, and keeps live commerce authority separate.

Updated

Safe catalog discovery order

A SKU.md v1.0.0 reader always starts from a known public HTTPS origin and checks /sku.md first, with query and fragment delimiters disallowed. Homepage HTML inspection is a narrow fallback that runs only after an exact HTTP 404 with zero redirects.

Timeouts, DNS failures, connection errors, HTTP 429 or 5xx responses, redirects, and malformed /sku.md bodies are not absence. A consumer must not scan surrounding site paths, guess /catalog.md, or read robots.txt, default sitemap.xml, or llms.txt to infer a SKU.md root.

  1. Request https://<origin>/sku.md using manual redirect handling and verify HTTP 200 with text/markdown or text/plain UTF-8 bytes.
  2. Only if /sku.md returns exact HTTP 404 with redirect_count === 0, request the same-origin homepage HTML.
  3. Inspect HTML <link> elements for one unambiguous <link rel="alternate" type="text/markdown" title="SKU.md" href="..."> and resolve it against the final homepage URL.
  4. Reject missing href values, conflicting multiple alternate declarations, cross-origin targets, non-HTTPS protocols, and any query or fragment delimiter.
  5. Validate the discovered root file as a v1.0.0 Catalog document before following any Product knowledge or Product knowledge Sitemap links.

Unambiguous homepage alternate link declaration

<link rel="alternate" type="text/markdown" title="SKU.md" href="/catalog.md">

Accepted only after an exact HTTP 404 on /sku.md with zero redirects, resolving to a same-origin query-free HTTPS URL.

Bounded parsing, anti-SSRF, and network limits

Markdown files and XML Sitemaps served by external storefronts are untrusted input. Before running CommonMark AST parsing, a conforming consumer enforces size and line limits so deeply nested or single-line payloads cannot exhaust memory or parser stack depth.

Network retrievals enforce public HTTPS target normalization, DNS resolution to public IP addresses only, and manual per-hop redirect checks. Network uncertainty or budget exhaustion leaves published and graph layers incomplete rather than treating unverified data as passed.

  • URL policy: HTTPS only without username, password, custom port, IP literals, localhost, .local, .internal, or .home.arpa.
  • DNS recheck: validate resolved IPv4 and IPv6 addresses against private, loopback, link-local, CGNAT, ULA, and reserved ranges before each request and on every redirect hop (maximum 3 redirects).
  • Pre-parse Markdown caps: maximum 65,536 UTF-8 bytes per document and maximum 8,192 UTF-8 bytes per physical line split on LF, CRLF, or CR before CommonMark parsing.
  • AST safety: reject raw HTML nodes (unsafe_markdown), reject linkReference, imageReference, and definition nodes in normative sections, and verify every AST URL resolves to credential-free HTTPS.
  • Prompt safety: treat headings, blockquotes, list items, link labels, and Evidence Quote text strictly as inert publisher data, never executable instructions.
SKU.md v1.0.0 parser and published-graph safety limits
Limit or GuardNormative ValueFailure or Boundary Behavior
Max Markdown document size65,536 UTF-8 bytes (64 KiB)Returns resource_too_large; response stream cancelled early
Max physical line length8,192 UTF-8 bytesChecked before CommonMark parsing; returns unsafe_markdown
Per-fetch timeout & redirects5,000 ms timeout; max 3 manual hopsTimeouts or 429/5xx yield incomplete; excess hops fail
Published graph traversal budget31 product docs, 63 fetches, 1 MiB total, 12 sStops cleanly, populates coverage.remaining, marks incomplete
Unique Source URLs per graph256 Source URLsExceeding 256 prevents Source checks and warns on incomplete coverage
Product knowledge XML Sitemap1 to 50,000 entries; max 50 MiB fileSingle sitemapindex layer max; rejects DTDs, entities, cycles

Conservative answering and live-state handoff

The Reference Consumer in src/lib/reference-consumer.ts (consumeProductReference) demonstrates deterministic product answering over validated Markdown. It validates exact bytes first, ignores unrecognized sections, checks live-commerce patterns before matching prose, and returns exact Source URLs on every answer.

When evaluating structured Product data records, deterministic evaluators apply explicit eq, in, lt, lte, gt, gte, and inclusive between filters strictly to reviewed attributes of matching scope. Variants never inherit product-level attributes, and missing, unknown, not_applicable, or incompatible-unit values return insufficient.

  • Live commerce handoff: questions about price, cost, promotions, coupons, discounts, stock, availability, shipping, delivery, tax, payments, carts, checkout, or orders return live_source_required with empty sources.
  • Recognized knowledge scope: answers draw only from Facts and the six recognized optional prose sections (Identifiers, Variants, Guidance, Limitations, Compatibility, Questions).
  • Staleness check: when a caller provides now and now minus Updated exceeds 180 days, warnings includes updated_stale while preserving factual attribution.
  • Unit conversions: deterministic filtering converts only mass (mg, g, kg, oz, lb), length (mm, cm, m, in, ft), and volume (ml, l); other dimensions compare only on identical unit strings.
Deterministic Reference Consumer outcomes
Outcome statusWhen returnedSources & guarantees
answeredValid product doc matches non-live question in recognized sectionsReturns matched item text, section name, and exact Source URLs
live_source_requiredQuestion asks about price, stock, promotions, shipping, tax, or ordersReturns empty sources; caller routes user to live storefront or protocol
not_foundValid product doc has zero lexical overlap in recognized sectionsReturns empty sources rather than guessing or reading unknown sections
rejectedInvalid input shape, archived v0.10 frontmatter, or catalog documentReturns issue codes such as invalid_input or product_document_required

Calling consumeProductReference on validated product Markdown

import { consumeProductReference } from "./src/lib/reference-consumer"; const outcome = consumeProductReference({  document: productMarkdown,  resourceUrl: "https://shop.example/products/tent.sku.md",  question: "What is the packaged weight?",  now: "2026-10-22T00:00:00.000Z",});

Performs zero network requests; returns answered, not_found, live_source_required, or rejected.

Local offline CLI and Agent Skill operations

The repository CLI (src/cli/sku-document-core-cli.ts) and the packaged Agent Skill runtime (skills/sku-md/scripts/sku-md-core.mjs) share the same deterministic parser, builder, auditor, and evaluator core. Both accept one UTF-8 JSON object on stdin up to 4 MiB and write one canonical JSON object to stdout, or structured error JSON to stderr with exit code 2.

The CLI never makes outbound HTTP requests. Validation, build, and comparison commands require an injected UTC checked_at timestamp so results remain reproducible, while published HTTP status and live Source checks remain separate.

All eight v1.0.0 CLI operations
OperationRequired stdin JSON keysOptional keys & role
build-catalogcatalog, target_url, checked_atGenerates canonical /sku.md Markdown and validates it
build-product-knowledgeproduct_knowledge, target_url, checked_atGenerates product Markdown with Source-backed sections
validate-documentdocument, target_url, checked_atRuns document-scope syntax and structure checks
validate-graphroot, resources, checked_atOptional sitemaps (max 31) and source_evidence map
compare-documentsafter_document, checked_atOptional before_document and target URLs for semantic diff
audit-productdocument, target_urlOptional channel JSON-LD and today; zero network fetches
evaluate-productsproducts (1-256), conditions (1-64)Deterministic matched / excluded / insufficient evaluation
export-productdocument, target_urlOptional channel and today; outputs reviewed patch proposal

Validate a local document and evaluate product conditions over stdin

printf '%s' '{"document":"# Example Shop\n> Trail gear.\n\nSKU.md: [1.0.0](https://sku.md/spec/1.0.0/)\nWebsite: [Example](https://shop.example/)\n\n## Catalog\n- [All](https://shop.example/all)\n","target_url":"https://shop.example/sku.md","checked_at":"2026-10-22T00:00:00.000Z"}' \  | node skills/sku-md/scripts/sku-md-core.mjs validate-document

Exits 0 with { cli_version, spec_version, operation, result }; exits 2 with { error: { code, message } } on invalid input.

Read-only remote MCP service workflows

For hosted agents that prefer remote verification, https://sku.md/mcp exposes seven stateless, anonymous, read-only tools implementing MCP 2026-07-28 (with 2025-11-25 compatibility). Five tools inspect caller-submitted payloads without scanning external origins, while two tools perform bounded public HTTPS fetches.

Public service bounds are 640 KiB per request, 64 KiB per Markdown document, 32 resources and 1 MiB per graph, and a 15-second request deadline, rate-limited to 20 requests/minute per source, 6 network-tool requests/minute, and 3/minute per target.

Seven read-only tools at https://sku.md/mcp
Tool nameExecution modePrimary purpose
sku_md_validate_documentSubmitted contentDocument-scope syntax, structure, and SHA-256 digest
sku_md_validate_document_graphSubmitted + safe Source HEAD/GETValidates supplied graph and checks up to 256 Source URLs
sku_md_compare_documentsSubmitted contentNormalized structural diff plus bounded unified Markdown diff
sku_md_audit_productSubmitted contentChecks missing attributes, conflicts, review status, 180-day staleness
sku_md_evaluate_productsSubmitted contentEvaluates explicit purchase conditions without ranking or recommendations
sku_md_validate_published_documentBounded public HTTPS fetchChecks exact URL HTTP 200, MIME, UTF-8, redirects, and document rules
sku_md_validate_published_graphBounded discovery & graph fetchRuns /sku.md -> 404 alternate discovery, Sitemaps, and Source checks

Developer implementation questions

Why must a consumer wait for an exact HTTP 404 before reading homepage alternate links?

A timeout, 5xx upstream error, rate limit, or redirect chain means /sku.md status is uncertain or misconfigured, not absent. Restricting fallback to HTTP 404 with zero redirects prevents silent discovery hijacking or masking broken root routing.

Why does the local CLI require an explicit checked_at timestamp instead of reading system time?

Injecting checked_at keeps document, graph, and comparison outputs bit-for-bit deterministic in tests and CI pipelines, and separates local evaluation from real-time network observation.

What happens when a store publishes more than 31 product documents in a Sitemap?

The merchant catalog has no 31-document cap: a Product knowledge Sitemap accepts up to 50,000 entries per file. The reference published-graph reader caps a single check at 31 product documents, reports remaining URLs in coverage, and returns incomplete rather than failing the merchant.