pinia-colada-skilld
БесплатноБез исполняемых скриптовНе проверенData fetching layer for Vue built on Pinia. Use when writing, debugging, or reviewing code that imports @pinia/colada (pinia colada), including useQuery…
от skilld-dev★ 188 звёзд на GitHubОб этом скилле
@pinia/colada 1.4.5
The smart data fetching layer for Vue.js, built on Pinia. Queries read and cache
data (useQuery), mutations write data (useMutation), everything lives in
Pinia stores (useQueryCache, useMutationCache).
- Docs: https://pinia-colada.esm.dev
- API types:
dist/index.d.mtsin the prepared package source - Runtime exports:
dist/index.mjs:1487 - Peers:
vue ^3.5.41,pinia ^2.2.6 || ^3.0.0 || ^4.0.2(pinia 4 allowed since 1.4.1,package.json:91-94) - Bundled codemods:
codemods/rules/*.yamlin the package
Setup
npm install pinia @pinia/colada
import { createPinia } from 'pinia'
import { PiniaColada } from '@pinia/colada'
const app = createApp(App)
app.use(createPinia())
// install after pinia; the options object is required for correct typing
app.use(PiniaColada, {
queryOptions: { staleTime: 60_000 },
plugins: [],
})
Global options go under queryOptions / mutationOptions (dist/index.d.mts:1601-1618).
Mental model
- A query is identified by its
key: a JSON-serializable array (EntryKey,dist/index.d.mts:119). Keys are hierarchical:{ key: ['todos'] }also matches['todos', { filter: 'done' }]when filtering. statusis the data status:'pending' | 'success' | 'error'.asyncStatusis the operation status:'idle' | 'loading'. They are separate on purpose (https://pinia-colada.esm.dev/guide/queries.md).- Defaults:
staleTime: 5000,gcTime: 300_000,refetchOnMount,refetchOnWindowFocus,refetchOnReconnect,enabled: true(dist/index.mjs:92-97). MutationgcTimedefault is60_000(dist/index.d.mts:1379).
Core patterns
Basic query
<script setup lang="ts">
import { useQuery } from '@pinia/colada'
const { state, asyncStatus } = useQuery({
key: ['todos'],
query: () => fetch('/api/todos').then(res => res.json()),
})
</script>
<template>
<div v-if="state.status === 'pending'">Loading...</div>
<div v-else-if="state.status === 'error'">{{ state.error.message }}</div>
<ul v-else>
<li v-for="todo in state.data" :key="todo.id">{{ todo.text }}</li>
</ul>
</template>
Use the grouped state object for type narrowing in templates. TypeScript
cannot narrow separate data / error refs from status
(https://pinia-colada.esm.dev/guide/queries.md).
Reactive keys: pass a getter
Everything the query function reads (route params, refs) must be in the key.
Pass key as a getter so the query refetches when dependencies change:
const { data } = useQuery({
key: () => ['contacts', route.params.id as string],
query: () => fetch(`/api/contacts/${route.params.id}`).then(r => r.json()),
})
Guard queries with enabled
Prevent invalid fetches when a required param is absent (common in stores and global queries):
useQuery({
key: () => ['decks', route.params.deckId],
query: () => fetchDeck(route.params.deckId as string),
enabled: () => 'deckId' in route.params,
})
Type-safe shared options: defineQueryOptions
export const todoOptions = defineQueryOptions((id: string) => ({
key: ['todos', id],
query: () => fetchTodo(id),
}))
// single-function form; the returned key is tagged so queryCache infers TData
const { data } = useQuery(() => todoOptions(route.params.id as string))
const todo = queryCache.getQueryData(todoOptions('1').key) // typed
useQuery accepts options or a getter returning options
(dist/index.d.mts:733). Since 1.0 the two-parameter form
useQuery(options, paramsGetter) is removed; see
references/migration.md.
Shared query state: defineQuery
Wrap queries used by multiple components so refs are created once, like a tiny Pinia store. The setup function must be synchronous:
export const useFilteredTodos = defineQuery(() => {
const search = ref('')
const query = useQuery({
key: () => ['todos', { search: search.value }],
query: () => fetchTodos(search.value),
})
return { ...query, search }
})
Details: references/queries.md.
Mutation + invalidation
const queryCache = useQueryCache()
const { mutate, isLoading } = useMutation({
mutation: (text: string) => createTodo(text),
async onSettled() {
await queryCache.invalidateQueries({ key: ['todos'] })
},
})
mutate(vars)never rejects; use it in templates and event handlers.mutateAsync(vars)returns a promise and rejects on failure.- Put
onMutatebeforemutationin the options object so its returned context is inferred in later hooks (dist/index.d.mts:1410-1433). - Optimistic updates: write to the cache in
onMutate, roll back inonErroronly if the cache still holds your optimistic value. Full pattern in references/mutations.md.
Queries have no onSuccess/onError
This is intentional: a query can have many watchers. Use watch(data, ...),
or global hooks via `PiniaColadaQuery
Установить pinia-colada-skilld в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл pinia-colada-skilld?
Data fetching layer for Vue built on Pinia. Use when writing, debugging, or reviewing code that imports @pinia/colada (pinia colada), including useQuery, useMutation, useInfiniteQuery, defineQuery, query cache invalidation, optimistic updates, plugins, SSR, or migrating from older versions. Provides current 1.4.x APIs, patterns, and migration rules.
Как установить скилл pinia-colada-skilld?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл pinia-colada-skilld запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
skill-creator
Create new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an…
от Anthropicdiscernment-nudge
After you give a substantive answer or draft that the user may act on — advice or recommendations, drafted artifacts such as goals, plans, pitches, proposals…
от Anthropicdata-consolidate
Joins the plant's scheduled exports and connector data into one working dataset — ERP items (NetSuite or Infor M3), sales orders, production work orders…
от Anthropicinspection-to-capa
Runs the quality chain end to end: writes the nonconformance against the requirement it violates, searches history at the moment of writing to say whether…
от Anthropic