data-engineering
Transforms, validates, loads data in ETL pipelines. Use when building scrapers, validating NDJSON feeds, or importing data into CMS/DB targets.
git clone --depth 1 https://github.com/monkilabs/opencastle /tmp/data-engineering && cp -r /tmp/data-engineering/src/orchestrator/skills/data-engineering ~/.claude/skills/data-engineeringSKILL.md
# Data Engineering
Generic pipeline patterns. For project-specific sources, full schema references see [REFERENCE.md](./REFERENCE.md).
## Scraper Architecture
Launch a headless browser cluster (Puppeteer Cluster / Playwright) with `retryLimit: 3`, `retryDelay: 5000`, `timeout: 30000`, `args: ['--no-sandbox', '--disable-setuid-sandbox']`.
## NDJSON Output
One record per line. Schema:
| Field | Type | Notes |
|-------|------|-------|
| `name` | Required | Preserve original encoding |
| `lat`/`lng` | Required | GPS coordinates |
| `address` | Required | Full text |
| `source` | Required | e.g. `google-maps` |
| `sourceId` | Required | Source-unique ID |
| `category` | Required | Domain category |
| `rating`, `reviewCount`, `phone`, `website`, `openingHours`, `photos`, `priceLevel` | Optional | — |
## Recommended Workflow (numbered, with validation)
1. Scrape: run scraper in `--dry-run` to collect sample (50–200 records).
- Checkpoint: sample contains expected fields, geo data.
- Recovery: fix extractor selectors; re-run sample.
2. Validate NDJSON: run line-by-line JSON parse + schema validator (see `validate-ndjson.js` example).
- Checkpoint: 0 parse errors, required fields present.
- Recovery: run `ndjson-filter` to isolate failing records; inspect source HTML.
3. Dry-run import: import into staging with `createOrReplace` disabled; check counts, duplicates.
- Checkpoint: counts match expectation ±5%; no duplicates inserted.
- Recovery: revert staging; adjust dedupe key.
4. Backup: snapshot current target (DB export); store with timestamp.
5. Import: run import with idempotent keys; monitor logs; on failure revert to backup.
## Quick executable pipeline (copy & adapt)
```bash
node ./scripts/scrape-to-ndjson.js --out=data.ndjson --pages=100
node ./scripts/validate-ndjson.js data.ndjson
node ./scripts/dry-import.js data.ndjson --target=staging
node ./scripts/import.js data.ndjson --target=production
```
## Inline: minimal NDJSON validator
```js
const fs = require('fs'), rl = require('readline'), { z } = require('zod');
const schema = z.object({ name: z.string(), source: z.string(), sourceId: z.string() });
const iface = rl.createInterface({ input: fs.createReadStream(process.argv[2]) });
let line = 0, errors = 0;
for await (const l of iface) { line++; try { schema.parse(JSON.parse(l)); } catch(e) { console.error(`Line ${line}:`, e.message); errors++; } }
if (errors) { console.error(`${errors} errors`); process.exit(2); }
console.log('OK');
```
Full scraper, extended validator: see [REFERENCE.md](./REFERENCE.md).Creates pages/layouts, defines content collections, configures hydration directives, and wires integrations. Use when adding or modifying Astro pages, layouts, components, or content collections. Trigger terms: Astro, content collection, client:load, client:visible, astro:content
Drive real browsers via Chrome DevTools MCP: navigate pages, capture snapshots, run responsive checks, and collect console/perf traces. Use when the user mentions: 'validate UI change in Chrome', 'capture a screenshot', 'run responsive checks', or 'collect console logs'. Trigger terms: browser testing, DevTools, console logs, screenshot, responsive testing
Creates and deploys Cloudflare Workers, configures wrangler.toml bindings, sets up KV/D1/R2 storage and Durable Objects, manages Pages deployments, and implements edge function patterns. Use when building or deploying Cloudflare Workers, setting up Pages, working with KV/D1/R2 storage, configuring wrangler.toml, or deploying edge applications.
Creates Contentful content types, queries entries via GraphQL/REST, runs CLI migrations, and manages assets and locales. Use when building or modifying Contentful content models, writing queries, or migrating content.
Convex reactive database patterns, schema design, real-time queries, mutations, actions, authentication, migrations, performance optimization, and component creation. Use when designing Convex schemas, writing queries/mutations, managing the Convex backend, setting up auth, migrating data, optimizing performance, or building Convex components.
Deploys applications, databases, and services on self-hosted Coolify instances, manages environments and env vars, runs infrastructure diagnostics, and performs batch operations. Use when deploying apps to Coolify, managing Coolify servers, debugging deployment issues, setting up databases, or managing Coolify infrastructure.
Writes Cypress E2E/component tests, configures `cy.intercept()` and `cy.session()`, authors custom commands, and wires CI artifacts. Use when creating E2E specs, component tests, or CI test pipelines. Trigger terms: cypress, e2e, component test, cy.intercept, cy.session
Drizzle ORM schema definition, type-safe queries, relational queries, CRUD operations, transactions, migrations with drizzle-kit, and database setup for PostgreSQL, MySQL, and SQLite. Use when defining database schemas, writing queries or joins, managing migrations, setting up a new Drizzle project, or working with drizzle-kit.