New to Claude Skills? Learn how to install them →

jeremylongshore on GitHub

PortalJS Define Schema

Free

Effortlessly define and manage dataset metadata profiles.

Get this skill

Free · Opens the source repo

What PortalJS Define Schema does

PortalJS Define Schema is a skill designed for defining and managing metadata profiles for datasets, specifically tailored for use with the PortalJS framework. This skill allows users to infer a Frictionless Table Schema from the dataset's data, which includes identifying fields, types, and constraints. Additionally, it facilitates the addition of essential Data Package metadata such as licenses, sources, and keywords, which are crucial for dataset cataloging and presentation. The output is written into the datasets.json file, enabling the showcase to render a detailed typed field table instead of a simple preview.

The skill operates on a profile ladder with four levels, providing flexibility based on the complexity of the dataset. Level 0 is the default, suitable for standard tabular datasets, while higher levels (L1 to L3) allow for additional descriptive fields and custom validation rules. This tiered approach ensures that users can start with basic schema definitions and expand as their needs evolve.

An interactive component enhances the user experience by prompting for necessary inputs and confirming inferred schemas, making it accessible even for those who may not be deeply familiar with data profiling. The skill is particularly useful for data publishers who need to prepare datasets for public access, ensuring that all necessary metadata is captured and structured correctly before publication.

This skill is ideal for developers and data professionals working within the PortalJS ecosystem who require a systematic approach to dataset metadata management. It streamlines the process of preparing datasets for display and ensures compliance with metadata standards, ultimately improving the quality and usability of published datasets.

When to use it

Use this skill when you need to define or update the metadata profile of a registered dataset in PortalJS, especially before publishing it.

When not to use it

This skill is not suitable for datasets that do not require metadata definitions or for users not utilizing the PortalJS framework.

What you can build with it

Defining a Schema for a New Dataset

Use the skill to define the metadata profile for a newly registered dataset, ensuring it meets publication standards.

Updating Metadata for Existing Datasets

Leverage the skill to update or refine the metadata of existing datasets, adding necessary fields and constraints.

Creating Custom Validation for Specialized Datasets

Utilize the skill's advanced profile options to create custom validation rules for datasets with unique requirements.

How to install PortalJS Define Schema

View source

1. Install with the skills CLI

npx skills add jeremylongshore/claude-code-plugins-plus-skills/portaljs-define-schema --agent claude-code

2. Or install it manually

Download the skill folder and drop it into ~/.claude/skills/ for all projects, or .claude/skills/ to scope it to one repo. Restart Claude Code so it picks up the new skill.

Anthropic's agentic coding CLI, and the reference implementation of Agent Skills. Drop a skill folder into ~/.claude/skills and Claude Code loads it automatically whenever a task matches the skill's description. Claude Code docs

Inside SKILL.md

Written by jeremylongshore

PortalJS — Define Schema

Overview

Define a dataset's metadata profile — the authoring skill for the metadata-profile contract (lib/metadata). Where portaljs-add-dataset registers that a dataset exists, this skill describes what its data means: infer a Frictionless Table Schema (fields, types, constraints) from sampled data, add the Data Package fields a catalog surfaces (title, licenses, sources, keywords), and write them onto the dataset's entry in datasets.json. The showcase at /@<namespace>/<slug> then renders a typed field table instead of a bare preview. The model is Frictionless-native; DCAT is a serialization layer built on top later, not authored here.

The skill runs on a profile ladder — reach for higher levels only when needed:

LevelWhat it isWhen
L0Default frictionless-tabular profile; declare schema + metadata.Default. Standard tabular CSV/TSV.
L1L0 plus extra descriptive package fields.Extra metadata, standard validation is fine.
L2Fully custom profile (own schema template + validate()).A dataset type needing custom validation rules.
L3Multiple registered profiles, resolved per dataset.A portal mixing dataset types.

The skill is interactive and never dead-ends: if input is thin it interviews in short rounds, infers defaults from the data, echoes the schema for confirmation, and accepts "use defaults" to proceed with the inferred schema as-is.

Prerequisites

  • A scaffolded PortalJS portal with the metadata contract (lib/metadata/types.ts, pages/[owner]/[slug].tsx); see portaljs-new-portal.
  • The target dataset already registered in datasets.json (see portaljs-add-dataset).
  • For tabular schema inference, the dataset's CSV/TSV file present under PORTAL_DIR/public/data/. JSON/GeoJSON datasets get package metadata only — no fields.
  • Node 18+; tsx optional, used for the schema-validation check.

Instructions

The canonical, full step-by-step workflow is .claude/commands/portaljs-define-schema.md — the single source of truth. Read and follow it when executing. Summary:

  1. Gather PORTAL_DIR, DATASET (slug or namespace/slug), and LEVEL (default L0) from input; if DATASET is missing, list the portal's slugs and ask.
  2. Validate the portal has the metadata contract (datasets.json, lib/metadata/types.ts, the showcase route); proceed anyway if lib/metadata/ predates the contract.
  3. For tabular datasets, sample the header and ~50 rows from public/data/<file> and infer each field's type, constraints (required, unique, pattern), and a primary key.
  4. Echo the inferred schema as a table for confirmation; offer to go beyond L0 only if warranted.
  5. Ask for optional Data Package metadata: license, source(s), keywords, version.
  6. Write the schema and metadata onto the dataset's entry in datasets.json in place, preserving all other fields; for L2/L3, scaffold and register a custom profile module.
  7. Optionally validate the schema against the data's rows via the profile's validate().
  8. Verify with npx next build; fix malformed JSON or an invalid FieldType before reporting success.
  9. Report the profile, fields, metadata set, and the showcase URL.

Output

  • Modified: datasets.json (target entry gains profile, schema, licenses, sources, keywords, version — unset fields omitted).
  • Created (L2/L3 only): lib/metadata/<profile-id>.ts; lib/metadata/registry.ts updated with a registerProfile(...) call.
  • Verified: npx next build succeeds.
  • Result: /@<namespace>/<slug> renders a typed field table in place of a bare preview.

Error Handling

SymptomCauseFix
Dataset not found in datasets.jsonWrong slug or missing namespace/ prefixList available slugs and re-prompt.
lib/metadata/ missingPortal predates the metadata-profile contractProceed anyway — schema fields are optional and ignored by older showcases.
No fields schema producedDataset is JSON/GeoJSON, not tabularExpected — capture Data Package metadata only.
Validation reports type errorsSampled values don't coerce to the inferred typeRelax the type or drop the offending required/pattern constraint.
next build fails on datasets.jsonStray comma or a type outside FieldTypeFix the JSON/type and rebuild before reporting success.

Examples

Example 1 — Default L0 schema for a CSV dataset

/portaljs-define-schema population-2022

Infers fields (e.g. country: string, population: integer), drafts titles, asks for a license and source, and writes the schema under the default frictionless-tabular profile.

Example 2 — Metadata only for a GeoJSON dataset

/portaljs-define-schema neighborhoods-geo

GeoJSON has no tabular fields; the skill captures license, sources, and keywords onto the entry and skips schema inference.

Example 3 — Custom L2 profile with its own validation

/portaljs-define-schema co2-emissions level=L2

Scaffolds lib/metadata/co2-emissions-profile.ts with a custom validate(), registers it in lib/metadata/registry.ts, and sets "profile": "co2-emissions-profile" on the entry.

Resources

Frequently asked questions about PortalJS Define Schema

Similar skills