motherduckdb/agent-skills / plugins/motherduck-skills-claude/skills/motherduck-migrate-to-motherduck
motherduck-migrate-to-motherduck
VerifiedPlan or implement migrations to MotherDuck with SQL translation, source-to-target validation, cutover, and rollback.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 4.6 KB |
| artifacts/migration_validation_example.py | script | 2.1 KB |
| artifacts/migration_validation_example.ts | script | 2.7 KB |
| references/EXECUTION_REFERENCE.md | markdown | 1.6 KB |
| references/MIGRATION_PLAYBOOK.md | markdown | 11.8 KB |
| references/MIGRATION_VALIDATION.md | markdown | 14.3 KB |
artifacts/migration_validation_example.ts
View on GitHubexport {};
declare const process: { env: Record<string, string | undefined> };
type OrderRow = { order_id: number; total_amount: number };
function normalizeMetadataValue(value: string | undefined, fallback: string): string {
const raw = (value ?? "").trim();
if (!raw) return fallback;
const normalized = raw.replace(/[^A-Za-z0-9._-]+/g, "-").replace(/^[-._]+|[-._]+$/g, "");
return normalized || fallback;
}
function buildUseCaseUserAgent(): string {
const harness = normalizeMetadataValue(process.env.MOTHERDUCK_AGENT_HARNESS, "unknown");
const llm = normalizeMetadataValue(process.env.MOTHERDUCK_AGENT_LLM, "unknown");
return `agent-skills/3.2.0(harness-${harness};llm-${llm})`;
}
function aggregate(rows: OrderRow[], kind: "count" | "sum" | "avg" | "min" | "max"): number {
if (kind === "count") return rows.length;
const values = rows.map((row) => row.total_amount);
if (kind === "sum") return values.reduce((sum, value) => sum + value, 0);
if (kind === "avg") return values.reduce((sum, value) => sum + value, 0) / values.length;
if (kind === "min") return Math.min(...values);
return Math.max(...values);
}
function compareMetric(source: OrderRow[], target: OrderRow[], kind: "count" | "sum" | "avg" | "min" | "max") {
const sourceValue = aggregate(source, kind);
const targetValue = aggregate(target, kind);
return {
source: sourceValue,
target: targetValue,
pct_variance: sourceValue ? Number((((targetValue - sourceValue) / sourceValue) * 100).toFixed(4)) : null,
};
}
const sourceRows: OrderRow[] = [
{ order_id: 1, total_amount: 100.0 },
{ order_id: 2, total_amount: 150.0 },
{ order_id: 3, total_amount: 200.0 },
];
const targetRows: OrderRow[] = [
{ order_id: 1, total_amount: 100.0 },
{ order_id: 2, total_amount: 150.0 },
{ order_id: 4, total_amount: 210.0 },
];
const sourceIds = new Set(sourceRows.map((row) => row.order_id));
const targetIds = new Set(targetRows.map((row) => row.order_id));
const result = {
backend: {
mode: "typescript-companion",
databases: { legacy_source: "legacy_source", motherduck_target: "motherduck_target" },
user_agent: buildUseCaseUserAgent(),
},
metric_comparison: {
"count(*)": compareMetric(sourceRows, targetRows, "count"),
"SUM(total_amount)": compareMetric(sourceRows, targetRows, "sum"),
"AVG(total_amount)": compareMetric(sourceRows, targetRows, "avg"),
"MIN(total_amount)": compareMetric(sourceRows, targetRows, "min"),
"MAX(total_amount)": compareMetric(sourceRows, targetRows, "max"),
},
new_records: targetRows.filter((row) => !sourceIds.has(row.order_id)).map((row) => [row.order_id]),
deleted_records: sourceRows.filter((row) => !targetIds.has(row.order_id)).map((row) => [row.order_id]),
};
console.log(JSON.stringify(result, null, 2));
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| deprecation-and-migrationaddyosmani/agent-skillsManages deprecation and migration. Use when removing old systems, APIs, or features. Use when migrating users from one implementation to another. Use when migrating a database schema in production, such as renaming or dropping a column without downtime (expand/contract). Use when deciding whether to maintain or sunset existing code. | Stars: 119k | Updated | Claude CodeCodex | Verified | Install |
| performance-optimizationaddyosmani/agent-skillsOptimizes application performance across frontend, backend, queries, and databases. Use when performance requirements exist, when you suspect performance regressions, when Core Web Vitals or load times need improvement, when N+1 query patterns need fixing, or when profiling reveals bottlenecks. | Stars: 119k | Updated | Claude CodeCodex | Verified | Install |
| agent-cost-reportthedotmack/claude-memBelievable agent cost report for any period, default the last 7 full days PT, not counting today. Measured tokens from Claude Code transcripts priced at OpenRouter list prices (ESTIMATED), measured provider spend when a sanctioned source exists, note-taker cost separate, Timing-style HTML/PDF plus report.json, line-items.csv, evidence.json. | Stars: 118k | Updated | Claude CodeCodex | Verified | Install |
| agent-cost-reportthedotmack/claude-memBelievable agent cost report for any period, default the last 7 full days PT, not counting today. Measured tokens from Claude Code transcripts priced at OpenRouter list prices (ESTIMATED), measured provider spend when a sanctioned source exists, note-taker cost separate, Timing-style HTML/PDF plus report.json, line-items.csv, evidence.json. | Stars: 118k | Updated | Claude CodeCodex | Verified | Install |