/sqlctx:webapp-builderfrom sqlctx
Builds interactive analytics webapps, dashboards, and demos from sqlctx semantic models using copyable React/Tailwind or static HTML component primitives with deterministic query inspection.
Ships in sqlctx. 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; scripts run unread.
Build webapps around a validated sqlctx semantic layer. Use the canonical built UI distribution, then wire runtime-specific data adapters to its documented props or mount functions.
In command examples, set SQLCTX_PLUGIN_ROOT to the installed sqlctx plugin directory.
Treat assets/ui-dist/ as the generated distribution of the sole component source in webapp/src. Never regenerate or fork component markup in a target project.
Copy React + Tailwind components for product apps:
uv run ${SQLCTX_PLUGIN_ROOT}/skills/webapp-builder/scripts/copy_components.py \
--kind react-tailwind \
--target src/components/sqlctx
Copy the static component files for plain HTML demos or generated scaffolds:
uv run ${SQLCTX_PLUGIN_ROOT}/skills/webapp-builder/scripts/copy_components.py \
--kind static \
--target public/sqlctx-components
Use --list to inspect the distribution. Existing target files are never overwritten unless --force is passed.
Available React primitives:
Analytics surfaces:
DashboardShell: dense analytics page frame with status and toolbar slots.MetricCard: metric label, value, inline delta with comparison caption, loading, selected state.Leaderboard: ranked dimension rows with bars, selection, and stable data attributes.FilterPill: active filter display and removal.QueryDebugPanel (+ tokenizeSql): generated SQL/debug surface.DataPreviewTable: stable sample row preview.DataTable (+ columnTotal, paginateRows): sortable, paginated result table with optional client search, totals footer, and sticky header.LoadingState, EmptyState, ErrorState, StatusDot, ErrorBoundary: status surfaces.Charts (hand-rolled SVG, theme-token driven, shared ChartTooltip/useChartTooltip):
TimeSeriesChart: full-size metric series with crosshair, comparison overlay, brush-to-zoom.LineChart, Sparkline: compact trend lines.ColumnChart: categorical bars with a zero baseline.BarLineCombo: dual-axis bars + independently scaled line.StackedAreaChart: composition over time using the categorical --viz-N palette.DonutChart (+ donutSegments): part-of-whole with center total and legend.HistogramChart (+ binValues): distribution of one numeric field.ScatterChart: numeric x/y correlation, optional multi-series coloring.HeatmapChart: category-by-category intensity grid.WaterfallChart (+ waterfallSteps): contribution bridge with running totals.NetworkChart (+ layoutNetwork): deterministic force-directed graph.Inputs and controls (dependency-free, accessible):
Button, Select, Switch, Tabs: base controls in the data-tool idiom.Combobox (+ filterOptions): searchable listbox; single-select, or multiple with removable chips. Use Combobox for multi-select or long lists where typeahead beats scanning; Select for a short static single choice.DatePicker (+ monthGrid): single or range calendar, inline or popover, ISO string values.DateRangeControl: preset + custom date range with comparison-mode picker.GrainSelect, TimezoneSelect, ViewSwitcher: dashboard toolbar controls.Tooltip: hover tooltip for arbitrary triggers (header hints, truncated labels), on the same surface as chart tooltips.Standard conventions shared by the primitives:
rowsToCategories, rowsToBarLine, rowsToPoints, rowsToSeries (long-to-wide pivot), rowsToCells, rowsToTimeSeries — instead of hand-reshaping per call site. parseTemporal normalizes ISO strings, epoch seconds/milliseconds, and Date values.TooltipRows (heading + aligned label/value rows + series swatches) inside ChartTooltip, so every hover reads the same. Custom charts should do the same rather than inventing new tooltip markup.vizColor(index) / VIZ_COLOR_COUNT cycle the theme's --viz-1..--viz-6 categorical colors; override them (and all other tokens) via applyThemeTokens.State primitives are conditional UI branches. Do not render loading, empty, and error examples as permanent app content unless the user explicitly asks for a component gallery.
Available static mount helpers in sqlctx-ui-static.js:
aliasForSemanticRef, toComponentResult, toComponentQuery, filterZeroMetricRows.labelize, formatValue, metricConfigFor, metricValueFormat, formatDateLike, seriesRangeLabel.renderMetricCards, renderMetricSummaryCards, renderLeaderboard, renderDimensionLeaderboardCards, renderFilterPills, renderSparkline, renderColumnChart, renderHighlightedQueryDebug, renderDataPreview, renderValidationState, renderState.renderSelectOptions, setControlsDisabled, syncScrollPosition.normalizeFilterValue, toggleFilterValue, removeFilterValue, removeFilterDimension.Use those static helpers before writing one-off DOM wiring. They are intentionally generic: they work for metric explorers, focused dashboards, debug tools, and browser-only demos as long as the app passes semantic query metadata plus row results into them. Runtime adapters for Python APIs, Pyodide, Rust WASM, DuckDB-WASM, or product backends should stay outside the copied component files.
info and the inspector in noninteractive agent work. Use validate only when the current CLI exits cleanly in your environment:uv run sqlctx info path/to/models
uv run ${SQLCTX_PLUGIN_ROOT}/skills/webapp-builder/scripts/inspect_layer.py path/to/models \
--db path/to/data.duckdb \
--require-execute
uv run ${SQLCTX_PLUGIN_ROOT}/skills/webapp-builder/scripts/inspect_layer.py path/to/models \
--db path/to/data.duckdb \
--require-execute \
--output /tmp/sqlctx-app-spec.json
Use --leaderboard-dimension field_name when domain judgment says one dimension should drive the first leaderboard. Without it, the inspector prefers common categorical dimensions over identifiers and booleans.
Keep the inspection inventory outside public or committed directories: it contains internal SQL, model metadata, and sampled data. Connection strings and raw database errors are omitted. Only the scaffold's allowlisted selected dashboard data belongs in the published app; review that dataset before publishing. The static scaffold does not publish generated SQL or unrelated models and samples.
uv run ${SQLCTX_PLUGIN_ROOT}/skills/webapp-builder/scripts/copy_components.py \
--kind react-tailwind \
--target src/components/sqlctx
Adapt imports, class names, and styling conventions after copying. Preserve the data contract conventions: data-metric, data-dimension, data-value, and data-testid hooks for metric totals, dimension leaderboards, and query debug surfaces.
For a minimal static app scaffold from the executed spec:
uv run ${SQLCTX_PLUGIN_ROOT}/skills/webapp-builder/scripts/scaffold_static_app.py \
/tmp/sqlctx-app-spec.json \
--output dist/sqlctx-dashboard \
--title "Metrics Dashboard"
The scaffold copies readable source from assets/templates/static-dashboard/ and the static component files. If you need a richer generated app, edit those copied source files in the target project; do not bury application JavaScript in Python strings or generated HTML fragments.
sqlctx.api_server.create_app() or start_api_server() when a FastAPI API is acceptable.sqlctx-wasm npm package (sqlctx Rust WASM) + DuckDB-WASM, or Pyodide + DuckDB-WASM, only for static demos or docs pages that must run without a backend.sqlctx.widget.MetricsExplorer instead of rebuilding the widget.sqlctx server mcp --apps --http --port 4100 and existing chart resources when the target is an MCP Apps-compatible host.{
"metrics": ["orders.revenue"],
"dimensions": ["orders.order_date__day"],
"filters": ["orders.status = 'completed'"],
"order_by": ["orders.order_date__day"],
"limit": 500
}
If a control is visible, it must change the app state or data. Do not satisfy interaction requirements by only changing a status label. Removing a filter must recompute metric cards, leaderboards, charts, and preview rows. Clicking a leaderboard row must add or toggle a filter. Selecting a metric must change the leaderboard ranking metric.
uv run sqlctx info path/to/models
uv run ${SQLCTX_PLUGIN_ROOT}/skills/webapp-builder/scripts/inspect_layer.py path/to/models --db path/to/data.duckdb --require-execute
uv run sqlctx query "SELECT metric_name FROM model_name LIMIT 5" --models path/to/models --db path/to/data.duckdb
uv run ${SQLCTX_PLUGIN_ROOT}/skills/webapp-builder/scripts/verify_static_app.py dist/sqlctx-dashboard
bunx --bun -p playwright node ${SQLCTX_PLUGIN_ROOT}/skills/webapp-builder/scripts/verify_static_interactions.mjs --url http://127.0.0.1:5174/
bun run build
For frontend changes, run the app on a 4xxx-5xxx port and verify with browser screenshots at desktop and mobile widths. If browser tooling is unavailable, run verify_static_app.py or another deterministic DOM/data check and state that real browser visual verification was not run.
For interactive dashboards, verify behavior, not just render counts:
For static dashboards that use the bundled component contracts, use the smoke-test script after starting a local server:
bunx --bun -p playwright playwright install chromium # first run only, if Playwright reports a missing browser
bunx --bun -p playwright node ${SQLCTX_PLUGIN_ROOT}/skills/webapp-builder/scripts/verify_static_interactions.mjs \
--url http://127.0.0.1:4519/
The script clicks filter pills, leaderboard rows, metric cards, and reset controls, and fails if visible data does not change.
Use the generated app spec first. For deeper implementation details, read references/webapp-patterns.md.
Default query set:
model.time_dimension__grain, ordered by time, capped around 500 points.Use inspect_layer.py --require-execute when a database is available. This adds result.columns, result.sample_rows, and sample_row_count to each compiled query and exits nonzero if execution is missing or fails. Use plain --execute only when a warning is acceptable.
For crossfilter leaderboards, exclude the dimension's own filter while querying that same dimension. If device_os = iOS is active, the device OS card should still show peer OS values while other cards show values within iOS.
Use explicit aliases at API boundaries so UI column names stay stable. The inspector emits output_aliases and, with --execute, actual result columns. Do not make display components depend on database-specific column casing or quoted identifiers.
Run DuckDB validation serially against a file database. Do not run the inspector and sqlctx query concurrently against the same .duckdb path; DuckDB file locks can make valid workflows fail.
When the app can call Python directly, prefer the existing HTTP API:
GET /healthGET /modelsGET /graphPOST /compilePOST /query?format=jsonPOST /query?format=arrowPOST /sqlWhen building a TypeScript frontend with a separate backend, keep sqlctx execution in Python unless the project already has a stable Python service. A Hono server can proxy to the sqlctx API, add auth/session context, and normalize responses.
Never concatenate user-entered filter values into SQL in the frontend. Pass structured filter values to a server-side query builder or quote them with the same rules as sqlctx/widget code.
The CLI sqlctx query auto-adds default time dimensions for metrics when a model has default_time_dimension. For exact app query shapes like true totals, prefer the inspector-generated SQL/result samples or the Python/API structured query path using skip_default_time_dimensions=True internally.
scripts/inspect_layer.py: inspect models, compile app query shapes, execute samples with --execute, or require execution with --require-execute.scripts/copy_components.py: copy the React + Tailwind or static component distribution from assets/ui-dist/ into a project.scripts/scaffold_static_app.py: create a small static dashboard from an executed app spec by copying templates and components. It writes index.html, styles.css, sqlctx-components.js, app.js, and data/app-spec.json.scripts/verify_static_app.py: dependency-free fallback verifier for static dashboards. It checks files, executed result samples, true totals, non-id leaderboard dimensions, and expected DOM/data bindings.scripts/verify_static_interactions.mjs: Playwright smoke test for standard static component contracts. It verifies real data changes for filter, leaderboard, metric, reset, and chart-bounds behavior.assets/ui-dist/sqlctx-ui.js + sqlctx-ui.css: the built React + Tailwind distribution copied by copy_components.py --kind react-tailwind.assets/ui-dist/sqlctx-ui-static.js: the static mount-helper bundle copied by copy_components.py --kind static.assets/templates/static-dashboard/: readable static app templates used by scaffold_static_app.py.After copying assets into a project, treat them as that project's code. Modify them to match local component APIs, naming, tests, and design system constraints.
Use browser-only sqlctx execution for static demos, docs, and shareable examples. The UI should still consume the copied static component files; keep runtime adapters separate from components.
sqlctx-wasm package (bun add sqlctx-wasm), call createSqlctxRuntime(), compile/validate/rewrite through it, and keep the generated SQL visible in the debug panel. For a no-bundler static page, vendor the package's bundle (see examples/sqlctx_wasm_demo).Analytics webapps should feel work-focused:
rx) on bars or heatmap cells; rounding is for chrome (buttons, chips, cards), never for marks.sqlctx validate and sqlctx info are noninteractive (add --json for machine-readable output); sqlctx workbench is a TUI, so never script it.inspect_layer.py --require-execute when possible so result columns and sample rows are checked and failures are nonzero.viewBox, padding, and overflow: hidden; verify with screenshots.3000 or 8000 in worktrees. Prefer 4100, 4400, 5174, or another available 4xxx-5xxx port.file:// when it fetches JSON/CSV. Serve it locally instead, because browser file-scheme fetch behavior differs from a real app.agents/openai.yaml (opens in a new tab)assets/templates/static-dashboard/app.js (opens in a new tab)assets/templates/static-dashboard/index.html (opens in a new tab)assets/ui-dist/sqlctx-ui-static.js (opens in a new tab)assets/ui-dist/sqlctx-ui.css (opens in a new tab)assets/ui-dist/sqlctx-ui.js (opens in a new tab)references/webapp-patterns.md (opens in a new tab)scripts/copy_components.py (opens in a new tab)scripts/inspect_layer.py (opens in a new tab)scripts/scaffold_static_app.py (opens in a new tab)scripts/verify_static_app.py (opens in a new tab)scripts/verify_static_interactions.mjs (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub sidequery/sqlctx --plugin sqlctx3 skills in this plugin
/modelerBuild, validate, and manage semantic models using sqlctx. Use when asked to create a semantic layer, define metrics/dimensions, model a database schema, generate models from SQL queries, import from Cube/dbt/LookML, or set up analytics definitions. Prioritizes CLI-first workflows, with YAML and optional Python API usage for advanced automation./semantic-analystAnswer analytical, KPI, metric, trend, cohort, and business-performance questions through a sqlctx semantic layer. Use when asked to analyze data, explain why a metric changed, compare segments or periods, calculate a business measure, or explore warehouse data when sqlctx MCP tools or semantic model files are available. Discover and reuse trusted definitions, distinguish durable semantic-model gaps from one-off query logic, and prefer semantic queries over duplicated raw SQL.Other plugins' skills for the same job