Goal

Build a reusable notion-schema-validator helper that any Notion-writing skill can call pre-flight. The helper fetches the live data source schema, validates the payload, and either returns corrections or rewrites the payload in place.

Why

The merge session burned three create-pages calls on property-name and value-type issues that the schema would have caught in one notion-fetch:

API Surface

validateNotionPayload({
  data_source_id,
  properties
}) => {
  valid: boolean,
  issues: [{ property, problem, suggestion }],
  rewritten_properties: { ... },  // auto-corrected where possible
  new_tag_options_needed: string[] // tags that must be added to the DB first
}

Implementation Steps

  1. Create /Users/samaguiar/Documents/Projects/Skills/notion-schema-validator/SKILL.md.
  2. Helper calls notion-fetch on the provided data source.
  3. Parses the returned schema, extracts property names and types, lists select/multi-select options.
  4. Walks the caller's payload, checking each property against the schema.
  5. Auto-rewrites known patterns (URL -> userDefined:URL, multi-select strings -> JSON arrays).
  6. Returns any Tag values that are not in the schema as new_tag_options_needed. Caller can decide to add them via notion-update-data-source first.
  7. Add a CLI wrapper so it can be called directly during testing.

Pickup Prompt

Build notion-schema-validator as a standalone skill. Register it in the skills index. Update notion-knowledge-base to call the validator before every create-pages call. Write a test that feeds in the three pre-merge failure cases and confirms all three get caught and auto-corrected. Document the full API surface in the SKILL.md.