Skip to main content

motherduck-dive-components

Build Dive UIs from a reusable React component kit (stat cards, gauges, area, heatmap, Sankey, treemap, timeline, date picker), brand themes, and custom components.

v1.0.0New

Install this skill

No account required. Pick your tool, or use the command that detects it for you.

Run in your terminal. It detects your AI tool.

npx @skills-hub-ai/cli install motherduck-motherduck-dive-components
Or get the file:
Browse all CLI commands →
Manual setup by platform

Claude Code

~/.claude/skills/motherduck-motherduck-dive-components/SKILL.md

Setup guide →

Signing

SignedSLSA L2
Signed by
skills-hub.ai distributor
Method
Distributor-signed by skills-hub.aiCryptographically signed by the skills-hub.ai distributor key at publish time.
Signed
0Save

Instructions

MotherDuck Dive Components

A component kit for Dives, copied into the Dive as source the way shadcn/ui works: a Dive is one .tsx file that may import only the runtime libraries get_dive_guide lists, so nothing is installed. Use it when a Dive needs more than the basic charts, a consistent look across several Dives, a brand theme, or a component the kit lacks. motherduck-create-dive owns the Dive mechanics (runtime contract, saving, sharing, embedding, write-back); this skill owns the visual building blocks.

When MotherDuck MCP is available, call get_dive_guide before writing Dive code and before every save_dive, update_dive, or edit_dive_content.

Start Here

  1. Open artifacts/gallery/index.html in a browser to see every component on sample data, with each block's data behind its </> button. It needs no MotherDuck account.
  2. Read artifacts/components.json: for each component, the data shape it renders, when to use it, and the other renderers it can switch to.
  3. Pick components for the question, write the Dive's queries, and build blocks from the rows.

Kit

PathWhat it holds
artifacts/kit/core.tsxThemes, makeTheme, ThemeCtx, formatting (N, fmt, niceTicks), primitives (Card, Badge, Button, Segmented, Skeleton, Delta, Sparkline), registerComponent, BlockView
artifacts/kit/blocks.tsxKPI row, line, bar, table, callouts, text
artifacts/kit/stats.tsxMetric cards, compact stats, radial gauges
artifacts/kit/area.tsxArea chart with headline value, legend toggles, crosshair
artifacts/kit/heatmap.tsxCalendar (daily activity) and matrix heatmaps
artifacts/kit/sankey.tsxFlows from one set of categories to another
artifacts/kit/treemap.tsxPart-to-whole, grouped, click to zoom
artifacts/kit/timeline.tsxEvents in order
artifacts/kit/datepicker.tsxSingle date and range picker with presets (an input, not a block)
artifacts/examples/funnel.tsxA custom component to copy
artifacts/assemble.pyConcatenates the kit, custom files, and your Dive into one index.tsx

Blocks

Every component renders a block: a plain object with id, type, title, and data in the shape components.json gives. Components never run SQL. Query with useSQLQuery, convert values with N(), build the block, and render it with BlockView:

// @imports
import { useSQLQuery } from '@motherduck/react-sql-query';
// @imports-end

export const REQUIRED_DATABASES = [{ type: 'database', path: 'md:analytics', alias: 'analytics' }];

export default function DailyVisits() {
	const q = useSQLQuery(`SELECT strftime(day, '%Y-%m-%d') AS x, count(*) AS visits
	                       FROM "analytics"."main"."events" GROUP BY 1 ORDER BY 1`);
	const rows = Array.isArray(q.data) ? q.data : [];
	const block = {
		id: 'daily', type: 'heatmap', mode: 'calendar', title: 'Daily visits',
		x: { kind: 'time', grain: 'day' },
		series: [{ key: 'visits', label: 'Visits', format: 'count' }],
		data: rows.map((r: any) => ({ x: String(r.x), visits: N(r.visits) })),
	};
	return (
		<ThemeCtx.Provider value={makeTheme('motherduck')}>
			<Card title={block.title} icon={componentIcon(block.type)}>
				{q.isLoading ? <Skeleton h={140} /> : <BlockView block={block} />}
			</Card>
		</ThemeCtx.Provider>
	);
}

