Token导航 LogoToken导航

Agent Skill · 开发

db-core%2flive-queries(db core%2flive 查询)

db-core%2flive-queries 用于处理 GitHub 仓库、Issue、Pull Request 和代码协作信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要围绕仓库状态、代码变更或协作事项进行整理时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

db-core%2flive-queries 是开发类 Agent Skill,可用宿主为 Codex、Claude、Cursor、Gemini CLI,通过GitHub 仓库获取,权限为需要联网;许可证信息还不明确,暂无第三方扫描结果,按安装量在开发类的 21,746 个 Skill 里排第 19,668。

总安装 261周安装 11GitHub Stars 3,738下载 92核验 2026-05-01

安装说明

本站只整理中文说明,不托管安装包,也不代用户安装。
GitHub
许可证
unknown

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:db-core%2flive-queries(db core%2flive 查询)
来源仓库:https://github.com/tanstack/db
仓库路径:skills/db-core%2Flive-queries
安装命令:
npx skills add https://github.com/tanstack/db --skill db-core/live-queries
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/tanstack/db --skill db-core/live-queries

这个 Skill 是做什么的

开发类 Skill 面向写代码、改代码和排查问题,一般会读写仓库文件,部分还会执行构建或测试命令。

db-core/live-queries 提供 TanStack DB 的流式查询能力,支持 SQL 风格链式操作与增量视图维护。它自动追踪数据变化并仅重算受影响部分,实现低延迟响应,优于传统 JavaScript 过滤逻辑。

使用时需先配置 collection,再通过 liveQuery 方法构建派生数据集,绑定 UI 渲染更新。建议优先选用内置聚合与字符串函数,减少手动循环带来的性能损耗与 token 开销。db-core%2flive-queries 属于开发类 Skill,可作为该场景下的辅助能力补充。

来源仓库内路径:skills/db-core%2Flive-queries

上手步骤

4 步
  1. 1

    确认自己的宿主工具

    公开资料标注支持 Codex、Claude、Cursor、Gemini CLI;先确认自己用的是其中之一,再按对应工具的 Skills 目录放置。

  2. 2

    拿到安装命令

    可以直接复制的命令是 npx skills add https://github.com/tanstack/db --skill db-core/live-queries;命令里的占位符换成自己的路径或密钥再执行。

  3. 3

    安装后重启宿主

    命令执行完要完全退出宿主工具再打开,让新装的 Skill 被重新扫描到,否则列表里可能看不到。

  4. 4

    按最小权限试用

    它需要需要联网,先在测试目录或测试账号里跑,确认没问题再放到正式项目。

常见问题

6 条

db-core%2flive-queries 怎么安装?

在终端执行 npx skills add https://github.com/tanstack/db --skill db-core/live-queries。装完完全退出宿主工具再打开,让它重新扫描本地 Skill。

db-core%2flive-queries 支持哪些 AI 工具?

公开资料标注支持 Codex、Claude、Cursor、Gemini CLI。其他工具只要能读取本地 Skill 目录,一般也能手动放进去,但要自己确认触发方式是否一致。

db-core%2flive-queries 需要什么权限?

权限级别是需要联网。该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

db-core%2flive-queries 是免费的吗?

公开资料没有标注明确许可证,收费和商用限制都无法确认。正式使用前请到来源仓库核对授权说明。

db-core%2flive-queries 用的人多吗?

公开数据是累计安装 261 次,近一周安装 11 次,下载 92 次,GitHub 3,738 星。这些数字来自第三方目录统计,只能当作热度参考,不代表质量或安全性。

db-core%2flive-queries 安全吗?

没有查到第三方扫描结果,安全性无法从公开资料判断,安装前请自行审查源码、依赖和命令行为。

值得选的地方和要先想清楚的地方

值得选的地方

  • 同时适配 4 种工具,换客户端不用重新找替代品。
  • 来源仓库有 3,738 星,维护活跃度相对可查。

先想清楚的地方

  • 许可证没有明确标注,能不能商用、能不能再分发都不确定。
  • 没有第三方扫描结果,安全性只能靠自己读源码判断。
  • 第三方目录整理,版本更新和行为细节以来源仓库为准。

适不适合你

更适合

  • 已经在用 Codex,想直接扩展它能力的人。
  • 需要处理开发类任务、又不想每次都手写提示词的人。

不太适合

  • 需要明确授权才能用到公司项目里的场景。
  • 要求有安全扫描结论才肯安装的团队。
  • 需要厂商级技术支持和 SLA 的生产系统。

开发类 Skill 对比

6 个同类
Skill总安装GitHub 星权限许可证扫描
skill-vetter

技能审查员 · OpenClaw

8,779,018986操作浏览器MIT-0通过
ontology

本体论 · OpenClaw

6,636,960576只读MIT-0通过
entra-app-registration

