/dogsled-core:add-warehouse-sourcefrom dogsled-core
Guides adding a new warehouse or database extractor source to @bobsled-inc/extractor, covering schema definitions, client implementation, SQL dialect support, type mappings, factory wiring, and tests.
Ships in dogsled-core. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Use this skill to add or extend a warehouse/database extractor source.
Load the full reference only when the task needs its schemas, command tables, examples, or troubleshooting detail:
Adds a new warehouse or database source type to packages/extractor/. This covers the full vertical: Zod schemas, WarehouseClient implementation, query builder dialect, type mapper, factory wiring, and tests.
/add-warehouse-source <source-name>
Example: /add-warehouse-source oracle, /add-warehouse-source clickhouse
Before starting, read these files to understand existing patterns:
| File | Purpose |
|---|---|
packages/extractor/src/runtime/warehouse-client.ts | WarehouseClient interface + createWarehouseClient() factory |
packages/extractor/src/runtime/pg-base-client.ts | Shared base for PG-compatible clients (connection pooling, batching) |
packages/extractor/src/runtime/postgres-client.ts | Reference implementation (thin subclass of PgBase) |
packages/extractor/src/runtime/snowflake-client.ts | REST API-based client (alternative pattern, no native driver) |
packages/extractor/src/runtime/mysql-client.ts | Standalone client with its own driver (mysql2) |
packages/extractor/src/framework/core/warehouse.ts | Zod schemas: connection, auth, SSL, replication |
packages/extractor/src/framework/extractor/resource.ts | Integration + resource spec discriminated unions |
packages/extractor/src/runtime/warehouse-query-builder.ts | Dialect-aware SQL generation (quoting, placeholders, FQN) |
packages/extractor/src/runtime/warehouse-type-mapper.ts | Source column types to protocol ColumnType mapping |
packages/extractor/AGENTS.md | Existing 7-step checklist to expand on |
grep -r '<source-name>' packages/extractor/src/framework/core/warehouse.ts
ls packages/extractor/src/runtime/<source-name>-client.ts 2>/dev/null
Check SourceTypeValues in packages/extractor/src/framework/core/warehouse.ts:
export const SourceTypeValues = [
'api',
'snowflake',
'bigquery',
'postgres',
'redshift',
'mysql',
'clickhouse',
'iceberg',
'delta',
] as const;
If the source already exists, ask the user whether to update or abort.
Choose the right pattern based on the source's driver model:
| Pattern | When to use | Reference |
|---|---|---|
| PG-compatible base | Source uses the pg driver (e.g., CockroachDB, AlloyDB, TimescaleDB) | pg-base-client.ts + postgres-client.ts |
| Standalone native driver | Source has its own npm driver (e.g., oracledb, @clickhouse/client) | mysql-client.ts |
| REST API | Source exposes a SQL-over-HTTP API (e.g., Databricks SQL, Trino) | snowflake-client.ts |
Read the chosen reference implementation end-to-end. Pay attention to:
execute() async generator yielding ~10K row batchesintrospect() using INFORMATION_SCHEMA or system catalogtestConnection() via SELECT 1close() draining pools or no-op for RESTFile: packages/extractor/src/framework/core/warehouse.ts
export const SourceTypeValues = [
'api',
'snowflake',
'bigquery',
'postgres',
'redshift',
'mysql',
'iceberg',
'delta',
'<source-name>', // <-- add here
] as const;
Follow these conventions:
.strict() on every object schema (catches YAML typos)*_env fields (env var name, not the secret itself).describe() on every fieldExample for a hypothetical Oracle source:
export const OracleConnectionSchema = z
.object({
host_env: z.string().describe('Env var holding the Oracle host'),
port: z.number().int().positive().describe('Oracle listener port'),
service_name: z.string().describe('Oracle service name or SID'),
schema: z.string().optional().describe('Default schema for unqualified table names'),
})
.strict();
Most SQL databases can reuse the existing DatabaseAuthSchema (password + IAM variants). Only define a new auth schema if the source has unique auth mechanisms (like Snowflake's PAT/OAuth or BigQuery's ADC/WIF).
// Reuse for standard username/password databases:
// DatabaseAuthSchema = discriminatedUnion('type', [DatabasePasswordAuthSchema, DatabaseIamAuthSchema])
If the source needs unique auth:
export const OracleWalletAuthSchema = z
.object({
type: z.literal('wallet'),
wallet_path_env: z.string().describe('Env var holding the Oracle wallet directory path'),
})
.strict();
export const OracleAuthSchema = z.discriminatedUnion('type', [
DatabasePasswordAuthSchema,
OracleWalletAuthSchema,
]);
If the source has unique SSL modes, create a dedicated schema. Otherwise reuse PostgresSslConfigSchema patterns:
export const OracleSslConfigSchema = z
.object({
mode: z.enum(['disable', 'require', 'verify-ca', 'verify-dn']).describe('Oracle SSL mode'),
ca_cert_env: z.string().optional().describe('Env var holding PEM-encoded CA certificate'),
})
.strict();
At the bottom of the file, add the inferred TypeScript types:
export type OracleConnection = z.infer<typeof OracleConnectionSchema>;
// export type OracleAuth = z.infer<typeof OracleAuthSchema>; // if custom auth
// export type OracleSslConfig = z.infer<typeof OracleSslConfigSchema>; // if custom SSL
File: packages/extractor/src/framework/extractor/resource.ts
Add the new connection schema (and auth/SSL if custom) to the imports from ../core/index.js.
const OracleIntegrationSpecSchema = z
.object({
...IntegrationSpecBase,
source_type: z.literal('oracle'),
connection: OracleConnectionSchema,
auth: DatabaseAuthSchema, // or OracleAuthSchema if custom
ssl: OracleSslConfigSchema.optional(), // if applicable
})
.strict();
export const IntegrationSpecSchema = z.union([
SnowflakeIntegrationSpecSchema,
BigQueryIntegrationSpecSchema,
PostgresIntegrationSpecSchema,
RedshiftIntegrationSpecSchema,
MysqlIntegrationSpecSchema,
OracleIntegrationSpecSchema, // <-- add before ApiIntegrationSpecSchema
IcebergIntegrationSpecSchema,
DeltaIntegrationSpecSchema,
ApiIntegrationSpecSchema, // API variant MUST be last (fallback)
]);
export type OracleIntegrationSpec = z.infer<typeof OracleIntegrationSpecSchema>;
File: packages/extractor/src/runtime/<source-name>-client.ts
The client must implement the WarehouseClient interface:
export interface WarehouseClient {
readonly dialect: Dialect;
execute(
sql: string,
params?: unknown[],
opts?: ExecuteOptions
): AsyncGenerator<Record<string, unknown>[]>;
testConnection(): Promise<{ success: boolean; error?: string }>;
introspect(database: string, schema: string): Promise<TableDiscovery[]>;
close(): Promise<void>;
}
Constructor:
rawConfig: Record<string, unknown> and validates into a typed configparse<Source>Config() function that validates required/optional fieldsrequireString(), requireNumber(), optionalString() helpers (copy from pg-base or mysql client)getPool() or getClient() methodDynamic import for the driver:
await import('<driver-package>') inside a method, never at module top levelconst Driver = pkg.default?.Pool ?? pkg.Pool;private async getPool(): Promise<PoolLike> {
if (this.pool) return this.pool;
const driver = await import('<driver-package>');
const Pool = driver.default?.Pool ?? driver.Pool;
this.pool = new Pool({ /* config */ });
return this.pool;
}
execute() -- AsyncGenerator yielding batches:
Record<string, unknown>[] with ~10,000 rows per batchBATCH_SIZE = 10_000 constantopts.maxRows limit across batchesfinally blockasync *execute(
sql: string,
params?: unknown[],
opts?: ExecuteOptions
): AsyncGenerator<Record<string, unknown>[]> {
const pool = await this.getPool();
const conn = await pool.getConnection();
try {
const result = await conn.query(sql, params ?? []);
const rows = result.rows;
const maxRows = opts?.maxRows;
const total = maxRows !== undefined ? Math.min(rows.length, maxRows) : rows.length;
let offset = 0;
while (offset < total) {
const end = Math.min(offset + BATCH_SIZE, total);
const batch = rows.slice(offset, end);
if (batch.length > 0) yield batch;
offset = end;
}
} finally {
conn.release();
}
}
testConnection():
SELECT 1 AS connected and consume the generator{ success: true } or { success: false, error: message }introspect(database, schema):
TableDiscovery[] with ColumnDiscovery per columnname, sourceType (raw DB type string), nullable, isPrimaryKey, commentclose():
await this.pool.end()Define minimal interfaces for the driver to avoid importing driver types at the module level:
interface PoolLike {
getConnection(): Promise<ConnectionLike>;
end(): Promise<void>;
}
interface ConnectionLike {
query(sql: string, params?: unknown[]): Promise<QueryResultLike>;
release(): void;
}
interface QueryResultLike {
rows: Record<string, unknown>[];
}
File: packages/extractor/src/runtime/warehouse-client.ts
Add a case to createWarehouseClient():
case '<source-name>': {
const { <SourceName>WarehouseClient } = await import('./<source-name>-client.js');
return new <SourceName>WarehouseClient(config);
}
Place it alphabetically or logically among the existing cases. The dynamic import() ensures the driver is only loaded when this source type is actually used.
File: packages/extractor/src/runtime/warehouse-query-builder.ts
export type Dialect =
| 'snowflake'
| 'bigquery'
| 'postgres'
| 'redshift'
| 'mysql'
| 'iceberg'
| 'delta'
| '<source-name>';
In quoteIdentifier(), add the source to the appropriate case:
export function quoteIdentifier(dialect: Dialect, name: string): string {
switch (dialect) {
case 'snowflake':
case 'postgres':
case 'redshift':
case 'iceberg':
case 'delta':
case '<source-name>': // if uses double-quote
return `"${name.replace(/"/g, '""')}"`;
case 'bigquery':
case 'mysql':
return `\`${name.replace(/`/g, '``')}\``;
}
}
Quoting rules by database:
"name": PostgreSQL, Snowflake, Redshift, Oracle, DuckDB`name`: MySQL, BigQuery, ClickHouse[name]: SQL Server (also supports double-quote)In buildParamPlaceholder():
function buildParamPlaceholder(dialect: Dialect, index: number): string {
switch (dialect) {
case 'snowflake':
return `:${index}`;
case 'bigquery':
return `@p${index}`;
case 'postgres':
case 'redshift':
case 'iceberg':
case 'delta':
return `$${index}`;
case 'mysql':
return '?';
case '<source-name>':
return ':<source-placeholder>'; // dialect-specific
}
}
Placeholder styles:
$1, $2, ... -- PostgreSQL, Redshift, DuckDB:1, :2, ... -- Snowflake, Oracle@p1, @p2, ... -- BigQuery? (positional) -- MySQL, ClickHouse:name (named) -- some drivers support thisIn buildFullyQualifiedTable(), add a case:
case '<source-name>': {
const parts: string[] = [];
// Adapt based on the source's namespace hierarchy:
// e.g., Oracle: schema.table, ClickHouse: database.table
if (config.schema) parts.push(quoteIdentifier(dialect, config.schema));
parts.push(quoteIdentifier(dialect, config.table));
return parts.join('.');
}
Table qualification patterns:
"database"."schema"."table" -- Snowflake`project.dataset.table` -- BigQuery"schema"."table" -- PostgreSQL, Redshift, Oracle`database`.`table` -- MySQL, ClickHouseIf the source supports CDC/change tracking, add a builder function and wire it into buildChangeTrackingQuery(). Most traditional databases do NOT support change tracking -- they should throw:
case '<source-name>':
throw new Error(
`change_tracking is not supported for ${config.dialect}. Use incremental_append or incremental_merge instead.`
);
File: packages/extractor/src/runtime/warehouse-type-mapper.ts
function map<SourceName>Type(normalized: string, baseType: string): ColumnType {
switch (baseType) {
// Integer types
case 'INT':
case 'INTEGER':
case 'BIGINT':
case 'SMALLINT':
return 'integer';
// Number types
case 'FLOAT':
case 'DOUBLE':
case 'DECIMAL':
case 'NUMERIC':
case 'NUMBER':
return 'number';
// String types
case 'VARCHAR':
case 'CHAR':
case 'TEXT':
case 'CLOB':
return 'string';
// Boolean
case 'BOOLEAN':
case 'BOOL':
return 'boolean';
// Timestamps
case 'TIMESTAMP':
case 'DATETIME':
return 'timestamp';
// Date (mapped to string, not timestamp)
case 'DATE':
return 'string';
// JSON/structured
case 'JSON':
case 'JSONB':
return 'object';
// Arrays
case 'ARRAY':
return 'array';
// Default fallback
default:
return 'string';
}
}
Protocol ColumnType values: 'string' | 'integer' | 'number' | 'boolean' | 'timestamp' | 'array' | 'object'
Mapping rules:
'string' (not timestamp) -- consistent across all dialects'string''integer' (check for Snowflake/Redshift pattern)'string'baseType has precision/scale parentheses stripped; normalized retains them for scale checksexport function mapColumnType(dialect: Dialect, sourceType: string): ColumnType {
const normalized = sourceType.toUpperCase().trim();
const baseType = normalized.split('(')[0]?.trim() ?? normalized;
switch (dialect) {
// ... existing cases ...
case '<source-name>':
return mapSourceNameType(normalized, baseType);
}
}
File: packages/extractor/tests/fixtures/integrations/<source-name>.yml
spec_version: '1'
type: integration
name: test_<source_name>
auth_env_vars: [<SOURCE>_HOST, <SOURCE>_USER, <SOURCE>_PASSWORD]
source_type: <source-name>
connection:
host_env: <SOURCE>_HOST
port: <default-port>
database: test_db
schema: public # if applicable
auth:
type: password
username_env: <SOURCE>_USER
password_env: <SOURCE>_PASSWORD
File: packages/extractor/tests/unit/warehouse-schemas.test.ts
Add a test case to the existing IntegrationSpecSchema -- warehouse integrations describe block:
it('validates <source-name> integration spec', () => {
const spec = loadYaml('integrations/<source-name>.yml');
const result = IntegrationSpecSchema.safeParse(spec);
expect(result.success).toBe(true);
});
Also add rejection tests for invalid configs (missing required fields, wrong types).
File: packages/extractor/tests/unit/warehouse-type-mapper.test.ts
Add a new describe block:
describe('mapColumnType -- <source-name>', () => {
const map = (t: string) => mapColumnType('<source-name>', t);
describe('integer types', () => {
it.each(['INT', 'INTEGER', 'BIGINT', 'SMALLINT'])('maps %s to integer', (t) => {
expect(map(t)).toBe('integer');
});
});
describe('number types', () => {
it.each(['FLOAT', 'DOUBLE', 'DECIMAL', 'NUMERIC'])('maps %s to number', (t) => {
expect(map(t)).toBe('number');
});
});
describe('string types', () => {
it.each(['VARCHAR', 'CHAR', 'TEXT'])('maps %s to string', (t) => {
expect(map(t)).toBe('string');
});
});
describe('boolean types', () => {
it('maps BOOLEAN to boolean', () => {
expect(map('BOOLEAN')).toBe('boolean');
});
});
describe('timestamp types', () => {
it.each(['TIMESTAMP', 'DATETIME'])('maps %s to timestamp', (t) => {
expect(map(t)).toBe('timestamp');
});
});
describe('date/time types', () => {
it('maps DATE to string', () => {
expect(map('DATE')).toBe('string');
});
});
describe('fallback', () => {
it('maps unknown types to string', () => {
expect(map('CUSTOMTYPE')).toBe('string');
});
});
});
File: packages/extractor/tests/unit/warehouse-query-builder.test.ts
Add tests for the new dialect's identifier quoting, placeholder style, and FQN generation:
describe('<source-name> dialect', () => {
it('quotes identifiers correctly', () => {
expect(quoteIdentifier('<source-name>', 'my_table')).toBe('"my_table"'); // or backtick
});
it('builds full refresh query', () => {
const result = buildExtractionQuery({
dialect: '<source-name>',
table: 'users',
schema: 'public',
method: 'full_refresh',
});
expect(result.sql).toContain('SELECT * FROM');
expect(result.params).toEqual([]);
});
it('builds incremental query with cursor', () => {
const result = buildExtractionQuery({
dialect: '<source-name>',
table: 'events',
schema: 'public',
method: 'incremental_append',
cursorField: 'updated_at',
cursorValue: '2024-01-01T00:00:00Z',
});
expect(result.sql).toContain('WHERE');
expect(result.params).toHaveLength(1);
});
});
pnpm --filter @bobsled-inc/extractor test
All existing tests must continue to pass. New tests must pass.
Run these before considering the work complete:
# Type-check (catches missing Dialect union members, schema type mismatches)
pnpm --filter @bobsled-inc/extractor run typecheck
# Lint
pnpm --filter @bobsled-inc/extractor run lint
# All extractor tests (includes schema, query builder, type mapper tests)
pnpm --filter @bobsled-inc/extractor test
# Full repo check
pnpm check && pnpm test:unit
TypeScript will flag non-exhaustive switches when you add a new Dialect value. Check that ALL switch statements in these files handle the new dialect:
warehouse-query-builder.ts: quoteIdentifier(), buildParamPlaceholder(), buildFullyQualifiedTable(), buildChangeTrackingQuery()warehouse-type-mapper.ts: mapColumnType()warehouse-client.ts: createWarehouseClient()Never import database drivers at the module top level. Use dynamic import() inside a lazy getter. This prevents crashes when the driver is not installed:
// WRONG - crashes if oracledb not installed
import oracledb from 'oracledb';
// CORRECT - only loaded when Oracle source is used
private async getPool() {
const oracledb = await import('oracledb');
// ...
}
All connection-based clients (not REST) must use a connection pool:
DEFAULT_MAX_CONNECTIONS = 5)close() drains the pool and sets the reference to nullexecute() yields arrays of rows, not individual rows. Target ~10,000 rows per batch for optimal throughput. If the driver supports streaming, stream into a batch buffer and yield when full. If not, fetch all rows and slice into chunks.
Secrets are NEVER stored in YAML. All secret fields use *_env suffix and contain an environment variable name. The runtime reads process.env[config.host_env] at connection time. This pattern is enforced by the Zod schemas.
Test fixtures live in packages/extractor/tests/fixtures/integrations/. Each source has a YAML file that the schema validation tests parse. These fixtures must pass IntegrationSpecSchema.safeParse().
If the new source uses the PostgreSQL wire protocol (CockroachDB, AlloyDB, TimescaleDB, Yugabyte), extend PgCompatibleWarehouseClient from pg-base-client.ts. You only need to:
readonly dialect: Dialect = '<source-name>'introspect() with source-specific catalog queriesexport class CockroachWarehouseClient extends PgCompatibleWarehouseClient {
readonly dialect: Dialect = 'cockroach';
constructor(rawConfig: Record<string, unknown>) {
super(rawConfig, 'CockroachConfig');
}
async introspect(database: string, schema: string): Promise<TableDiscovery[]> {
// CockroachDB uses pg_catalog, same as PostgreSQL
// ...
}
}
Most databases expose metadata via INFORMATION_SCHEMA. Key tables:
INFORMATION_SCHEMA.COLUMNS -- column names, types, nullabilityINFORMATION_SCHEMA.TABLE_CONSTRAINTS + KEY_COLUMN_USAGE -- primary key detectionPostgreSQL/Redshift use pg_catalog for better visibility with restricted users. Oracle uses ALL_TAB_COLUMNS and ALL_CONSTRAINTS. ClickHouse uses system.columns.
Always use parameterized queries for schema/database filter values to prevent SQL injection.
SourceTypeValues includes the new source name.strict() and *_env for secretsDatabaseAuthSchema reusedIntegrationSpecSchema union (before API fallback)WarehouseClient interfaceimport()execute() yields ~10K row batches via AsyncGeneratortestConnection() runs SELECT 1 with try/catchintrospect() queries system catalog with PK detectionclose() drains poolcreateWarehouseClient()Dialect type unionquoteIdentifier() handles the new dialectbuildParamPlaceholder() handles the new dialectbuildFullyQualifiedTable() handles the new dialectbuildChangeTrackingQuery() handles the new dialect (throw if unsupported)mapColumnType() switch handles the new dialectpnpm check && pnpm test:unit passesWhat SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub bobsled-inc/dogsled-core --plugin dogsled-coreOther plugins' skills for the same job
65 skills in this plugin
/add-custom-api-integrationAuthor a generic custom_api source for any REST/GraphQL API purely in YAML — inline transport (base_url + auth), one declarative resource per endpoint, then validate/verify/extract. Use when the API isn't in the bundled catalog./add-custom-mcp-integrationAuthor a custom_mcp source for any remote MCP server (Model Context Protocol over streamable HTTP) purely in YAML — inline mcp_http transport (url + auth + auth_env_vars), one resource_kind mcp resource per tool, then validate/verify/extract. Use when the MCP server isn't in the bundled catalog./add-database-destination