Skip to content
Back to skills

Scaffold Importer

ASecurity

A new venue importer end to end

  • 2 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added December 1, 2026
developmentgojavakotlinbashgitapiperformance

Works with

  • cli
  • api

Security analysis

A100/100

Scanned December 1, 2026

npx -y skills add enorm-labs/event-junkie --skill scaffold-importer --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Scaffold Importer?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Scaffold Importer
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/enorm-labs-scaffold-importer/badge)](https://www.skillsdirectory.com/skills/enorm-labs-scaffold-importer)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: scaffold-importer
description: "A new venue importer end to end"
---

# Scaffold a New Importer

Add a new venue event importer to `events-importer`, end to end: enum value, parser + importer classes, fixtures, tests, seed venue file — following ADR-007
and the importers already there.

**Arguments**: `$ARGUMENTS` names the venue and its listing URL (`SO36 https://so36.com/programm/`). Ask if either is missing.

## Important

- `git --no-pager`.
- Read [ADR-007](../../../docs/adr/ADR-007_WEB_SCRAPING_STRATEGY.md) in full first — architecture, selector strategy, scraping ethics. Read the venue's row in
  [EVENT_DATA_SOURCES.md](../../../docs/EVENT_DATA_SOURCES.md) for platform and quirks; it is not a field mapping — analyse the live site and map it onto
  [DATA_MODEL.md](../../../docs/DATA_MODEL.md) yourself.
- Copy the closest existing importer: **JSON / API source** — `scraper/festsaal/`, `scraper/neuezukunft/` (`AbstractJsonApiImporter`, `ApiClient`, one
  `*ApiScraper.kt`), or `scraper/madameclaude/` for a paged WordPress REST API (`AbstractWpRestImporter`); **single listing page** — `scraper/privatclub/` (`AbstractSinglePageWebsiteImporter`); **list + detail** — `scraper/cassiopeia/`,
  `scraper/astra/` (`AbstractTwoPageWebsiteImporter`). New code looks like the code around it; the shared helpers in `scraper/` are used, not reimplemented.

## 1. Reconnaissance

1. **`robots.txt`**: honour any `Disallow` on the listing and detail paths; disallowed means stop and report.
2. **Look for a JSON / API source before committing to HTML** (ADR-007 selector priority 1): XHR/`fetch` calls in the Network tab, WordPress
   `/wp-json/wp/v2/<type>`, an RSS feed, `?format=json`, an embedded calendar widget's boot endpoint (Festsaal is Wagtail REST, Neue Zukunft an Elfsight
   widget, Madame Claude WordPress `event` with ACF). `<script type="application/ld+json">` `schema.org/MusicEvent` is still an HTML fetch, parsed as JSON-LD
   (Astra, Privatclub). **A clean JSON source wins.**
3. **Save the real listing** (and one or two detail pages for list+detail, including an edge case — cancelled, sold out, free, missing date) as the fixture:
   `curl -sSL -A 'EventJunkie/1.0 (+https://github.com/enorm-labs/event-junkie)' '<url>' -o events-importer/src/test/resources/scraper/<venue>/<venue>-overview.html`.
   Then run `scripts/mask-fixture-contacts.py`: a saved page carries the venue's e-mail addresses, and a fixture never does (AGENTS.md § Privacy).
   **A 403 from `curl` is not a blocked source.** Cloudflare refuses curl by its fingerprint, whatever the User-Agent, and still serves the importer's JDK
   client. Fetch once with `java.net.http.HttpClient` and the same User-Agent before calling a source blocked.
4. **Classify**: JSON / API → `ApiClient.fetchJson` + a pure JSON scraper; JSON-LD → `HtmlFetcher`, read with `jsonLdEvents()` and the `schema*` readers;
   server-rendered HTML → Jsoup; **JS-rendered with no API → stop and flag** (Playwright is not in the project, ADR-007 §3, and adding it is a separate decision).
5. **Page pattern**: single page, list+detail or paginated. **First page only** (ADR-007 § Pagination); a venue that truly needs more loops inside
   `importEvents()`, never a changed interface.

## 2. The `EventSource` value

