Agents & OrchestrationSûr100100/100
Svelte DB (TanStack)
Svelte 5 bindings for TanStack DB. useLiveQuery with Svelte 5 runes ($state, $derived, $effect). Dependency arrays use getter functions (() => value) for reactive props. Direct destructuring breaks reactivity — use dot notation or wrap with $derived. Conditional queries via returning undefined/null. Import from @tanstack/svelte-db (re-exports all of @tanstack/db).
ou envoie-le directement à ton agent.
Installer dans ton projet
$ curl -fsSL https://arboristhree.xyz/cli/install-skill.mjs -o /tmp/arboris-install-skill.mjs && node /tmp/arboris-install-skill.mjs svelte-db__tanstack-db__packages-svelte-db-skills-00151411e7a8TanStack
TanStack/db
Contenu à copier
---
name: svelte-db
description: >
Svelte 5 bindings for TanStack DB. useLiveQuery with Svelte 5 runes
($state, $derived, $effect). Dependency arrays use getter functions
(() => value) for reactive props. Direct destructuring breaks reactivity —
use dot notation or wrap with $derived. Conditional queries via returning
undefined/null. Import from @tanstack/svelte-db (re-exports all of
@tanstack/db).
type: framework
library: db
framework: svelte
library_version: '0.6.17'
requires:
- db-core
sources:
- 'TanStack/db:docs/framework/svelte/overview.md'
- 'TanStack/db:packages/svelte-db/src/useLiveQuery.svelte.ts'
metadata:
origin: TanStack
---
This skill builds on db-core. Read it first for collection setup, query builder, and mutation patterns.
# TanStack DB — Svelte 5
## Setup
```svelte
<script lang="ts">
import { useLiveQuery, eq, not } from "@tanstack/svelte-db"
const todosQuery = useLiveQuery((q) =>
q
.from({ todo: todoCollection })
.where(({ todo }) => not(todo.completed))
.orderBy(({ todo }) => todo.created_at, "asc")
)
</script>
{#if todosQuery.isLoading}
<div>Loading...</div>
{:else}
<ul>
{#each todosQuery.data as todo (todo.id)}
<li>{todo.text}</li>
{/each}
</ul>
{/if}
```
`@tanstack/svelte-db` re-exports everything from `@tanstack/db`.
## Hook
### useLiveQuery
Returns a reactive object with getter properties:
```ts
// Query function — access via dot notation
const query = useLiveQuery((q) => q.from({ todo: todoCollection }))
// query.data, query.isLoading, query.status, etc.
// With reactive deps — use GETTER FUNCTIONS
let minPriority = $state(5)
const query = useLiveQuery(
(q) =>
q
.from({ todo: todoCollection })
.where(({ todo }) => gt(todo.priority, minPriority)),
[() => minPriority],
)
// Config object
const query = useLiveQuery({
query: (q) => q.from({ todo: todoCollection }),
gcTime: 60000,
})
// Pre-created collection
const query = useLiveQuery(preloadedCollection)
```
## Svelte-Specific Patterns
### Destructuring with $derived
```ts
// WRONG — breaks reactivity
const { data, isLoading } = useLiveQuery(...)
// CORRECT — use dot notation
const query = useLiveQuery(...)
// Access: query.data, query.isLoading
// CORRECT — wrap with $derived if you need destructuring
const query = useLiveQuery(...)
const { data, isLoading } = $derived(query)
```
### Props in dependency arrays
```svelte
<script lang="ts">
let { userId }: { userId: number } = $props()
const todosQuery = useLiveQuery(
(q) => q.from({ todo: todoCollection })
.where(({ todo }) => eq(todo.userId, userId)),
[() => userId]
)
</script>
```
## Includes (Hierarchical Data)
When a query uses includes (subqueries in `select`), each child field is a live `Collection` by default. Subscribe to it with `useLiveQuery` in a subcomponent:
```svelte
<!-- ProjectList.svelte -->
<script lang="ts">
import { useLiveQuery, eq } from "@tanstack/svelte-db"
import IssueList from "./IssueList.svelte"
const projectsQuery = useLiveQuery((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 })),
}))
)
</script>
{#each projectsQuery.data as project (project.id)}
<div>
{project.name}
<IssueList issuesCollection={project.issues} />
</div>
{/each}
```
```svelte
<!-- IssueList.svelte — subscribes to the child Collection -->
<script lang="ts">
import { useLiveQuery } from "@tanstack/svelte-db"
let { issuesCollection } = $props()
const issuesQuery = useLiveQuery(issuesCollection)
</script>
{#each issuesQuery.data as issue (issue.id)}
<li>{issue.title}</li>
{/each}
```
With `toArray()`, child results are plain arrays and the parent re-emits on child changes:
```ts
import { toArray, eq } from '@tanstack/svelte-db'
const projectsQuery = useLiveQuery((q) =>
q.from({ p: projectsCollection }).select(({ p }) => ({
id: p.id,
name: p.name,
issues: toArray(
q
.from({ i: issuesCollection })
.where(({ i }) => eq(i.projectId, p.id))
.select(({ i }) => ({ id: i.id, title: i.title })),
),
})),
)
// project.issues is a plain array — no subcomponent needed
```
See db-core/live-queries/SKILL.md for full includes rules (correlation conditions, nested includes, aggregates).
## Common Mistakes
### CRITICAL Passing values instead of getter functions in deps
Wrong:
```ts
let filter = $state('active')
const query = useLiveQuery(
(q) =>
q
.from({ todo: todoCollection })
.where(({ todo }) => eq(todo.status, filter)),
[filter],
)
```
Correct:
```ts
let filter = $state('active')
const query = useLiveQuery(
(q) =>
q
.from({ todo: todoCollection })
.where(({ todo }) => eq(todo.status, filter)),
[() => filter],
)
```
In Svelte 5, deps must be getter functions. Passing values directly captures them at creation time — changes won't trigger re-execution.
Source: docs/framework/svelte/overview.md
### HIGH Direct destructuring breaks reactivity
Wrong:
```ts
const { data, isLoading } = useLiveQuery((q) =>
q.from({ todo: todoCollection }),
)
```
Correct:
```ts
const query = useLiveQuery((q) => q.from({ todo: todoCollection }))
// Use query.data, query.isLoading
```
Direct destructuring captures values at creation time. Use dot notation or wrap with `$derived`.
Source: packages/svelte-db/src/useLiveQuery.svelte.ts
See also: db-core/live-queries/SKILL.md — for query builder API.
See also: db-core/mutations-optimistic/SKILL.md — for mutation patterns.Colle ce Markdown dans ton agent ou utilise les boutons ci-dessus pour l’écrire dans ton projet.
Ce que fait Svelte DB (TanStack)
Applique les pratiques du skill svelte-db__tanstack-db__packages-svelte-db-skills-00151411e7a8.
Comment utiliser Svelte DB (TanStack)
1
Copie le prompt
Un clic copie le prompt packagé (ou l'envoie à ton agent).
2
L'agent installe le skill
Il ajoute le SKILL.md et ses ressources à ton projet.
3
Activation automatique
Le skill s'active dès que le contexte correspond.
Déclencheurs pour Svelte DB (TanStack)
Dis simplement à ton agent quelque chose comme :
Applique le skill svelte-db__tanstack-db__packages-svelte-db-skills-00151411e7a8 à cette tâche
Utilise svelte-db__tanstack-db__packages-svelte-db-skills-00151411e7a8 pour améliorer cette implémentation
Passe en revue ce sujet avec svelte-db__tanstack-db__packages-svelte-db-skills-00151411e7a8
Skills liés à Svelte DB (TanStack)
Acceleration (Microsoft)
Compare synthetic acceleration options and clearly separate scenario value from forecast commitments.Account Overview (Microsoft)
Create a synthetic Acme account overview and identify evidence that merits seller attention.Acroform Writer (Microsoft)
Use this skill whenever the user wants values written INTO an existing PDF form that lives in the connected SharePoint knowledge source — filling out, completing, populating, or submitting a fillable PDF (application, intake sheet, contract, government form) from data they supply, a spreadsheet row, or the conversation. Triggers include "fill out the job application form", "complete the intake form for [person]", "populate our standard NDA template", and "make this ready to send / non-editable" (flatten). The source form should be found via knowledge search; only ask the user to upload it if knowledge search turns up nothing plausible. different task), and do NOT use it on scanned/image-only PDFs that have no real fillable fields — those need OCR or manual overlay instead, which this skill explicitly detects and reports rather than silently failing.