effect-batching

Implement automatic request batching and deduplication using Effect's Request and RequestResolver APIs.

1|Updated Aug 24, 2026
One-click install
npx skills add https://github.com/lambdasolver2/opencode-effect-harness --skill effect-batching-lambdasolver2
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: effect-batching
Source: https://github.com/lambdasolver2/opencode-effect-harness/tree/main/packages/module-typescript/assets/skills/effect-batching
Command: npx skills add https://github.com/lambdasolver2/opencode-effect-harness --skill effect-batching-lambdasolver2

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires effect.

What problem does it solve? Naive data fetching executes one query per item, causing N+1 query problems that degrade performance. This Skill guides you through Effect's batching system so individual lookups are automatically collected and resolved together in a single batched call. ## Core Features & Use Cases - Request and RequestResolver Patterns: Define requests with Request.Class and build resolvers using make, fromFunction, fromEffect, and tagged variants. - Batching, Caching, and Observability: Configure batch windows with setDelay and batchN, add LRU/FIFO caching with withCache, and trace batches with withSpan. - SQL Integration: Use SqlResolver.ordered, grouped, findById, and void for schema-validated batched SQL operations with transaction awareness. - Use Case: Fetching 100 users by ID produces one batched SQL query instead of 100 separate queries, with duplicate IDs automatically deduplicated. ## Quick Start Show me how to solve the N+1 query problem in my Effect service by batching user lookups with RequestResolver and SqlResolver.

Frequently Asked Questions about effect-batching

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

FAQPage Schema
How do I solve the N+1 query problem in Effect TypeScript?

Define requests with Request.Class and resolve them with RequestResolver.make, which receives all collected requests as a batch. Concurrent Effect.request calls are automatically collected and resolved together in a single resolver invocation.

How to batch SQL queries with Effect SqlResolver?

Use SqlResolver.ordered, grouped, findById, or void from effect/unstable/sql to create schema-validated batched SQL resolvers. Concurrent requests are combined into single SQL statements using IN clauses, with automatic transaction grouping.

Does Effect request batching deduplicate identical requests?

Yes, requests use structural equality via the Equal trait, so two identical requests within a batch window are deduplicated automatically. In-flight deduplication also attaches new callers to pending results when caching is enabled.

Why does my Effect resolver throw QueryFailure errors?

QueryFailure occurs when a resolver fails to complete every entry in the batch. Each entry must be completed with entry.completeUnsafe using Exit.succeed, Exit.fail, or Exit.die, including entries with no matching results.

Why is Effect batching not working with Effect.forEach?

Batching requires concurrent execution. Effect.forEach without a concurrency option runs sequentially, so each request resolves individually. Pass { concurrency: "unbounded" } to enable concurrent execution and trigger batching.

How do I add caching to an Effect RequestResolver?

Apply RequestResolver.withCache with a capacity and optional LRU or FIFO strategy to cache results in memory. For TTL control, use RequestResolver.asCache to convert the resolver into a Cache instance with timeToLive configuration.