In `scraper/EventSource.kt`, **one line of KDoc about the venue itself** — nothing about the site or the parsing, which lives on the importer. The name becomes
`source_type` and the `sourceId` prefix:

```kotlin
/** SO36 Berlin – the Oranienstraße club central to Berlin's punk and new-wave history. */
SO36,
```

## 3. The `scraper/<venue>/` package

- **`<Venue>OverviewPageScraper.kt`** — pure, no I/O; a Jsoup `Document` + base URL in (or the raw JSON `String`), `List<ScrapedEvent>` out.
- **`<Venue>DetailPageScraper.kt`** — list+detail only; `ScrapedEvent?` for one page.
- **`<Venue>WebsiteImporter.kt`** — the `@Component` that fetches and wires. JSON in one response: extend
  `AbstractJsonApiImporter(apiClient, "<Venue>", <Venue>ApiScraper()::scrape)`, overriding `requestUrl` to build a query on the configured base, and `eventPages` when the feed links a page per event (LabSaal, Zita Club). The
  Events Calendar: extend `AbstractTecImporter`. A WordPress REST collection: extend `AbstractWpRestImporter`, which pages it with `walkWpRestPages`, never one page of 100. Single-page HTML:
  extend `AbstractSinglePageWebsiteImporter(htmlFetcher, "<Venue>", <Venue>OverviewPageScraper()::scrape)`, which owns the conditional fetch and the
  `NotModified` case; a listing paged by a next link overrides `maxListingPages` and `nextListingPage`, and an entry page that only links month pages
  extends `AbstractMonthPagesWebsiteImporter`. A loop over pages that keeps the others when one fails uses `readEach`; to add fields from each event's own page, override `enrichFromEventPage` with a parser, or `eventPageReader` when the page can also drop the row. **Never fetch an event page
  yourself**: the hook, or `withEventPageOrFlagged` in an importer that implements `EventImporter` directly, owns the catch, the `WARN` and the
  `detailUnavailable` flag that keeps the stored fields when the page fails. A performance listing whose rows share one page per production overrides
  `sharedPages`, which reads each page once through `enrichFromSharedPages` and flags every row of a failed one. All three HTML bases run one `HtmlImportPipeline`, so `cookies`, `sharedPages` and the second-language hooks mean the same on each. List+detail: extend `AbstractTwoPageWebsiteImporter`,
  pass `<Venue>OverviewPageScraper()::scrape` and `<Venue>DetailPageScraper()::scrape` to its constructor. Override `fillGapsFromOverview` only where the listing is authoritative for a field, as `primary.withGapsFrom(fallback).copy(…)`; the default fills every gap from the listing. A field the detail page supplies over the listing's own value goes in `detailPageOwns`, so a failed page keeps the stored one; add `ScrapedField.ARTISTS` where the page's lineup is finer than the listing's. `override val eventSource = EventSource.<VENUE>`.