内部应用程序注册 · Codex、Claude

6,631,872764接触敏感数据未明确通过
entra-app-registration

内部应用程序注册 · Codex、Claude

3,757,680201接触敏感数据未明确通过
nano-banana-pro

纳米香蕉专业版 · OpenClaw

3,526,898364接触敏感数据MIT-0有提醒
db-core%2flive-queries

db core%2flive 查询 · 本页

2613,738需要联网未明确未收录

按安装量取同分类前几名;数字来自第三方目录统计,只作热度参考,不代表质量结论。

SKILL.md 原文

Live Queries

This skill builds on db-core.

TanStack DB live queries use a SQL-like fluent query builder to create reactive derived collections that automatically update when underlying data changes. The query engine compiles queries into incremental view maintenance (IVM) pipelines using differential dataflow (d2ts), so only deltas are recomputed.

All operators, string functions, math functions, and aggregates are incrementally maintained. Prefer them over equivalent JS code.

Setup

Minimal example using the core API (no framework hooks):

import {
  createCollection,
  createLiveQueryCollection,
  liveQueryCollectionOptions,
  eq,
} from '@tanstack/db'

// Assume usersCollection is already created via createCollection(...)

// Option 1: createLiveQueryCollection shorthand
const activeUsers = createLiveQueryCollection((q) =>
  q
    .from({ user: usersCollection })
    .where(({ user }) => eq(user.active, true))
    .select(({ user }) => ({
      id: user.id,
      name: user.name,
      email: user.email,
    })),
)

// Option 2: full options via liveQueryCollectionOptions
const activeUsers2 = createCollection(
  liveQueryCollectionOptions({
    query: (q) =>
      q
        .from({ user: usersCollection })
        .where(({ user }) => eq(user.active, true))
        .select(({ user }) => ({
          id: user.id,
          name: user.name,
        })),
    getKey: (user) => user.id,
  }),
)

// The result is a live collection -- iterate, subscribe, or use as source
for (const user of activeUsers) {
  console.log(user.name)
}

Core Patterns

1. Filtering with where + operators

Chain .where() calls (ANDed together) using expression operators. Use and(), or(), not() for complex logic.

import { eq, gt, or, and, not, inArray, like } from '@tanstack/db'

const results = createLiveQueryCollection((q) =>
  q
    .from({ user: usersCollection })
    .where(({ user }) => eq(user.active, true))
    .where(({ user }) =>
      and(
        gt(user.age, 18),
        or(eq(user.role, 'admin'), eq(user.role, 'moderator')),
        not(inArray(user.id, bannedIds)),
      ),
    ),
)

Boolean column references work directly:

.where(({ user }) => user.active)        // bare boolean ref
.where(({ user }) => not(user.suspended)) // negated boolean ref

2. Joining two collections

Join conditions must use eq() (equality only -- IVM constraint). Default join type is left. Convenience methods: leftJoin, rightJoin, innerJoin, fullJoin.

import { eq } from '@tanstack/db'

const userPosts = createLiveQueryCollection((q) =>
  q
    .from({ user: usersCollection })
    .innerJoin({ post: postsCollection }, ({ user, post }) =>
      eq(user.id, post.userId),
    )
    .select(({ user, post }) => ({
      userName: user.name,
      postTitle: post.title,
    })),
)

Multiple joins:

q.from({ user: usersCollection })
  .join({ post: postsCollection }, ({ user, post }) => eq(user.id, post.userId))
  .join({ comment: commentsCollection }, ({ post, comment }) =>
    eq(post.id, comment.postId),
  )

3. Aggregation with groupBy + having

Use groupBy to group rows, then aggregate in select. Filter groups with having. The $selected namespace lets having and orderBy reference fields defined in select.

import { count, sum, gt } from '@tanstack/db'

const topCustomers = createLiveQueryCollection((q) =>
  q
    .from({ order: ordersCollection })
    .groupBy(({ order }) => order.customerId)
    .select(({ order }) => ({
      customerId: order.customerId,
      totalSpent: sum(order.amount),
      orderCount: count(order.id),
    }))
    .having(({ $selected }) => gt($selected.totalSpent, 1000))
    .orderBy(({ $selected }) => $selected.totalSpent, 'desc')
    .limit(10),
)

Without groupBy, aggregates in select treat the entire collection as one group:

const stats = createLiveQueryCollection((q) =>
  q.from({ user: usersCollection }).select(({ user }) => ({
    totalUsers: count(user.id),
    avgAge: avg(user.age),
  })),
)

4. Standalone derived collection with createLiveQueryCollection

Derived collections are themselves collections. Use one as a source for another query to cache intermediate results:

// Base derived collection
const activeUsers = createLiveQueryCollection((q) =>
  q.from({ user: usersCollection }).where(({ user }) => eq(user.active, true)),
)

