{"data":{"slug":"github-datopian-portaljs-skills-portaljs-add-dataset-d7491f62df5f","title":"Register Dataset in PortalJS Portal","summary":"Add a dataset (CSV, TSV, JSON, or GeoJSON) to an existing PortalJS portal by appending an entry to datasets.json and routing the data via R2\/Git LFS or passthrough. The dataset will appear in the catalog at `\/search` and render automatically at `\/@<namespace>\/<slug>`.","url":"https:\/\/skillshunter.net\/skills\/github-datopian-portaljs-skills-portaljs-add-dataset-d7491f62df5f","json_url":"https:\/\/skillshunter.net\/api\/public\/v1\/skills\/github-datopian-portaljs-skills-portaljs-add-dataset-d7491f62df5f","markdown_url":"https:\/\/skillshunter.net\/skills\/github-datopian-portaljs-skills-portaljs-add-dataset-d7491f62df5f.md","download_url":"https:\/\/skillshunter.net\/skills\/github-datopian-portaljs-skills-portaljs-add-dataset-d7491f62df5f\/download","category":{"slug":"data-research","name":"Data & Research"},"editor_note":"Ensure a scaffolded PortalJS portal with `datasets.json`, `package.json`, and `pages\/[owner]\/[slug].tsx` is present. For R2\/Git LFS routing, install `git` and `git-lfs`, and have an Arc account token or OSS Giftless key. Node 18+ and npm must be available in the portal directory.","instructions":"---\nname: portaljs-add-dataset\ndescription: Add 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) \u2014 R2 via Git LFS by default, remote URLs by passthrough. Use when registering a new dataset in a scaffolded portal.\nallowed-tools: Read, Write, Edit, Bash(npm:*), Bash(npx:*), Bash(git:*), Bash(curl:*), Bash(mkdir:*), Bash(cp:*), WebFetch\nversion: 1.0.0\nauthor: Datopian <hello@datopian.com>\nlicense: MIT\ncompatibility: Claude Code with PortalJS portals (Next.js 14, React 18, Node 18+). Runs from any project via the plugin, a personal ~\/.claude\/commands install, or a portaljs clone.\ntags:\n  - portaljs\n  - data-portal\n  - dataset\n  - csv\n  - geojson\n  - catalog\n---\n\n# PortalJS \u2014 Add Dataset\n\n## Overview\n\nRegister a dataset in a PortalJS (`portaljs-catalog`) portal. The skill appends one entry to\n`datasets.json` \u2014 the single source of truth for the catalog \u2014 and routes the underlying\nbytes by **source first, then size**: a local file defaults to R2 via Git LFS, a remote URL\ndefaults to passthrough (no copy). No per-dataset page is created; the catalog at `\/search`\nlists the new entry and the dynamic showcase route `pages\/[owner]\/[slug].tsx` renders it\nautomatically at `\/@<namespace>\/<slug>`. Supported formats for the showcase preview: CSV,\nTSV, JSON (array), and GeoJSON.\n\n## Prerequisites\n\n- A scaffolded PortalJS portal (see `portaljs-new-portal`) with `datasets.json`,\n  `package.json`, and `pages\/[owner]\/[slug].tsx` present.\n- The source data: a local file path or a publicly reachable URL.\n- For the R2\/Git LFS default route: `git` and `git-lfs` installed, and an Arc account token\n  (or an OSS Giftless key) to mint a push-scoped LFS credential.\n- Node 18+ and npm available in the portal directory.\n\n## Instructions\n\nThe canonical, full step-by-step workflow is\n[`.claude\/commands\/portaljs-add-dataset.md`](https:\/\/github.com\/datopian\/portaljs\/blob\/main\/.claude\/commands\/portaljs-add-dataset.md) \u2014\nthe single source of truth. Read and follow it when executing. Summary:\n\n1. Gather input from `$ARGUMENTS` \u2014 source (file path or URL), portal directory (default\n   `.`), dataset name\/slug, description, namespace. If the source is missing, interview the\n   user; never dead-end.\n2. Validate the portal directory: confirm `datasets.json`, `package.json`, and\n   `pages\/[owner]\/[slug].tsx` exist.\n3. Detect the format from the file extension, URL extension, or `Content-Type` header\n   (CSV, TSV, JSON array, or GeoJSON); reject anything else and ask for a conversion.\n4. Route the data by source: remote URL \u2192 passthrough (default) or adopt into R2 (opt-in);\n   local file \u2192 R2 via Git LFS (default) or inline into `public\/data\/` (fenced exception for\n   bundled samples or an OSS-no-R2 fallback).\n5. Append one entry to `datasets.json` \u2014 `slug`, `namespace`, `name`, `description`, `file`\n   (the routed path\/URL), `format` \u2014 keeping `(namespace, slug)` unique.\n6. Verify the build with `npx next build`; fix errors (commonly malformed JSON) before\n   reporting success.\n7. Report the route taken, the manifest change, and the showcase URL.\n\n## Output\n\n- **Modified:** `datasets.json` (one entry appended).\n- **Created (route-dependent):** `data\/<slug>.<ext>` tracked via Git LFS (R2 default), or\n  `public\/data\/<slug>.<ext>` (inline exception). Nothing is created for remote passthrough.\n- **Verified:** `npx next build` passes.\n- **Result:** the dataset appears in `\/search` and renders at `\/@<namespace>\/<slug>`.\n\n## Error Handling\n\n| Symptom | Cause | Fix |\n| --- | --- | --- |\n| Fetch fails for a URL source | Non-200 status or unreachable host | Report the HTTP status and ask the user to confirm the URL is publicly accessible. |\n| \"Not a portaljs-catalog portal\" | `datasets.json` missing | This is an older single-page template; ask the user how to proceed rather than failing silently. |\n| Unsupported format | Extension\/content-type isn't csv\/tsv\/json\/geojson | Ask the user to convert the source before continuing. |\n| `git lfs push` has nothing to stream | `git lfs install --local` never ran, so raw bytes were committed instead of a pointer | Run `git lfs install --local` before `git lfs track`, re-add and re-commit the file. |\n| R2 PUT returns 400 | A broad `http.extraHeader` was set and replayed onto the presigned URL | Use the `_jwt` Basic-auth piggyback in `lfs.url` only \u2014 never a global `http.extraHeader`. |\n| `(namespace, slug)` clash | Another entry already uses that pair | Ask the user for a different slug or namespace. |\n| `next build` fails | Malformed JSON in `datasets.json` | Print the build log, fix the JSON, rebuild before reporting success. |\n\n## Examples\n\n### Example 1 \u2014 Local CSV, default R2 route\n\n```\n\/portaljs-add-dataset .\/data\/co2-emissions.csv namespace=climate\n```\nMoves the file into `data\/`, tracks it with Git LFS, pushes it to R2, and appends a manifest\nentry whose `file` is the resulting `https:\/\/data.portaljs.com\/...` URL.\n\n### Example 2 \u2014 Remote URL, passthrough (no download)\n\n```\n\/portaljs-add-dataset https:\/\/example.org\/open-data\/trade.csv namespace=trade\n```\nDetects the format from the response headers and records the URL as-is in `datasets.json` \u2014\nno bytes are copied.\n\n### Example 3 \u2014 GeoJSON adopted into R2\n\n```\n\/portaljs-add-dataset https:\/\/example.org\/boundaries.geojson namespace=reference adopt=true\n```\nDownloads the file, then routes it as a local file through the Git LFS \u2192 R2 path so it is\nhosted and versioned under the portal (useful when in-browser range queries are needed).\n\n### Example 4 \u2014 Bundled sample data, inline exception\n\n```\n\/portaljs-add-dataset .\/samples\/demo.csv namespace=reference\n```\nWhen the portal has no R2 credentials (OSS self-host) or the file is bundled sample data,\nthe skill copies it into `public\/data\/` instead, per the `.gitattributes` inline fence.\n\n## Resources\n\n- Full workflow: [`.claude\/commands\/portaljs-add-dataset.md`](https:\/\/github.com\/datopian\/portaljs\/blob\/main\/.claude\/commands\/portaljs-add-dataset.md)\n- Manifest fields and routing details: [`references\/reference.md`](references\/reference.md)\n- Related skills: `portaljs-new-portal`, `portaljs-add-chart`, `portaljs-add-map`, `portaljs-define-schema`\n- Git LFS documentation: <https:\/\/git-lfs.com\/>\n","use_cases":["Register a local CSV file with R2\/Git LFS routing","Register a remote URL with passthrough routing","Add a GeoJSON file to the portal catalog"],"limitations":[],"compatibility":[],"setup_tip":null,"sample_input":null,"sample_output":null,"source_url":"https:\/\/github.com\/datopian\/portaljs\/blob\/fc7ccd651459549a962c8b7aa08f60f8849fd9a5\/skills\/portaljs-add-dataset\/SKILL.md","source_commit":"fc7ccd651459549a962c8b7aa08f60f8849fd9a5","license":"MIT","version":"1.0.0","listing_approved_at":"2026-11-22","created_at":"2026-11-21T15:45:49.000000Z","updated_at":"2026-11-22T11:18:24.000000Z","seo_title":"Register Dataset in PortalJS Portal","seo_description":"Add a dataset to a PortalJS portal by appending to datasets.json and routing data via R2\/Git LFS or passthrough.","seo_keywords":["portaljs add dataset","register dataset in portaljs","add dataset to portaljs portal","portaljs dataset routing","portaljs catalog entry"]}}