**The importer's and scrapers' KDoc is the one home for the source** — platform, pages read and why, the traps, why a selector was chosen. Under 20 comment
lines on the importer, under 10 per scraper; **do not copy the boilerplate an existing scraper still carries** (purity, fixture setup, `@param document the
parsed document` — #393 deleted it from 106 files). A defect we could repair is an issue, not KDoc.

**What the source does not carry is a record** (#715). Every importer file ends with one, and the build fails without it:

```kotlin
val <VENUE>_LIMITATIONS =
    VenueLimitations(
        EventSource.<VENUE>,
        AcceptedLimitation(LimitedAspect.DOORS_TIME, "the site publishes only one time per night", verified = "<today>"),
    )
```

One `AcceptedLimitation` per withheld thing, the reason a property of the _site_, lowercase, one sentence, no full stop. `verified` is the ISO date you saw
the site withhold it — today, for a new importer. A venue that publishes everything
declares `VenueLimitations(EventSource.<VENUE>)` — a statement, not an omission. `/data-quality-audit` reads these; a limitation left in prose is re-reported
every run. A single-sound club that names no style declares it here as `houseGenre = "Techno"`, never as a `genre` constant in the scraper: the import fills
it into every music event that names no genre of its own.

## 4. Shared helpers, selectors, fields

`ScrapingExtensions.kt` (`textAt`, `attrAt`, `imgSrcAt`, `hrefAt`, `resolveUrl`), `DateParsingExtensions.kt` (`parseTime`, `parseIsoDate`, `parseIsoTime`),
`WeekdayDateExtensions.kt` (`inferYearForWeekday`; `neighbouringMonthOnWeekday`, for a full date whose printed weekday names another month),
`EventTypeMapping.kt` (`mapEventType`, `refineConcertVenueType`, `isFestivalTitle`), `ArtistNameMapping.kt` (`buildArtistList`), `NonArtistNames.kt` (`isPlaceholderName`, `isNonArtistName`),
`SupportLines.kt` (`extractSupportFromSubtitle`), `ActSlots.kt` (`parseActSlot`, for a DJ night's slot, which reads the `LIVE` role before the name is cleaned),
`LineupVocabulary.kt` (`LINE_UP_WORD`, `splitDjList`, `endsAsSentence`), `EventFieldMapping.kt` (`parseEventStatus`, `orderDoorsBeforeStart`, `cleanEventTitle`, `detectFree`),
`JsonLdEvents.kt` (`jsonLdEvents`, `schemaDate`, `schemaTime`, `schemaImageUrl`, `schemaSoldOut`). A helper two venues need
goes into the extension file and ADR-007's utility table, not the venue package.

Selectors in ADR-007's order: JSON-LD > semantic HTML5 (`article`, `time[datetime]`, headings) > ARIA > `data-*` > meaningful classes > **never** positional
(`div:nth-child(3)`, `.col-md-4`). Scope to the narrowest container; `:has()` for context.
**Write each selector so it holds in both of jsoup's query modes.** The pinned jsoup (`jsoup.version` in `gradle.properties`) defaults to the legacy mode.
Web query mode becomes the default in 1.25.1: a query matches below the element only, and `[a~=x]` is a token, not a regex. `selectFirstOrSelf` or
`selectWithSelf` when the element itself can match, `:matchesAttr(a, regex)` for a regex. `test` runs every scraper test in the legacy mode, and
`webQueryModeTest` runs them again in web mode (#4871).

`ScrapedEvent` (`scraper/ScrapedEvent.kt`): required `title`, `eventDate`, `sourceUrl`, `sourceId` = `"${EventSource.<VENUE>.sourceIdPrefix}$slug"` derived
from the canonical URL, never from mutable text. **Validate before returning**: skip a blank title or an unparseable date with a warning, and parse the
listing with `rows.parseListing(logger, "<Venue> event item", url = baseUrl) { … }`. It logs the row count and goes through `mapSkippingFailures`, so one
malformed event does not abort the import; never a hand-written count line or try/catch (#5305).

## 5. Tests

Under `src/test/kotlin/de/norm/events/scraper/<venue>/`: **`<Venue>OverviewPageScraperTest`** (and `DetailPageScraperTest`) parse the fixture
(`Jsoup.parse(html, baseUrl)`, or the raw string) and assert the count, one fully populated event, and the edge cases. **`<Venue>WebsiteImporterTest`** mocks
`ApiClient` or `HtmlFetcher` with MockK (`coEvery { … }`) and asserts `ImportResult.Success` with the right events and an empty page handled. Do not
restate what is tested once: the base class's tests cover propagated validators and a `NotModified` pass-through, and `EventImporterRegistryTest` checks
that every `EventSource` has exactly one importer. Test those two here only when the importer overrides its fetch path (`importEvents`, `requestUrl`, a
next-page hook) or implements `EventImporter` directly. Template: `PrivatclubWebsiteImporterTest`. JUnit 5 + Kotest + MockK; a fixed `Clock` where the
scraper infers the year.

## 6. Register the source

Sources are runtime rows, not Flyway (ADR-007). Each venue is one file, `http/importer/seed/venues/<venue-slug>.json` (#2824): the
`POST /api/admin/venues` body under `venue` (with `district`, `venueTypes` and, where the venue publishes one, `capacity`), and under `sources` the
`POST /api/admin/event-sources` body with `"sourceType": "<VENUE>"` and the listing `url`, without `venueId`. The file name is the venue's slug
(`Astra Kulturhaus` → `astra-kulturhaus.json`); `SeedVenueFilesTest` fails on a wrong one. Then run `scripts/dev-seed-parity.sh`: it regenerates
`http/importer/dev-seed.http`, the "Run all" file, with the venue, source and import requests. Never edit that file by hand; CI fails when it drifts.

```json
{
    "venue": { "name": "Astra Kulturhaus", "address": "Revaler Str. 99", "...": "..." },
    "sources": [
        {
            "name": "Astra Kulturhaus",
            "url": "https://www.astra-berlin.de/",
            "sourceType": "ASTRA",
            "enabled": true,
            "importIntervalMinutes": 1440,
            "maxRetries": 3
        }
    ]
}
```

**The venue may already have a file**, because a venue we know but do not import gets one with a `programmeUrl` and `"sources": []` (#2766). Look for
`http/importer/seed/venues/<venue-slug>.json` first. If it exists, create no second venue: add the source to its `sources` list and remove its
`programmeUrl`. The row on a cluster keeps its value, which the site stops showing once the source exists.

**The venue's `description` and `descriptionAlt`** are our own prose, English and German, one sentence each. Take the facts from the venue's own About or
history page, not from the listing. Open with what sets the venue apart — the building, its history, who programmes it, a house rule such as smoke-free —
then name its formats plainly. **No hedged tail**: "and the odd concert", "occasional club parties", "gelegentliche Konzerte" fit nearly any club and tell a
visitor nothing. A minor format is either named without the hedge or left out. The same holds for the one-line `EventSource` KDoc. A description already on
a cluster changes only through a guarded data migration, as V078 does; the seed alone never reaches it.

**And a row in `docs/licence-review/RESULTS.tsv`**, keyed on the same name: `scripts/seed-sources.py --enable` refuses to switch on a source without a
verdict, so a source missing here can be created on a cluster and never import. Read the venue's legal and press pages; an agent records `UNCLEAR`, and a
person confirms `PERMITTED` or `PROHIBITED` (`docs/licence-review/README.md` §3). The same row gives the source its translation licence:
`scripts/apply-licence-review.py` derives it from the description verdict (ADR-027, `docs/licence-review/README.md` §7).

**And the onboarding steps in the pull request**, under `## After deploy`, which `label-pr.yml` labels `after-deploy`: the new-venue block from
[`/post-release`](../post-release/SKILL.md#the-format-a-pull-request-writes), copied as written, so a session that runs it after the release seeds, reviews
and enables the source in the order the licence gate needs.

## 7. Verify

```bash
./gradlew :events-importer:test --tests '*<Venue>*' --tests '*ModularityTests'
./gradlew :events-importer:ktlintCheck :events-importer:detekt :events-importer:detektMain
```

Then `/verify`, then [`/importer-smoke`](../importer-smoke/SKILL.md) against the live site — the per-host throttle applies; do not hammer the venue.

## Checklist

- [ ] `robots.txt` checked; JSON/API source looked for first; not a JS SPA without an API
- [ ] `EventSource` value with a one-line venue description
- [ ] `<venue>/` package: scraper(s) + `@Component` importer; shared helpers reused; semantic selectors
- [ ] `sourceId` stable and prefixed; events validated before return
- [ ] `<VENUE>_LIMITATIONS` at the foot of the importer, registered in `AcceptedLimitations.declarations`; `ACCEPTED_LIMITATIONS.md` regenerated
- [ ] Fixtures under `src/test/resources/scraper/<venue>/`, masked (`scripts/mask-fixture-contacts.py check` is clean); scraper + importer tests cover happy path, edge cases, empty page, and NotModified only for an importer that owns its fetch path
- [ ] The venue file under `http/importer/seed/venues/` holds the source; `scripts/dev-seed-parity.sh` run; a `docs/licence-review/RESULTS.tsv` row under the same name
- [ ] Venue description read against the venue's own About page; opens with what sets it apart, no "the odd …" tail
- [ ] `venueTypes` from the venue's own site, one or more; `capacity` only from a figure the venue or its operator publishes
- [ ] `ktlintCheck`, detekt, `ModularityTests`, new tests green; `/verify` clean

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in development →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.