// Second query uses the derived collection as its source
const activeUserPosts = createLiveQueryCollection((q) =>
  q
    .from({ user: activeUsers })
    .join({ post: postsCollection }, ({ user, post }) =>
      eq(user.id, post.userId),
    )
    .select(({ user, post }) => ({
      userName: user.name,
      postTitle: post.title,
    })),
)

Create derived collections once at module scope and reuse them. Do not recreate on every render or navigation.

Virtual Properties

Live query results include computed, read-only virtual properties on every row:

  • $synced: true when the row is confirmed by sync; false when it is still optimistic.
  • $origin: "local" if the last confirmed change came from this client, otherwise "remote".
  • $key: the row key for the result.
  • $collectionId: the source collection ID.

These props are added automatically and can be used in where, select, and orderBy clauses. Do not persist them back to storage.

Includes (Subqueries in Select)

Embed a correlated subquery inside select() to produce hierarchical (nested) data. The subquery must contain a where with an eq() that correlates a parent field with a child field. Three materialization modes are available.

Collection includes (default)

Return a child Collection on each parent row:

import { eq, createLiveQueryCollection } from '@tanstack/db'

const projectsWithIssues = createLiveQueryCollection((q) =>
  q.from({ p: projectsCollection }).select(({ p }) => ({
    id: p.id,
    name: p.name,
    issues: q
      .from({ i: issuesCollection })
      .where(({ i }) => eq(i.projectId, p.id))
      .select(({ i }) => ({
        id: i.id,
        title: i.title,
      })),
  })),
)

// Each row's `issues` is a live Collection
for (const project of projectsWithIssues) {
  console.log(project.name, project.issues.toArray)
}

Array includes with toArray()

Wrap the subquery in toArray() to get a plain array of scalar values instead of a Collection:

import { eq, toArray, createLiveQueryCollection } from '@tanstack/db'

const messagesWithParts = createLiveQueryCollection((q) =>
  q.from({ m: messagesCollection }).select(({ m }) => ({
    id: m.id,
    contentParts: toArray(
      q
        .from({ c: chunksCollection })
        .where(({ c }) => eq(c.messageId, m.id))
        .orderBy(({ c }) => c.timestamp)
        .select(({ c }) => c.text),
    ),
  })),
)
// row.contentParts is string[]

Concatenated scalar with concat(toArray())

Wrap toArray() in concat() to join the scalar results into a single string:

import { eq, toArray, concat, createLiveQueryCollection } from '@tanstack/db'

const messagesWithContent = createLiveQueryCollection((q) =>
  q.from({ m: messagesCollection }).select(({ m }) => ({
    id: m.id,
    content: concat(
      toArray(
        q
          .from({ c: chunksCollection })
          .where(({ c }) => eq(c.messageId, m.id))
          .orderBy(({ c }) => c.timestamp)
          .select(({ c }) => c.text),
      ),
    ),
  })),
)
// row.content is a single concatenated string

Includes rules

  • The subquery must have a where clause with an eq() correlating a parent alias with a child alias. The library extracts this automatically as the join condition.
  • toArray() works with both scalar selects (e.g., select(({c}) => c.text) → string[]) and object selects (e.g., select(({c}) => ({id: c.id, title: c.title})) → Array<{id, title}>).
  • concat(toArray()) requires a scalar select to concatenate into a string.
  • Collection includes (bare subquery) require an object select.
  • Includes subqueries are compiled into the same incremental pipeline as the parent query -- they are not separate live queries.

One-Shot Queries with queryOnce

For non-reactive, one-time snapshots use queryOnce. It creates a live query collection, preloads it, extracts the results, and cleans up automatically.

import { eq, queryOnce } from '@tanstack/db'

const activeUsers = await queryOnce((q) =>
  q
    .from({ user: usersCollection })
    .where(({ user }) => eq(user.active, true))
    .select(({ user }) => ({ id: user.id, name: user.name })),
)

// With findOne — resolves to T | undefined
const user = await queryOnce((q) =>
  q
    .from({ user: usersCollection })
    .where(({ user }) => eq(user.id, userId))
    .findOne(),
)

Use queryOnce for scripts, loaders, data export, tests, or AI/LLM context building. For UI bindings and reactive updates, use live queries instead.

Reactive Effects (createEffect)

Reactive effects respond to query result *changes* without materializing the full result set. Effects fire callbacks when rows enter, exit, or update within a query result — like a database trigger on an arbitrary live query.

import { createEffect, eq } from '@tanstack/db'

const effect = createEffect({
  query: (q) =>
    q
      .from({ msg: messagesCollection })
      .where(({ msg }) => eq(msg.role, 'user')),
  skipInitial: true,
  onEnter: async (event, ctx) => {
    await processNewMessage(event.value, { signal: ctx.signal })
  },
  onExit: (event) => {
    console.log('Message left result set:', event.key)
  },
  onError: (error, event) => {
    console.error(`Failed to process ${event.key}:`, error)
  },
})

