Skip to content
Back to skills

Batched Queries

ASecurity

Where `batchedQuery` from src/auth/batched-query.ts belongs, which is the browser, and why the server reads many keys with one query instead. Applies whenever writing or reviewing a read that fetches one key at a time, or reaching for batchedQuery.

  • 5 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added September 20, 2026
development

Security analysis

A100/100

Scanned November 27, 2026

npx -y skills add lxsmnsyc/overwander --skill batched-queries --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Batched Queries?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Batched Queries
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/lxsmnsyc-batched-queries/badge)](https://www.skillsdirectory.com/skills/lxsmnsyc-batched-queries)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: batched-queries
description: Where `batchedQuery` from src/auth/batched-query.ts belongs, which is the browser, and why the server reads many keys with one query instead. Applies whenever writing or reviewing a read that fetches one key at a time, or reaching for batchedQuery.
---

# Batched queries belong in the browser

`batchedQuery` gathers every call made in the same moment into one read of all their keys. It only pays when those calls reliably arrive together, and the place they do is one browser tab rendering a list.

## Use it in the browser

Reach for it where many components each read one key as they mount: list rows, cards, lobby parties, a page of history. Every row asks in the same instant, so twenty server calls become one.

The existing ones show the shape: `getCaughtBatched` in `src/auth/caught.ts`, `getTeamBatched` and `getTeamSnapshotBatched` in `src/auth/teams.ts`, and `getProfileBatched` in `src/auth/profile.ts`. Each sits beside the single-key read it batches, which stays for one-off callers.

## Not to merge separate server requests

Do not use it on the server to merge calls from different requests. Separate requests rarely land in the same moment, so the batch mostly adds a timer. When they do land together, one failed query fails every request in it, other players' included. A batched `requireUid` was tried for this and reverted.

## Within one server request, query many keys directly

A handler that needs many rows reads them with one query that takes the list: `readCaughtMany`, `readStacksIn`, or `where id = any(${ids})`. That is simpler than a batch and runs inside the transaction when there is one.

Use `batchedQuery` inside a single request only when that request fans out through code that cannot easily be handed a list, and never inside a transaction: the batched read runs a moment later on its own connection, without the transaction's locks or its writes.

## Setting one up

- Give `key` for object queries, since without it only the same object is read once.
- Give `limit`, since the server function checks the list's length (`ID_BATCH` allows 50). The existing ones use 50.
- Have the callback return a `Map` by key, so `lookup` is one `get` rather than a search.
- Read the result under a `Loading` where a list re-reads: it keeps the rows on screen through a `refresh` rather than swapping them for the fallback.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in development →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.