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.
- Request https://<origin>/sku.md using manual redirect handling and verify HTTP 200 with text/markdown or text/plain UTF-8 bytes.
- Only if /sku.md returns exact HTTP 404 with redirect_count === 0, request the same-origin homepage HTML.
- 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.
- Reject missing href values, conflicting multiple alternate declarations, cross-origin targets, non-HTTPS protocols, and any query or fragment delimiter.
- 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.
| Limit or Guard | Normative Value | Failure or Boundary Behavior |
|---|---|---|
| Max Markdown document size | 65,536 UTF-8 bytes (64 KiB) | Returns resource_too_large; response stream cancelled early |
| Max physical line length | 8,192 UTF-8 bytes | Checked before CommonMark parsing; returns unsafe_markdown |
| Per-fetch timeout & redirects | 5,000 ms timeout; max 3 manual hops | Timeouts or 429/5xx yield incomplete; excess hops fail |
| Published graph traversal budget | 31 product docs, 63 fetches, 1 MiB total, 12 s | Stops cleanly, populates coverage.remaining, marks incomplete |
| Unique Source URLs per graph | 256 Source URLs | Exceeding 256 prevents Source checks and warns on incomplete coverage |
| Product knowledge XML Sitemap | 1 to 50,000 entries; max 50 MiB file | Single 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.
| Outcome status | When returned | Sources & guarantees |
|---|---|---|
| answered | Valid product doc matches non-live question in recognized sections | Returns matched item text, section name, and exact Source URLs |
| live_source_required | Question asks about price, stock, promotions, shipping, tax, or orders | Returns empty sources; caller routes user to live storefront or protocol |
| not_found | Valid product doc has zero lexical overlap in recognized sections | Returns empty sources rather than guessing or reading unknown sections |
| rejected | Invalid input shape, archived v0.10 frontmatter, or catalog document | Returns 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.
| Operation | Required stdin JSON keys | Optional keys & role |
|---|---|---|
| build-catalog | catalog, target_url, checked_at | Generates canonical /sku.md Markdown and validates it |
| build-product-knowledge | product_knowledge, target_url, checked_at | Generates product Markdown with Source-backed sections |
| validate-document | document, target_url, checked_at | Runs document-scope syntax and structure checks |
| validate-graph | root, resources, checked_at | Optional sitemaps (max 31) and source_evidence map |
| compare-documents | after_document, checked_at | Optional before_document and target URLs for semantic diff |
| audit-product | document, target_url | Optional channel JSON-LD and today; zero network fetches |
| evaluate-products | products (1-256), conditions (1-64) | Deterministic matched / excluded / insufficient evaluation |
| export-product | document, target_url | Optional 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-documentExits 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.
| Tool name | Execution mode | Primary purpose |
|---|---|---|
| sku_md_validate_document | Submitted content | Document-scope syntax, structure, and SHA-256 digest |
| sku_md_validate_document_graph | Submitted + safe Source HEAD/GET | Validates supplied graph and checks up to 256 Source URLs |
| sku_md_compare_documents | Submitted content | Normalized structural diff plus bounded unified Markdown diff |
| sku_md_audit_product | Submitted content | Checks missing attributes, conflicts, review status, 180-day staleness |
| sku_md_evaluate_products | Submitted content | Evaluates explicit purchase conditions without ranking or recommendations |
| sku_md_validate_published_document | Bounded public HTTPS fetch | Checks exact URL HTTP 200, MIME, UTF-8, redirects, and document rules |
| sku_md_validate_published_graph | Bounded discovery & graph fetch | Runs /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.
Developer tools and references
Tools Hub
Browse the catalog generator, reviewer, condition playground, and validators.
SKU.md Agent Skill
Local-first Claude Code and Codex Skill packaging sku-md-core.mjs with review-before-write.
Read-only MCP Server
Connect Claude or compatible MCP clients to https://sku.md/mcp.
Condition Playground
Test deterministic matched, excluded, and insufficient outcomes in the browser.
v1.0.0 Conformance Kit
Run the offline browser paste validator and inspect 28 document-scope test fixtures.
Product Knowledge Sitemaps
XML Sitemap rules, single-layer sitemapindex limits, and coverage budgets.
SKU.md 1.0.0 Glossary
Definitions for document, published, and graph scopes and core v1.0.0 terms.