query

Creates UI query use cases following the BFF pattern with direct Drizzle access.

4|Updated Jul 30, 2026
One-click install
npx skills add https://github.com/gabriellst/codm --skill query-gabriellst
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: query
Source: https://github.com/gabriellst/codm/tree/main/.claude/skills/query
Command: npx skills add https://github.com/gabriellst/codm --skill query-gabriellst

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Frontend routes often need data shaped differently from domain DTOs, and stitching multiple API calls in the UI causes N+1 requests and duplicated logic. This Skill guides the creation of read-only query use cases in the BFF (Backend for Frontend) style, with language-specific playbooks for TypeScript and Go. ## Core Features & Use Cases - BFF Query Use Cases (TypeScript): Build Handler classes in the ui context that query tables directly via Drizzle, with Zod input/output schemas, pagination, joins, aggregations, and outputSchema.parse() on return. - Ctx-Local Go Queries: Implement Go Handler[I,O] query handlers that read from repositories without UnitOfWork, with pagination defaults and primitive output mapping. - Language Dispatch: Routes to the TypeScript or Go playbook by file extension, enforcing the ownership rule that UI-shaped queries live in api-typescript while Go owns only ctx-local reads. - Use Case: When a dashboard page needs patient counts, appointments, and revenue in one round-trip, scaffold a single composite query use case instead of three frontend fetches. ## Quick Start Ask the agent to create a UI query use case for the data your route needs, for example: create a ListPatients query with name filter and pagination in the ui context.

Frequently Asked Questions about query

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I create a BFF query use case with Drizzle?

Create a Handler class in packages/api/typescript/src/ui/usecases/ that injects DrizzleDatabaseDriver and queries tables directly via this.driver.db. Define Zod input and output schemas, then return this.outputSchema.parse() of the mapped rows.

When should a read query live in the ui context instead of a domain context?

Use the ui context whenever the output is shaped for a specific frontend view, joins tables across contexts, or aggregates data. Domain contexts are for writes; read-only queries shaped for UI belong in the BFF ui context.

Can Go backend serve UI-shaped queries in this architecture?

No. Per the polyglot ownership matrix, UI-shaped BFF queries belong to api-typescript. Go query handlers are limited to ctx-local reads such as job status checks or internal lookups, using repositories without UnitOfWork.

How do I add pagination to a list query use case?

In TypeScript use z.paginatedQuery for input and z.paginatedResponse for output, with count(*) OVER().mapWith(Number) for totals. In Go, set a default Limit (e.g. 20) when the input Limit is zero before calling the repository.

Why is filtering in memory after a Drizzle query a bad practice?

Filtering in JavaScript after fetching rows wastes bandwidth and breaks pagination counts. All filtering must happen in SQL via Drizzle where/ilike/eq conditions so the database returns only matching rows.