Skip to content

motherduckdb/agent-skills / plugins/motherduck-skills-claude/skills/motherduck-enable-self-serve-analytics

motherduck-enable-self-serve-analytics

Verified

Roll out governed MotherDuck analytics to internal teams, choosing trusted datasets, access boundaries, and owners.

artifacts/self_serve_rollout_example.ts

View on GitHub
export {};
declare const process: { env: Record<string, string | undefined> };

type AccountRow = { team: string; account_id: number; status: string; arr: 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})`;
}

const accounts: AccountRow[] = [
  { team: "sales", account_id: 1, status: "healthy", arr: 12000.0 },
  { team: "sales", account_id: 2, status: "watch", arr: 7000.0 },
  { team: "success", account_id: 3, status: "healthy", arr: 9000.0 },
  { team: "success", account_id: 4, status: "risk", arr: 5000.0 },
];

const teamMap = new Map<string, { total_accounts: number; total_arr: number }>();
for (const row of accounts) {
  const current = teamMap.get(row.team) ?? { total_accounts: 0, total_arr: 0 };
  current.total_accounts += 1;
  current.total_arr += row.arr;
  teamMap.set(row.team, current);
}

const result = {
  backend: {
    mode: "typescript-companion",
    databases: { analytics: "analytics" },
    user_agent: buildUseCaseUserAgent(),
  },
  first_audience: "customer success",
  first_asset: 'team KPI Dive on top of "analytics"."main"."customer_health"',
  team_kpis: Array.from(teamMap.entries())
    .map(([team, value]) => ({ team, ...value }))
    .sort((a, b) => b.total_arr - a.total_arr),
};

console.log(JSON.stringify(result, null, 2));
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: 119kUpdated Claude CodeCodexVerifiedInstall
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: 119kUpdated Claude CodeCodexVerifiedInstall
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: 118kUpdated Claude CodeCodexVerifiedInstall
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: 118kUpdated Claude CodeCodexVerifiedInstall