query-scopes

Create reusable, composable query conditions for Drizzle ORM data access.

2|Updated Feb 13, 2026
One-click install
npx skills add https://github.com/yutna/vibe-next-template --skill query-scopes
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: query-scopes
Source: https://github.com/yutna/vibe-next-template/tree/main/.claude/skills/query-scopes
Command: npx skills add https://github.com/yutna/vibe-next-template --skill query-scopes

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Scopes are a lightweight pattern for building reusable, composable query conditions in data access layers, reducing duplication and improving readability.

Core Features & Use Cases

  • Named scopes such as active, notDeleted, byAuthor, and search enable modular filtering.
  • Composite scopes allow combining multiple conditions into a single reusable predicate.
  • Dynamic scope utilities provide conditional application and dynamic where clause construction.
  • Repository-friendly patterns integrate scopes with common query builders and data access layers for scalable filtering.
  • Use cases include filtering active users, admins, or records by role, status, or search term.

Quick Start

Review the example patterns and integrate the scope patterns into your entity modules to start composing reusable filters.

Frequently Asked Questions about query-scopes

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

FAQPage Schema
How do I create reusable query filters with Drizzle ORM?

You can create reusable query filters in Drizzle ORM by defining named scopes and composite scopes. This pattern lets you build modular conditions like active or notDeleted once, then dynamically apply them across your repository layer to reduce query duplication.

What is the scopes pattern for building composable query conditions?

The scopes pattern is a lightweight technique for building composable query conditions in your data access layer. It uses utility helpers to expose named predicates, enabling conditional application and dynamic where clause construction for scalable, readable filtering.

How do I combine multiple where clauses safely in a TypeScript repository pattern?

You can combine multiple where clauses safely using composite scopes and dynamic scope utilities. These helpers provide safe composition functions that integrate with the repository pattern, allowing you to merge conditions like role-based filters and search terms into a single reusable predicate.

Does this query scope approach work for filtering active users and related search data?

Yes, the query scope approach works for filtering active users and related search data. It includes specific use cases for filtering active users, admins, or records by role, status, or search term, supporting dynamic scope application across related data.

What's the best way to reduce duplication in dynamic query composition?

The best way to reduce duplication in dynamic query composition is to apply the scopes pattern. By creating named and composite scopes, you modularize filtering logic into reusable predicates, improving readability and minimizing repeated where clause definitions.