/dogsled-core:add-file-destinationfrom dogsled-core
Guides adding a new file-based load destination (Azure Blob Storage, R2, MinIO) to the @bobsled-inc/loader package, covering class implementation, config schema, factory wiring, CLI options, check command, 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.
None: SKILL.md is the whole skill.
Adds a new file-based destination to packages/loader/. File destinations implement the FileDestination interface and publish converted files (parquet, csv, jsonl) to a remote or local store. The canonical reference implementation is S3Destination (~85 lines).
/add-file-destination <destination-name>
Example: /add-file-destination azure-blob
ls packages/loader/src/runtime/destinations/
Look for a file matching the destination name. If it already exists, ask the user whether to update or abort.
Also check the factory to see if the destination kind is already in the DestinationKind union:
packages/loader/src/runtime/destinations/index.tsRead these files to internalize the patterns before writing any code:
packages/loader/src/runtime/destinations/s3.ts — canonical file destination (~85 lines)packages/loader/src/runtime/destinations/types.ts — FileDestination interface, PublishOptions, assertObjectKeyLength() and normalizeDestinationPath()packages/loader/src/runtime/destinations/index.ts — DestinationKind union, DestinationConfig, createDestination() factorypackages/loader/src/schemas/config.ts — Zod discriminated union config schemaspackages/loader/src/commands/check.ts — connectivity check functions and CheckDependencies DIpackages/loader/src/commands/run.ts — CLI option registration (search for --s3-bucket to see the pattern)packages/loader/tests/unit/destinations/s3.test.ts — test structure and mock patternsKey patterns to note:
| Pattern | Why |
|---|---|
DI interface (e.g., S3ClientLike) | Allows unit tests to inject a mock client instead of the real SDK |
Dynamic import() for SDK | The cloud SDK is an optional peer dep — must not be a static import |
Lazy client caching (getClient()) | Creates the real SDK client on first use, caches it, but prefers injected client |
normalizeDestinationPath() | Path traversal protection — call on both prefix (constructor) and destPath (publish) |
publish() returns a URI string | e.g., s3://bucket/key or gs://bucket/key — used for logging and state tracking |
| Constructor validation | Validate bucket/container naming rules at construction time, fail fast |
Create a new file at:
packages/loader/src/runtime/destinations/<name>.ts
The file must contain:
A client-like DI interface — minimal interface matching the SDK methods you call. Example from S3:
export interface S3ClientLike {
send(command: unknown): Promise<unknown>;
}
An options interface — includes the bucket/container name, optional prefix, optional region/account, and optional injected client:
export interface <Name>DestinationOptions {
bucket: string; // or container, etc.
prefix?: string;
region?: string; // or account, endpoint, etc.
<name>Client?: <Name>ClientLike;
}
A validation function for bucket/container naming rules — fail fast with a clear error message. Research the cloud provider's naming rules (length, allowed characters, start/end constraints).
The destination class implementing FileDestination:
normalizeDestinationPath and FileDestination from ./types.jsbucketName, prefix (normalized, trailing slashes stripped), region, providedClient, and cachedClient as private fieldsnormalizeDestinationPath(options.prefix).replace(/\/+$/, '')publish(localPath, destPath, options?):
normalizeDestinationPath(destPath)path.posix.join(prefix, normalizedPath) (or just normalizedPath if no prefix)assertObjectKeyLength(key) on the final key, as S3 and GCS doawait import('...'))await readFile(localPath))options?.copy is not truehttps://<account>.blob.core.windows.net/<container>/<key>)getClient():
this.providedClient if set (DI path)this.cachedClient if already createdimport() of the SDK package"Failed to load <package>. Install it to use --dest <name>."options is PublishOptions from ./types.js: { copy?: boolean; metadata?: Record<string, string> }. The loader passes { copy: true } for a FILE message, which writes a file as it is (a file Resource with source.kind: copy). A copy sets no content type, because the file is not in the loader's output format. A destination that should take copies must skip the content type when copy is true and check every final key with assertObjectKeyLength(), as S3Destination and GcsDestination do. A destination that can keep object metadata writes metadata for a copy too, through encodeObjectMetadata(), which percent-encodes each value and refuses more than 2,048 bytes. The loader decides what to send: copyMetadata in run-file-loader.ts adds the two dogsled- keys only when the destination sets object_metadata, and only if they fit.
Only local, s3 and gcs take copies today. FILE_DESTINATION_TYPES in packages/dogsled/src/runner/config/validate-copy-destinations.ts lists them, and dogsled.yml validation refuses a copy Resource whose destination has any other type. Add a new type there before a dogsled.yml pipeline copies files to it.
File: packages/loader/src/schemas/config.ts
Add a new schema object following the S3 pattern:
const <Name>DestConfigSchema = z.object({
dest: z.literal('<name>'),
format: z.enum(OUTPUT_FORMATS),
outputDir: z.string().trim().min(1).default('./output'),
<name>Bucket: z.string().trim().min(1), // or <name>Container, etc.
<name>Prefix: z.string().trim().min(1).optional(),
<name>Region: z.string().trim().min(1).optional(), // if applicable
bufferSize,
logFormat,
});
Then:
LoaderConfigSchema discriminated union arrayexport type <Name>DestConfig = z.infer<typeof <Name>DestConfigSchema>;FileDestConfig union: export type FileDestConfig = LocalDestConfig | GcsDestConfig | S3DestConfig | <Name>DestConfig;File: packages/loader/src/runtime/destinations/index.ts
Import the new destination class:
import { <Name>Destination } from './<name>.js';
Add the new kind to the DestinationKind union:
export type DestinationKind = 'local' | 'gcs' | 's3' | '<name>';
Add the destination-specific fields to DestinationConfig:
<name>Bucket?: string;
<name>Prefix?: string;
<name>Region?: string; // if applicable
Add a new case in createDestination() switch — before the default exhaustive check:
case '<name>':
if (!config.<name>Bucket) {
throw new Error('--<name>-bucket is required when --dest <name>');
}
return new <Name>Destination({
bucket: config.<name>Bucket,
prefix: config.<name>Prefix,
region: config.<name>Region,
});
Add a re-export at the bottom:
export { <Name>Destination } from './<name>.js';
File: packages/loader/src/commands/check.ts
Add an async check<Name>() function following the checkS3 or checkGcs pattern:
CheckDependenciesstderr using chalk.green/chalk.redsetExitCode(1) on failureAdd CLI options to the check command registration (inside registerCheckCommand):
.option('--<name>-bucket <bucket>', '<Name> bucket/container name')
.option('--<name>-region <region>', '<Name> region') // if applicable
Add a new case '<name>': in the switch (dest) block inside the .action() handler:
check<Name>()Update the default error message to include the new destination in the list:
chalk.red('✗ --dest must be one of: duckdb, bigquery, gcs, local, s3, <name>');
Export the new check function at the bottom if it might be useful externally:
export { checkDuckDb, checkLocal, checkS3, check<Name> };
File: packages/loader/src/commands/run.ts
Search for the existing --s3-bucket option registrations and add analogous options nearby:
.option('--<name>-bucket <bucket>', '<Name> bucket/container name')
.option('--<name>-prefix <prefix>', '<Name> object prefix')
.option('--<name>-region <region>', '<Name> region') // if applicable
These options get passed through to the config object that feeds into LoaderConfigSchema.parse(), so they will flow through the Zod schema and into the factory automatically. Verify that the option names (camelCased by Commander) match the Zod schema field names exactly.
Create a new test file at:
packages/loader/tests/unit/destinations/<name>.test.ts
Follow the s3.test.ts test structure exactly. Required test cases:
publish(), assert the returned URI and the arguments passed to the mocknew Destination({ bucket: 'b', prefix: '../escape' }) must throw "Invalid destination path"publish('/tmp/f', '../escape.parquet') must reject with "Invalid destination path"publish(), assert the error message mentions the SDK package nameMock client pattern (from S3 tests):
const mockClient = {
async send(command: { input: Record<string, unknown> }): Promise<Record<string, never>> {
uploads.push({
bucket: command.input.Bucket as string,
key: command.input.Key as string,
});
return {};
},
};
Adapt the mock to match the SDK interface of the new cloud provider.
Run the tests:
pnpm --filter @bobsled-inc/loader test
All tests must pass.
Before considering the destination complete, verify all of the following:
| Gate | Command / Check |
|---|---|
| TypeScript compiles | pnpm --filter @bobsled-inc/loader typecheck |
| Lint passes | pnpm --filter @bobsled-inc/loader lint |
| All unit tests pass | pnpm --filter @bobsled-inc/loader test |
| Full repo builds | pnpm build |
| Full repo type-check | pnpm typecheck |
| Exhaustive switch still works | The default: { const exhaustiveCheck: never = config.dest; } in createDestination() must compile — ensures every DestinationKind is handled |
| Zod discriminated union valid | LoaderConfigSchema must parse a config with dest: '<name>' and reject configs missing required fields |
FileDestConfig union updated | The new config type is included in the FileDestConfig type alias |
| No static imports of optional SDK | The cloud SDK package must only appear inside await import('...') calls — never at the top of the file |
normalizeDestinationPath() called | Called on both the prefix (constructor) and destPath (publish) — prevents path traversal |
| Constructor validates naming rules | Invalid bucket/container names throw synchronously at construction time |
publish() returns a URI string | The URI uses the provider's canonical scheme (e.g., s3://, gs://, https://...blob.core.windows.net/) |
| Copies written as they are | With { copy: true }, publish() sets no content type, and every key goes through assertObjectKeyLength(). A test covers both |
| DI interface enables testing | A *ClientLike interface is exported and accepted in the options, so tests never need real SDK |
| Check command wired | dogsled load check --dest <name> --<name>-bucket <b> runs the connectivity check |
| Run command options wired | dogsled load run --dest <name> --<name>-bucket <b> parses correctly |
| File | Change |
|---|---|
packages/loader/src/runtime/destinations/<name>.ts | New — destination class |
packages/loader/src/runtime/destinations/index.ts | Add import, DestinationKind, DestinationConfig fields, factory case, re-export |
packages/loader/src/runtime/destinations/types.ts | No changes needed (shared interface) |
packages/loader/src/schemas/config.ts | Add Zod schema, add to discriminated union, export type, update FileDestConfig |
packages/loader/src/commands/check.ts | Add check function, CLI options, switch case, error message update, export |
packages/loader/src/commands/run.ts | Add CLI options for bucket/prefix/region |
packages/loader/tests/unit/destinations/<name>.test.ts | New — unit tests |
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
Other plugins' skills for the same job
npx claudepluginhub bobsled-inc/dogsled-core --plugin dogsled-core65 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-destinationAdd a new database load destination (e.g., Snowflake, PostgreSQL, ClickHouse) to the @bobsled-inc/loader package. Implements the DatabaseDestination interface with full append/merge/full_refresh support./add-file-storage-sourceOnboard documents (PDF, DOCX, PPTX, HTML, Markdown, text, email) from an Amazon S3 or Google Cloud Storage bucket — author a file-storage integration (source_type s3|gcs, bucket + auth) plus a document resource that parses and token-chunks each file, and an optional pipeline that embeds the chunks. Use when the user wants to ingest files/documents from cloud object storage rather than from an API./add-integrationAdd a new API integration to the @bobsled-inc/integrations library. Automates OpenAPI spec discovery, YAML generation, curation, and validation./add-warehouse-sourceAdd a new warehouse or database extractor source to @bobsled-inc/extractor. Guides through schema definitions, client implementation, SQL dialect support, type mappings, factory wiring, and tests.