Skip to main content

Build

Portaljs Define Schema

portaljs

Define a dataset's metadata profile — infer a Frictionless Table Schema from its data, add Data Package metadata (license, sources, keywords), and write it into datasets.json so the showcase renders a typed field table. Extend or customize via the L0-L3 profile ladder. Use when a registered dataset needs field types, constraints, or catalog metadata before publishing.

  • New
  • v1.0.0
  • Reviewed Aug 24
  • No reviews yet

Getting started

Full instructions

Install the skill, then ask your AI tool for the task in plain words. The full SKILL.md below shows what it covers.

Instructions: SKILL.mdv1.0.0

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:

Level What it is When
L0 Default frictionless-tabular profile; declare schema + metadata. Default. Standard tabular CSV/TSV.
L1 L0 plus extra descriptive package fields. Extra metadata, standard validation is fine.
L2 Fully custom profile (own schema template + validate()). A dataset type needing custom validation rules.
L3 Multiple 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

Symptom Cause Fix
Dataset not found in datasets.json Wrong slug or missing namespace/ prefix List available slugs and re-prompt.
lib/metadata/ missing Portal predates the metadata-profile contract Proceed anyway — schema fields are optional and ignored by older showcases.
No fields schema produced Dataset is JSON/GeoJSON, not tabular Expected — capture Data Package metadata only.
Validation reports type errors Sampled values don't coerce to the inferred type Relax the type or drop the offending required/pattern constraint.
next build fails on datasets.json Stray comma or a type outside FieldType Fix the JSON/type and rebuild before reporting success.

Examples

Example 1 — Default L0 schema for a CSV dataset

text
/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

text
/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

text
/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

  • Full workflow: .claude/commands/portaljs-define-schema.md
  • Field-type and troubleshooting reference: references/reference.md
  • Related skills: portaljs-add-dataset, portaljs-add-dcat, portaljs-check-data-quality
  • Frictionless Table Schema specification: https://datapackage.org/standard/table-schema/

Explore more skills

Browse all
This skill doesn’t include stateful context yet, instructions only. Learn about stateful skills.

Security

Loading security scan...

Reviews (0)

More from portaljs

View source →
arcgis-to-portaljsMigrate a whole ArcGIS Hub site into a PortalJS Arc portal end-to-end. Harvests the Hub /data.json (DCAT-US) inventory, exports every FeatureService layer through the ArcGIS REST query API with resultOffset paging, converts each to the…1 installsportaljs-add-geoAuto-ingest a geospatial file (GeoJSON, Shapefile, GeoPackage, KML/KMZ, FlatGeobuf, CSV-with-geometry) into a PortalJS portal on the user's own machine, with no server. Normalizes CRS to EPSG:4326, derives a PMTiles render tier and a…0 installsportaljs-add-chartAdd a chart (line, bar, area, pie, or scatter) to a dataset's showcase in a PortalJS portal. Installs recharts, writes a reusable Chart component, and renders it in the showcase Views section. Use when visualizing a dataset already…0 installsportaljs-add-dcatMake a PortalJS portal harvestable by national/EU/US open-data portals — emit standards-compliant DCAT catalog feeds (DCAT 2/3, DCAT-AP, DCAT-US, national profiles) in JSON-LD, Turtle, and RDF/XML at build, with autodiscovery and…0 installsportaljs-add-mapRender a GeoJSON dataset on an interactive Leaflet map in the Views section of a dataset's showcase. Installs react-leaflet and a Map component, then renders the map for the chosen dataset. Use when a dataset's data is geographic and a map…0 installsportaljs-add-datasetAdd a dataset (CSV, TSV, JSON, or GeoJSON) to an existing PortalJS portal. Appends an entry to datasets.json so the catalog and showcase render it automatically; routes the data by source (local file vs remote URL) — R2 via Git LFS by…0 installs

Frequently asked questions about portaljs-define-schema

What does the portaljs-define-schema skill do?

Define a dataset's metadata profile — infer a Frictionless Table Schema from its data, add Data Package metadata (license, sources, keywords), and write it into datasets.json so the showcase renders a typed field table. Extend or customize via the L0-L3 profile ladder. Use when a registered dataset needs field types, constraints, or catalog metadata before publishing. It's a reusable SKILL.md instruction set that loads into your AI coding assistant on demand, no prompt engineering, no copy-pasting every session.

How do I install the portaljs-define-schema skill?

Run `npx @skills-hub-ai/cli install portaljs-define-schema` from your terminal. The CLI writes the SKILL.md to the correct location for your AI tool (e.g. ~/.claude/skills/portaljs-define-schema/ for Claude Code or ~/.cursor/skills/ for Cursor with --target cursor) and adds it to your project's .skills.json lockfile.

Which AI tools does portaljs-define-schema work with?

portaljs-define-schema runs in Claude Code. It follows the open Agent Skills standard (SKILL.md), so the same skill works in every supported tool without modification.

Is the portaljs-define-schema skill free?

Yes. Every skill on skills-hub.ai is free and open-source. There are no premium tiers, paywalls, or usage limits. You only pay for whatever AI assistant you're already using.

How do I use portaljs-define-schema after installing it?

In Claude Code, type `/portaljs-define-schema` (or whatever slash command the skill registers) and the AI follows the skill's instructions immediately. You can also reference it by name in natural language, your AI loads the skill into context when relevant.

Can I share the portaljs-define-schema skill with my team?

Yes. Commit your project's .skills.json lockfile and teammates run `npx @skills-hub-ai/cli install` (no args) to install every skill at the exact version you pinned. Organization-scoped installs work via skills-hub.ai organizations.

Badge for your README

Show that this skill is on Skills Hub. The badge links back to this page and shows the live install count.

Install on Skills Hub badge preview
Markdown
[![Install on Skills Hub](https://skills-hub.ai/api/badges/skill/portaljs-define-schema)](https://skills-hub.ai/skills/portaljs-define-schema)
HTML
<a href="https://skills-hub.ai/skills/portaljs-define-schema"><img src="https://skills-hub.ai/api/badges/skill/portaljs-define-schema" alt="Install on Skills Hub"></a>

More options in the badge docs.