ndk-batch-event-queries

ndk-batch-event-queries is a skill for Claude Code, Codex from divinevideo/divine-mobile. It costs 109 tokens per session (1,070 once invoked), scanned A, original, MPL-2.0.

A guide to fetching many Nostr events in batches with NDK instead of sending one request for each item. It applies to checking whether multiple events exist on relays.

In plain words
What is it for?
Use it when checking many videos or other addressable events by their labels, or when loops of individual fetchEvents calls are too slow. It helps split large filters into relay-friendly chunks.
Why use it?
It removes the slowdown caused by hundreds of sequential network requests, sometimes called the N+1 query problem. Batching reduces repeated round trips.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one. Also seen: mentions Claude Code; installed under .agents/ (shared by several agents).

Good fit Use it when checking many videos or other addressable events by their labels, or when loops of individual fetchEvents calls are too slow. It helps split large filters into relay-friendly chunks.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/divinevideo/divine-mobile/ndk-batch-event-queries
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add divinevideo/divine-mobile --skill ndk-batch-event-queries
Clone the repo
git clone --depth 1 https://github.com/divinevideo/divine-mobile

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for ndk-batch-event-queries

README.md
[![agentmods](https://agentmods.dev/badge/skills/divinevideo/divine-mobile/ndk-batch-event-queries/github.svg)](https://agentmods.dev/skills/divinevideo/divine-mobile/ndk-batch-event-queries)
Your own site
<a href="https://agentmods.dev/skills/divinevideo/divine-mobile/ndk-batch-event-queries"><img src="https://agentmods.dev/badge/skills/divinevideo/divine-mobile/ndk-batch-event-queries/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for ndk-batch-event-queries

Your own site · 80×15
<a href="https://agentmods.dev/skills/divinevideo/divine-mobile/ndk-batch-event-queries"><img src="https://agentmods.dev/badge/skills/divinevideo/divine-mobile/ndk-batch-event-queries.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 109 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,070 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe. Third-party audits
  • NVIDIA SkillSpector pass 7 Sept 2026
How audits are shown
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00109 $0.01070
Opus 5.5 $0.00044 $0.00428
Sonnet 5.5 $0.00022 $0.00214
Haiku 4.5 $0.00011 $0.00107

Measured 1mo ago against content hash 5ff60c67bc82, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

ndk-batch-event-queries scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 1mo ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.agents/skills/ndk-batch-event-queries/SKILL.md · 134 lines

How it starts

The opening of the file, as written. The whole thing — 134 lines — stays where its author put it; the contents beside it link to each section on GitHub.

NDK Batch Event Queries

Problem

When checking if many Nostr events exist (e.g., 300 videos for a user), querying one-by-one causes hundreds of sequential relay round-trips, making the operation extremely slow (minutes instead of seconds).

Context / Trigger Conditions

  • Loop with await fetchEvents() inside, checking events individually
  • Processing takes minutes when it should take seconds
  • Checking existence of addressable events (Kind 30000-39999) by d-tag
  • Need to find which items from a list already exist on a relay

Solution

NDK's fetchEvents filter accepts arrays for most fields. Instead of:

// SLOW: 300 sequential queries
for (const id of vineIds) {
  const exists = await ndk.fetchEvents({
    kinds: [34236],
    authors: [pubkey],
    "#d": [id],  // Single value
  });
}

Use a batch query:

// FAST: 1-3 queries (chunked if needed)
const CHUNK_SIZE = 100;  // Relays may limit query size
const existingIds = new Set<string>();

for (let i = 0; i < vineIds.length; i += CHUNK_SIZE) {
  const chunk = vineIds.slice(i, i + CHUNK_SIZE);
  const events = await ndk.fetchEvents({
    kinds: [34236],
    authors: pubkeys,  // Can also be an array
    "#d": chunk,       // Array of d-tag values
  });

  for (const event of events) {
    const dTag = event.tags.find(t => t[0] === "d");
    if (dTag?.[1]) existingIds.add(dTag[1]);
  }
}

// O(1) lookup in processing loop
for (const id of vineIds) {
  if (existingIds.has(id)) continue;  // Skip existing
  // Process new items...
}

Key Points

  1. Array filters: #d, #p, #e, authors all accept arrays
  2. Chunk size: Use 50-100 items per query to avoid relay limits
  3. Multiple authors: Pass array of pubkeys if checking across users
  4. Extract results: Parse the d-tag from returned events to build a Set

Verification

  • Processing time drops from minutes to seconds
  • Total relay connections decrease dramatically
  • Same results as individual queries (verified by comparison)

Read the full file on GitHub · 134 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 1mo ago First seen · 134 lines · 109 tokens per session scan A 5ff60c67bc82

Subscribe to this mod's changes

ndk-batch-event-queries is a skill published in the GitHub repository divinevideo/divine-mobile (264 stars, last pushed today), licensed MPL-2.0. It adds 109 tokens to every session and 1,070 once invoked, about $0.0004 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-03.

Related

Other skills, from other repositories

web3-fullstack-packaged-build

Systematic full-stack Web3 build with mandatory packaging and delivery phase.

HKUDS/OpenSpace · 21 tokens

web3-fullstack-systematic-build

Systematic approach to building full-stack Web3 applications layer by layer.

HKUDS/OpenSpace · 21 tokens

devtools-event-client

Create typed EventClient for a library. Define event maps with typed payloads, pluginId auto-prepend namespacing, emit()/on()/onAll()/onAllPluginEvents() API. Connection lifecycle (5 retries, 300ms), event queuing, enabled/disabled state, SSR fallbacks, singleton pattern. Unique pluginId requirement to avoid event…

TanStack/devtools · 79 tokens

solana-dev

Use when user asks to "build a Solana dapp", "write an Anchor program", "create a token", "debug Solana errors", "set up wallet connection", "test my Solana program", "fuzz my Solana program", "deploy to devnet", "send a v1 transaction", "support larger transactions", "fix maxSupportedTransactionVersion", or "explain…

solana-foundation/solana-dev-skill · 249 tokens

walkeros-create-destination

Use when creating a new walkerOS destination to send events to a vendor or API (GA4/gtag, Meta/Facebook Pixel, Mixpanel, Amplitude, a custom HTTP API, Measurement Protocol), web or server-side. Example-driven workflow: research the vendor SDK and define step examples before implementing the destination interface, env…

elbwalker/walkerOS · 77 tokens

walkeros-create-source

Use when creating a new walkerOS source to capture events (browser source, dataLayer interception, server/HTTP source, webhook receiver, event capture), web or server-side. Example-driven workflow: research the input format and define step examples before implementing the push interface, createTrigger, and env pattern.

elbwalker/walkerOS · 65 tokens