bruin-data/ingestr/add-source
Claude Code and agent skill by bruin-data/ingestr
- community
Checking that the SKILL.md file is still in the repository.
Implement a new ingestr source (API/SaaS connector) from scratch against a vendor's HTTP API. Use when a task asks to add a new source/connector, wire it into the URI registry, design its tables and incremental behavior, add its rate limiting, or write its tests. Covers researching the vendor API, creating the source package, the post-implementation review checklist, and verifying the output against the live account.
Install
npx vskill@latest install bruin-data/ingestr/add-sourceSKILL.md
The same SKILL.md was published earlier as bruin-data/ingestr/add-source.
Add an ingestr Source
This skill covers adding a new API / SaaS source. These are built from scratch against the vendor's HTTP API, so there's nothing to diff against — the vendor's official docs and the existing Go sources in pkg/source/ are the source of truth.
Workflow
- Study the vendor API (section 1). Don't write Go until endpoints, pagination, filtering,
and the table set are mapped out.
- Ask the user for test-account credentials (section 2).
- Look up rate limits and compute limiter values (section 3).
- Create the source package (section 4), then run
make generateandmake format. - Work through the review checklist (section 5) and fix what it turns up.
- Verify the output against the live account (section 6) and write tests (section 7).
- Add docs and report the per-table design back to the user (section 8).
1. Study the vendor's API first
The most important step. Read the official docs and map out, per endpoint:
- URL, query params, required headers/auth.
- Pagination style — per endpoint, not per API. Some return everything in one call; others
use cursor, page-number, or offset pagination.
- Which endpoints take time-based filter params, and the exact operator/field (e.g.
updated_since, from/to, >= vs >). Operators differ per endpoint — check each.
- Response shape — nested envelope vs flat array, and which objects are deeply nested.
- Rate limits (section 3).
Then decide the table set and per-table behavior:
- Table names, primary key(s), incremental key, write strategy (see below).
- Don't flatten nested objects. Pass each provider object through as-is so it lands as a JSON
column; only lift the primary-key field(s) to top-level columns.
- Every URI param you expose must be wired end to end: parse → store on the struct → use in a
real request. A parsed-but-unused param is a bug.
- Validate constrained params (e.g.
environmentmust beproduction/sandbox) with a clear
error.
Read 2-3 existing sources as reference — e.g. attio for schema inference, plus one that paginates and one that does server-side date filtering. Reuse their patterns and helpers instead of inventing new ones.
Choose each table's write strategy
API sources return HandlesIncrementality() == true, so the table's Strategy() is what runs. The user's --incremental-strategy is silently ignored unless GetTable reads req.Strategy, so pick the right one here — users can't fix it later.
- `replace` when a full fetch stays cheap (users, labels, settings) or the API can't return
only changed rows. Fetch everything and set TableIgnoresInterval: replace drops rows outside the interval.
- The incremental key must be when the row last changed (
updated_at), not when it was
created (created_at, committed_at). A creation time loses rows that show up after their window already ran. Rows that never change after creation (trades, bounces, events) can use the creation time. If there's no change time, use replace.
- `merge` on a stable PK for entities fetched by `updated_at` (users, tickets, orders). It
never deletes rows, so request deleted/archived items and keep is_deleted / deleted_at.
- `delete+insert` when a slice, usually a day, is replaced as a whole. Use it for reports
(one row per day + dimensions, e.g. adjust, applovin): vendors recompute whole days, rows drop out, and a renamed campaign changes the PK, so merge would keep stale rows. Also use it when there's no stable PK, or for large date-partitioned tables where deleting a partition is cheaper than a MERGE. Never key it on updated_at for entities: the old version of a row sits outside the window, never gets deleted, and duplicates.
- `delete+insert` deletes `[start, end]` with both ends inclusive, then inserts what you
fetched, so the fetch must return exactly that window. Rows outside it are inserted but never deleted. An end-exclusive filter (like deel's filterItemsByInterval) deletes the end day without re-inserting it. And an API failure that comes back as an empty result while an interval is set wipes the whole window, so return an error instead.
- `append` for immutable, high-volume events and logs read with a cursor that never returns a
row twice: no lookback, no overlapping windows (slack access_logs, zendesk ticket_metric_events, posthog events, influxdb). It's cheaper than merge since there's no MERGE over a growing table, but any re-run or overlap duplicates rows. If rows have a stable id and the volume is moderate, use merge.
- `scd2` only when the API returns just the current state and history matters (Shopify
balance). It's destination-specific, and it only closes deleted keys on a full fetch.
- Child tables (line items, PR commits):
mergeon(parent_id, child_id). Fetching
children only for changed parents works only if a child change bumps the parent's updated_at.
- Lookbacks only shrink the gap, so add one only when the vendor documents the maximum delay
(an attribution window, a re-run limit).
--full-refresh always runs replace with whatever the source returns for the interval given (or its default window if none is given). On APIs that only keep recent data, that wipes older history: adapty fetches the last 30 days by default, so a full refresh leaves only those. Don't suggest periodic full refreshes for those sources.
2. Ask the user for test-account credentials
Testing needs a real account with data. Ask the user for the credentials (API key/token, client ID/secret, account ID, etc.) for an account that has at least one record in every table you plan to support. They're only needed locally while building and testing. Never commit credentials or tokens.
3. Look up API rate limits
Find the vendor's rate-limit docs. Note the limit type (per-minute, per-second, concurrent) and the actual numbers. If different endpoints have different limits, give each group its own HTTP client and limiter — don't apply the lowest limit to everything.
Compute rateLimit / rateLimitBurst at ~80% of the documented limit:
- Per-minute:
rateLimit = (limit * 0.8) / 60.0 - Per-second:
rateLimit = limit * 0.8 rateLimitBurstis usually 5. For low per-minute caps, size it soburst + rateLimit*60
stays under the cap — e.g. a 10 req/min tier needs burst ≤ 2 (burst 5 + ~7.8 refilled ≈ 12.8 in the first minute, over the cap).
Comment the rateLimit constant with the vendor's actual limit. If the connector only targets a free tier, don't document the full plan-quota table — it implies behavior the limiter doesn't act on.
4. Create the source package
Create pkg/source/<source>/ with register.go and <source>.go.
register.go self-registers the source in an init(). Without it the source is unreachable from a URI even after make generate. Match the existing sources:
In <source>.go, using existing sources as reference, implement: constants, supportedTables, the source struct, New*Source(), HandlesIncrementality, Schemes, Connect, Close, parseURI, GetTable, isValidTable, the read dispatcher, and paginateAndSend.
OAuth token refresh
If the vendor uses OAuth, accept both a ready access_token and the refresh credentials (client_id / client_secret / refresh_token) in the URI. When no access token is given, mint one in Connect from the refresh credentials via a refreshAccessToken helper, then set it with httpclient.WithAuth(...). Access tokens usually expire in hours; the refresh token is long-lived. See redditads and quickbooks.
Schema design — prefer inference over hand-written types
- Set
KnownSchema: falseand let the pipeline infer types. Build records with
arrowconv.ItemsToArrowRecordWithSchema(items, nil, opts.ExcludeColumns) — nil columns means every field is emitted as Unknown and inferred. Don't hand-maintain column type blocks; SchemaFn can just return an error.
- Don't flatten nested objects (inference maps
map/[]to JSON). Only lift the primary-key
field(s) to top-level columns so merge can dedupe (e.g. id from team.id).
- Stream one batch per response/page/fan-out unit via the
resultschannel. Never buffer the
whole result set into one slice before emitting.
- Bound each batch by bytes (see below) whenever you accumulate rows before emitting.
- Comment only where the code isn't self-explanatory — a non-obvious API quirk, or the "why"
behind a choice. Keep comments to at most 2 lines.
Bounding a batch by bytes
Any loop that accumulates rows into a slice before emitting must honor opts.MaxBatchBytes (the cap derived from --batch-size). Before appending a row that would push the batch over the cap, flush what you have and reset the byte counter with the batch. Use arrowconv.RowBytes(item) for the estimate — never hand-roll a size calc.
Guard every check with opts.MaxBatchBytes > 0. Zero means "no cap" and only exists as the struct default — the CLI rejects a non-positive --batch-size and defaults to 512 MiB, so in practice it's always positive. Keep accBytes a function-local var and reset it with the batch on every flush path (in-loop, trailing-after-loop, error) — a missed reset leaks the count into the next batch. A source that emits exactly one row per response and never grows a slice can skip the cap.
Query params on the table string
When a source_table carries URL-style query params (e.g. boards?board_ids=1,2&linked=true), don't hand-split it. Use the shared pkg/tablespec parser:
Parse returns the base path, decodes params onto your struct via mapstructure tags, coerces types (repeated/separator-joined → []string, bare flag → bool, dotted keys → nested), and rejects unknown keys so a typo errors instead of being silently dropped. When hasParams is false, fall back to your legacy table-string parsing. See monday, adjust, sharepoint.
Per-table read functions
For each table in supportedTables, implement a read<TableName>:
opts source.ReadOptions carries what each read needs: the incremental window IntervalStart / IntervalEnd (both *time.Time; nil means unbounded on that side) and IncrementalKey, plus MaxBatchBytes and ExcludeColumns. That's how "the interval" below reaches a table — pass it as a query param, or filter on it client-side.
Then run:
Finally, add the scheme to the hand-maintained catalog in internal/server/connectors.go (GetConnectors()) — e.g. genericURIConnector("trello", "Trello", []string{"trello"}, true, false). register.go only wires URI resolution; TestConnectorCatalogCoversRegisteredSchemes fails without the catalog entry.
5. Post-implementation review checklist
First re-check the whole implementation against the vendor docs — table names, endpoints, primary keys, incremental keys, strategies, special handling (filters, sub-types, field normalization). Fix discrepancies before continuing.
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewNot runA model review is scheduled for the next rescan.
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/add-source/SKILL.md
Popularity
- 7-day trend score
- 0
Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/bruin-data/ingestr/add-source)