// Dispose when no longer needed
await effect.dispose()
Use caseApproach
Display query results in UILive query collection + useLiveQuery
React to changes (side effects)createEffect with onEnter / onUpdate / onExit
Inspect full batch of changescreateEffect with onBatch

Key options: id (optional), query, skipInitial (skip existing rows on init), onEnter, onUpdate, onExit, onBatch, onError, onSourceError. The ctx.signal aborts when the effect is disposed.

Common Mistakes

CRITICAL: Using === instead of eq()

JavaScript === in a where callback returns a boolean primitive, not an expression object. Throws InvalidWhereExpressionError.

// WRONG
q.from({ user: usersCollection }).where(({ user }) => user.active === true)

// CORRECT
q.from({ user: usersCollection }).where(({ user }) => eq(user.active, true))

CRITICAL: Filtering in JS instead of query operators

JS .filter() / .map() on the result array throws away incremental maintenance -- the JS code re-runs from scratch on every change.

// WRONG -- re-runs filter on every change
const { data } = useLiveQuery((q) => q.from({ todos: todosCollection }))
const active = data.filter((t) => t.completed === false)

// CORRECT -- incrementally maintained
const { data } = useLiveQuery((q) =>
  q
    .from({ todos: todosCollection })
    .where(({ todos }) => eq(todos.completed, false)),
)

HIGH: Not using the full operator set

The library provides string functions (upper, lower, length, concat), math (add), utility (coalesce), and aggregates (count, sum, avg, min, max). All are incrementally maintained. Prefer them over JS equivalents.

// WRONG
.fn.select((row) => ({
  name: row.user.name.toUpperCase(),
  total: row.order.price + row.order.tax,
}))

// CORRECT
.select(({ user, order }) => ({
  name: upper(user.name),
  total: add(order.price, order.tax),
}))

HIGH:.distinct() without.select()

distinct() deduplicates by the selected columns. Without select(), throws DistinctRequiresSelectError.

// WRONG
q.from({ user: usersCollection }).distinct()

// CORRECT
q.from({ user: usersCollection })
  .select(({ user }) => ({ country: user.country }))
  .distinct()

HIGH:.having() without.groupBy()

having filters aggregated groups. Without groupBy, there are no groups. Throws HavingRequiresGroupByError.

// WRONG
q.from({ order: ordersCollection }).having(({ order }) =>
  gt(count(order.id), 5),
)

// CORRECT
q.from({ order: ordersCollection })
  .groupBy(({ order }) => order.customerId)
  .having(({ order }) => gt(count(order.id), 5))

HIGH:.limit() /.offset() without.orderBy()

Without deterministic ordering, limit/offset results are non-deterministic and cannot be incrementally maintained. Throws LimitOffsetRequireOrderByError.

// WRONG
q.from({ user: usersCollection }).limit(10)

// CORRECT
q.from({ user: usersCollection })
  .orderBy(({ user }) => user.name)
  .limit(10)

HIGH: Join condition using non-eq() operator

The differential dataflow join operator only supports equality joins. Using gt(), like(), etc. throws JoinConditionMustBeEqualityError.

// WRONG
q.from({ user: usersCollection }).join(
  { post: postsCollection },
  ({ user, post }) => gt(user.id, post.userId),
)

// CORRECT
q.from({ user: usersCollection }).join(
  { post: postsCollection },
  ({ user, post }) => eq(user.id, post.userId),
)

MEDIUM: Passing source directly instead of {alias: collection}

from() and join() require sources wrapped as {alias: collection}. Passing the collection directly throws InvalidSourceTypeError.

// WRONG
q.from(usersCollection)

// CORRECT
q.from({ users: usersCollection })

Tension: Query expressiveness vs. IVM constraints

The query builder looks like SQL but has constraints that SQL does not:

  • Equality joins only -- eq() is the only allowed join condition operator.
  • orderBy required for limit/offset -- non-deterministic pagination cannot be incrementally maintained.
  • distinct requires select -- deduplication needs an explicit projection.
  • fn.select() cannot be used with groupBy() -- the compiler must statically analyze select to discover aggregate functions.

These constraints exist because the underlying d2ts differential dataflow engine requires them for correct incremental view maintenance.

See also: react-db/SKILL.md for React hooks (useLiveQuery, useLiveSuspenseQuery, useLiveInfiniteQuery).

References

平台分布

Codex

35.17%
按下载量换算32

Claude

30.31%
按下载量换算28

Cursor

21.44%
按下载量换算20

Gemini CLI

10.3%
按下载量换算9

安全审计

暂无安全审计结果可展示。

权限和风险

需要联网

该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。目前只有一个公开来源,建议同时核对源仓库。

继续浏览同类 Skills