Any block can also carry narrative and context:

  • insight: a "so what" line, rendered by <BlockInsight>.
  • about: { definitions: [{ term, text }], why }, which <SourceFooter> shows with the source.
  • probe and hypothesis: mark a follow-up query.

Callout items can carry continuity (new, ongoing, worsening, improving, resolved) with first_seen and times_seen. Pass a nav with rate and rating to add thumbs up and down.

For any input, use the form fields in kit/field.tsx, modelled on shadcn/ui Field:

  • Layout: FieldSet and FieldLegend group fields; FieldGroup stacks them.
  • One field: Field (orientation vertical, horizontal or responsive, plus invalid) wraps a FieldLabel, the control, a FieldDescription and a FieldError.
  • Controls: Input, Textarea, Select and ChoiceGroup (radio or checkbox choice cards, or chips).
  • From a spec: a form block renders a whole form and sends the answers to nav.submit(blockId, values). Use native controls: they work in every Dive.

A questions block asks viewers about a date or a segment the data can't explain. Each answer is a note: { kind: 'date' | 'topic', x, grain?, dimension?, value?, category, note }. Pass a nav with annotate and noteFor to take answers. withNotes(block, notes) pins notes to every block that shows that date or value, as markers on line and area charts. <NotesLine> lists them under a block, and <NoteForm>, built on the form fields, adds one from any chart.

Formats are count, currency, pct (a fraction), number, delta_pct, text, and row (read _format per row). Set good: 'down' on measures where lower is better, so deltas colour by meaning rather than direction.

Assemble and preview with the MotherDuck CLI:

python3 artifacts/assemble.py app.tsx -o my-dive/index.tsx --components kpi,line,heatmap
motherduck dive watch my-dive

Omit --components to include the whole kit. Before save_dive or update_dive, follow the review step that get_dive_guide sets for your client: when it asks you to show the final source or preview and get the user's go-ahead, do that once, unless the user already said to save without review.

Variants

A block can render with any registered component whose accepts(block) takes its data: a KPI row as stats, metric cards, compact stats, or gauges; a line as area, bar, heatmap, or table; a bar as treemap or table. variantsFor(block) lists them. Offer the switch with Segmented, and keep the viewer's choice in useDiveState.

Themes and Brands

motherduck is the default theme and follows the visual rules in get_dive_guide: flat, no card chrome, the MotherDuck palette. Use it unless the user asks for another look or the Dive already has one. The kit also ships swiss (greyscale, one red accent), paper (cards), duck (brutalist brand), and night (dark).

For a brand, ask for the accent colour, flat or card look, and a font, then derive a theme:

const theme = makeTheme({ base: 'paper', name: 'Acme', accent: '#0f766e', font: 'Georgia, serif', radius: 6 });

Dives cannot load web fonts, so offer system font stacks. Read references/THEMING.md for the token list and the contrast and colour checks.

Custom Components

When no kit component shows the data well, copy artifacts/examples/funnel.tsx, render only from the block with useTheme() tokens, and register it with registerComponent(type, { label, icon, render, variants, accepts }). Pass the file to assemble.py --extra. Read references/CUSTOM_COMPONENTS.md for the contract, the catalog entry, and how a Flight can plan the new component.

Rules

  • Keep SQL out of components; a block is data only.
  • Run every value through N() before maths or charts; format dates in SQL.
  • Use inline styles for colours and sizes; arbitrary Tailwind values do not resolve.
  • Each kit file declares its imports between // @imports and // @imports-end; assemble.py merges them. Do not name a component after an icon or chart it imports (Gauge, Treemap, Sankey).
  • After adding or changing a component, add a sample block to artifacts/gallery/app.tsx, rebuild the page with python3 artifacts/gallery/build_page.py (needs Node.js), and check it in the default theme and one other at desktop and phone width.

