一键导入
nostr-filter-designer
Design correct Nostr REQ filters when the task is to query relay data with precise AND/OR, tag, thread, zap, reaction, or feed semantics.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Design correct Nostr REQ filters when the task is to query relay data with precise AND/OR, tag, thread, zap, reaction, or feed semantics.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Run Microsoft SkillOpt experiments for agent skills, prompts, or instruction files with clean train/validation/held-out splits, adapter setup, bounded rollouts, artifact collection, and honest reporting. Use when the user wants to use SkillOpt, optimize a skill with SkillOpt, benchmark prompt variants, run multi-epoch skill optimization, check held-out quality, or diagnose SkillOpt runs.
Run pre-implementation AI consulting engagements—company research, discovery, maturity assessment, opportunity prioritization, and proposal/SOW/roadmap creation—and use only for advisory work, not implementation.
Guide annuity and life-insurance sales workflows—discovery, suitability, product selection, objections, closing, and servicing—when supporting licensed insurance sales conversations or deliverables.
Generate API reference documentation from source code—endpoints, schemas, auth, errors, and examples—when the task is to document an existing API rather than design or implement one.
Turns an approved build spec into a minimal technical implementation plan, including system components, human-in-the-loop boundaries, workflows, and delivery milestones. Use when an internal automation, concierge workflow, or lightweight product has already been chosen and now needs a concrete build plan.
Generate release notes and changelogs from git history with SemVer classification, grouped changes, and migration notes when documenting what changed between versions or refs.
| name | nostr-filter-designer |
| description | Design correct Nostr REQ filters when the task is to query relay data with precise AND/OR, tag, thread, zap, reaction, or feed semantics. |
Construct correct REQ filters for Nostr relay queries. The filter syntax has
subtle semantics around AND/OR combination, tag matching, and multi-filter
subscriptions that agents consistently get wrong without explicit guidance.
Do NOT use when:
Always structure the final response with these top-level sections, in this order:
None if nothing remains.Rules:
None when a section does not apply.Translate the natural language query into concrete requirements:
Ask: "Can a single event satisfy ALL my conditions simultaneously?"
The most common mistake is cramming OR-logic into a single filter. If you need "events by Alice OR events mentioning Alice," that requires two filters.
Build each filter object. For each condition, add the appropriate field. Cross-reference with references/filter-patterns.md for common patterns.
Check each filter against these rules:
#e, not #event)since and until are unix timestamps in seconds (not milliseconds)limit is only used for initial queries, not ongoing subscriptionsWrap in the REQ message format:
["REQ", "<subscription-id>", <filter1>, <filter2>, ...]
Need: The root event itself, plus all kind-1 replies that tag it.
A single filter can't do this because the root event won't have an #e tag
pointing to itself. Use two filters (OR):
[
"REQ",
"thread-sub",
{ "ids": ["aabb...64chars"] },
{ "kinds": [1], "#e": ["aabb...64chars"] }
]
Filter 1 fetches the root by ID. Filter 2 fetches all kind-1 events that
reference it via an e tag. Together (OR), you get the complete thread.
Why not one filter? {"ids": ["aabb..."], "#e": ["aabb..."]} would match
only events whose own ID is aabb... AND that also tag aabb... -- which is
almost certainly nothing.
Need: A user's notes, reposts, and reactions.
All three share the same author, so one filter with multiple kinds works (AND on author, list-match on kinds):
{ "authors": ["<pubkey>"], "kinds": [1, 6, 7], "limit": 50 }
This works because kinds is a list -- the event matches if its kind is ANY of
the listed values. Combined with authors (AND), this gives "events by this
author that are notes OR reposts OR reactions."
Need: Replies, reactions, zaps, and reposts of a specific event.
All engagement types tag the event via #e, but have different kinds. One
filter works:
{ "#e": ["<event-id>"], "kinds": [1, 6, 7, 9735] }
Need: Show everything relevant to a user -- their own posts and posts that mention them.
This requires OR (two filters), because an event can't simultaneously be
authored by someone AND mention them in a p tag (well, it could, but you'd
miss events that only satisfy one condition):
[
"REQ",
"user-activity",
{ "authors": ["<pk>"], "kinds": [1] },
{ "#p": ["<pk>"], "kinds": [1] }
]
| Mistake | Why it's wrong | Fix |
|---|---|---|
| OR logic in one filter | {"authors": ["A"], "#p": ["A"]} means events BY A that ALSO tag A (AND) | Use two separate filters |
#event or #pubkey as tag filter key | Tag filter keys are single letters only | Use #e, #p, #a, etc. |
Non-hex values in ids, authors, #e, #p | Must be exact 64-char lowercase hex | Convert npub/note to hex first |
| Timestamps in milliseconds | Nostr uses seconds since epoch | Divide JS Date.now() by 1000 |
Using limit for ongoing subscriptions | limit only applies to the initial query batch | Remove limit for live subscriptions |
| Expecting NOT/exclusion | Nostr filters have no negation | Filter client-side after receiving events |
| Assuming tag filter matches all tag values | Only index 0 (the first value) is matched | Don't try to filter by relay hints or markers |
| Mixing replaceable event semantics | Relay returns only latest for kind 0, 3, 10000-19999 | Don't expect historical versions |
| Query | Filter |
|---|---|
| User's notes | {"authors": ["<pk>"], "kinds": [1]} |
| User's profile | {"authors": ["<pk>"], "kinds": [0]} |
| User's contacts | {"authors": ["<pk>"], "kinds": [3]} |
| User's relay list | {"authors": ["<pk>"], "kinds": [10002]} |
| Replies to event | {"kinds": [1], "#e": ["<eid>"]} |
| Reactions to event | {"kinds": [7], "#e": ["<eid>"]} |
| Zaps on event | {"kinds": [9735], "#e": ["<eid>"]} |
| Reposts of event | {"kinds": [6], "#e": ["<eid>"]} |
| Full thread | {"ids": ["<root>"]} + {"kinds": [1], "#e": ["<root>"]} |
| Comments on content | {"kinds": [1111], "#E": ["<root-id>"]} |
| User's DM relay list | {"authors": ["<pk>"], "kinds": [10050]} |
| All engagement on event | {"#e": ["<eid>"], "kinds": [1, 6, 7, 9735]} |
| Events mentioning user | {"#p": ["<pk>"]} |
| User's feed (notes+reposts+reactions) | {"authors": ["<pk>"], "kinds": [1, 6, 7]} |
See references/filter-patterns.md for the full cookbook with advanced patterns and explanations.
AND within, OR between -- This is the single most important rule. Every condition in one filter is AND'd. Multiple filters are OR'd. There is no other way to combine conditions.
Hex or nothing -- ids, authors, #e, and #p values must be exact
64-character lowercase hex strings. No npub, note1, nprofile, or other NIP-19
encodings. Convert first.
Tag filters are shallow -- #e matches only the first value (index 0) of
e tags. You cannot filter by relay hints, markers, or other positional tag
values. Those must be filtered client-side.
No negation -- You cannot exclude events matching a condition. If you need "all kind-1 events except from author X," fetch all kind-1 events and filter client-side.
Limit is a suggestion for initial load -- limit tells the relay how
many events to return in the initial batch (newest first). It does NOT cap an
ongoing subscription. Relays may return fewer than requested.