Add query mode

From cliftonc/drizzle-cube · View interactive version

Add query mode is an AI agent skill from the GitHub repository cliftonc/drizzle-cube. Use when adding a new analysis/query mode to drizzle-cube (e.g., cohort, path analysis). Covers backend types, query builder, executor/compiler integration, frontend adapter, store slice, hooks, UI components, tests, and icon.

How to use this skill

Skill file

Adding a Query Mode

Drizzle-cube has four analysis modes: query, funnel, flow, and retention. Each mode requires coordinated changes across backend (types → query builder → executor → compiler → cache), frontend (types → adapter → store slice → hooks → UI), tests, and an icon. Follow this checklist in order.

Documentation Context

Before designing or updating an analysis/query mode, review https://www.drizzle-cube.dev/llms.txt for the current documentation map, public API guidance, and mode-related examples. Use repository source and the checklist below as the implementation source of truth when docs and code differ.

Checklist

Backend

Frontend

Testing

File Reference

| File | Action | Key Symbols |

|------|--------|-------------|

| src/server/types/{mode}.ts | Create | {Mode}QueryConfig, {Mode}ResultRow |

| src/server/types/index.ts | Export new types | — |

| src/server/types/query.ts | Add field to union | SemanticQuery |

| src/server/builders/{mode}-query-builder.ts | Create | has{Mode}(), build{Mode}Query(), validateConfig(), transformResult() |

| src/server/executor.ts | Add builder + routing | QueryExecutor, execute(), execute{Mode}QueryWithCache() |

| src/server/compiler.ts | Add public methods | dryRun{Mode}(), validateQueryAgainstCubes(), explainQuery() |

| src/server/cache-utils.ts | Add normalizer | normalize{Mode}Config(), normalizeQuery() |

| src/client/types/{mode}.ts | Create | {Mode}SliceState, Server{Mode}Query, {Mode}ChartData |

| src/client/types/analysisConfig.ts | Extend union + config | AnalysisType, {Mode}AnalysisConfig |

| src/client/adapters/{mode}ModeAdapter.ts | Create | {mode}ModeAdapter : ModeAdapter |

| src/client/adapters/adapterRegistry.ts | Register adapter | adapterRegistry.register() |

| src/client/stores/slices/{mode}Slice.ts | Create | create{Mode}Slice, createInitial{Mode}State() |

| src/client/stores/analysisBuilderStore.tsx | Compose slice | createAnalysisBuilderStore() |

| src/client/hooks/queries/use{Mode}Query.ts | Create | use{Mode}Query() |

| src/client/hooks/useAnalysisQueryExecution.ts | Add mode routing | server{Mode}Query |

| src/client/hooks/useAnalysisBuilderHook.ts | Add state/actions | — |

| src/client/components/AnalysisBuilder/{Mode}ModeContent.tsx | Create | — |

| src/client/components/AnalysisBuilder/{Mode}ConfigPanel.tsx | Create | — |

| src/client/components/AnalysisBuilder/AnalysisTypeSelector.tsx | Add option | — |

| src/client/components/AnalysisBuilder/AnalysisQueryPanel.tsx | Add conditional render | — |

| src/client/components/AnalyticsPortlet.tsx | Add mode detection | — |

| src/client/icons/customIcons.ts | Add icon | {mode}Icon : IconifyIcon |

Reference Implementations

Study these existing modes as patterns (paths only — read the files directly):

Funnel — src/server/builders/funnel-query-builder.ts, src/server/types/funnel.ts, src/client/adapters/funnelModeAdapter.ts, src/client/types/funnel.ts, src/client/stores/slices/funnelSlice.ts, src/client/hooks/queries/useFunnelQuery.ts, src/client/components/AnalysisBuilder/FunnelModeContent.tsx, src/client/components/AnalysisBuilder/FunnelConfigPanel.tsx, tests/funnel-query.test.ts, tests/client/adapters/funnelModeAdapter.test.ts

Flow — src/server/builders/flow-query-builder.ts, src/server/types/flow.ts, src/client/adapters/flowModeAdapter.ts, src/client/types/flow.ts, src/client/stores/slices/flowSlice.ts, src/client/hooks/queries/useFlowQuery.ts, src/client/components/AnalysisBuilder/FlowModeContent.tsx, tests/flow-query.test.ts, tests/client/adapters/flowModeAdapter.test.ts

Retention — src/server/builders/retention-query-builder.ts, src/server/types/retention.ts, src/client/adapters/retentionModeAdapter.ts, src/client/types/retention.ts, src/client/stores/slices/retentionSlice.ts, src/client/hooks/queries/useRetentionQuery.ts, src/client/components/AnalysisBuilder/RetentionModeContent.tsx, src/client/components/AnalysisBuilder/RetentionConfigPanel.tsx, tests/retention-query.test.ts, tests/client/adapters/retentionModeAdapter.test.ts

Verification

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.