References

  • references/THEMING.md -- built-in themes, makeTheme tokens, asking for a brand, contrast checks
  • references/CUSTOM_COMPONENTS.md -- writing, registering, and cataloguing a new component

Related Skills

Load related skills only for missing capabilities; reuse established context.

  • motherduck-create-dive for the Dive runtime contract, saving, sharing, embedding, and write-back
  • motherduck-cli for dive watch, dive push, and keeping Dive source in files
  • motherduck-query for validating the SQL each block renders
This skill doesn’t include stateful context yet, instructions only. Learn about stateful skills.

Security

Loading security scan...

Reviews (0)

Browse all →

More from MotherDuck Agent Skills

View source →

More Build skills

Browse category →
senior-frontendBuild and review React, Next.js, TypeScript or Tailwind frontends: components, scaffolding, performance and bundle size. Use whenever the user wants a new component or app, a page feels slow, the bundle is too big, or asks for a frontend code review.635 installsui-design-systemUse when building a design system: tokens, component docs, responsive scales or developer handoff. Generates tokens with design_token_generator.py.535 installsfrontend-designGuidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making choices that don't read as templated defaults.346 installssenior-backendBuild and fix backend services: REST or GraphQL APIs, auth, microservices, PostgreSQL queries, migrations and load tests. Use whenever the user's API is slow or broken, needs login or auth added, a schema change, or a new endpoint or service scaffolded.246 installsself-improving-agentCurate what the agent has learned into durable project knowledge. Reviews Claude Code auto-memory (MEMORY.md and its topic files) for learnings worth keeping, promotes proven ones into CLAUDE.md or .claude/rules/, records a correction as a lesson that persists across sessions, prunes stale or duplicate entries, and turns a recurring fix into a reusable skill. Use whenever the user asks what you have learned or saved about the project, which memories should become permanent rules, to remember a lesson or stop repeating a mistake, or to clean up, audit or check memory health.173 installsusing-superpowersUse when starting any conversation - establishes how to find and use skills, requiring skill invocation before ANY response including clarifying questions145 installs

Frequently asked questions about motherduck-dive-components

What does the motherduck-dive-components skill do?

Build Dive UIs from a reusable React component kit (stat cards, gauges, area, heatmap, Sankey, treemap, timeline, date picker), brand themes, and custom components. It's a reusable SKILL.md instruction set that loads into your AI coding assistant on demand, no prompt engineering, no copy-pasting every session.

How do I install the motherduck-dive-components skill?

Run `npx @skills-hub-ai/cli install motherduck-motherduck-dive-components` from your terminal. The CLI writes the SKILL.md to the correct location for your AI tool (e.g. ~/.claude/skills/motherduck-motherduck-dive-components/ for Claude Code or ~/.cursor/skills/ for Cursor with --target cursor) and adds it to your project's .skills.json lockfile.

Which AI tools does motherduck-dive-components work with?

motherduck-dive-components runs in Claude Code. It follows the open Agent Skills standard (SKILL.md), so the same skill works in every supported tool without modification.

Is the motherduck-dive-components skill free?

Yes. Every skill on skills-hub.ai is free and open-source. There are no premium tiers, paywalls, or usage limits. You only pay for whatever AI assistant you're already using.

How do I use motherduck-dive-components after installing it?

In Claude Code, type `/motherduck-motherduck-dive-components` (or whatever slash command the skill registers) and the AI follows the skill's instructions immediately. You can also reference it by name in natural language, your AI loads the skill into context when relevant.

Can I share the motherduck-dive-components skill with my team?

Yes. Commit your project's .skills.json lockfile and teammates run `npx @skills-hub-ai/cli install` (no args) to install every skill at the exact version you pinned. Organization-scoped installs work via skills-hub.ai organizations.