pb-collection
БесплатноБез исполняемых скриптовНе проверенAdd or modify a field on the PocketBase tasks collection end-to-end — schema script, task-mapper, Zod schema, Dexie version bump, migration test. Use when the…
от vscarpenter★ 41 звезда на GitHubОб этом скилле
pb-collection — End-to-end PocketBase tasks-collection field change
This skill walks through every place a field touches when added to the synced tasks collection. Skipping any step has bitten us before — the order matters.
When to invoke
User says any of:
- "Add a
<field>to tasks" - "Sync
<field>across devices" - "PocketBase needs
<field>" - "Update the tasks schema"
Do NOT invoke for local-only Dexie fields (those don't need the PB layers).
Prerequisites — verify before touching code
- Read
.claude/rules/pocketbase-sync.md. The gotchas below are condensed but the source of truth is there. - Confirm the user has the PocketBase admin password handy (needed to run
scripts/setup-pocketbase-collections.sh). - Confirm the field is not a system field name (
id,created,updated,collectionId,collectionName). - Confirm field type is supported by both Dexie and PocketBase:
text,number,bool,json,date. Never userelationto_pb_users_auth_(placeholder doesn't resolve at runtime).
Step order (do not reorder)
1. Update Zod schema — lib/schema.ts
- Add the field to the
taskSchema(andtaskInputSchemaif user-settable). - Use
.safeParse()callers; if this is a user-input path, the schema must already be wired to a safeParse boundary. - For optional fields, default to a sensible value (
.optional().default(...)) so legacy tasks parse without error. - Update both
exportSchema(.strict()) andimportSchema(.strip()).
2. Update task-mapper — lib/sync/task-mapper.ts
- Add the camelCase ↔ snake_case mapping. PocketBase uses snake_case; the app uses camelCase.
- Both directions:
mapToRemote()andmapFromRemote(). - Test the mapper round-trip in
tests/data/task-mapper.test.ts.
3. Update PocketBase collection — scripts/setup-pocketbase-collections.sh
- Add the field to the
taskscollection definition in the script. - If the field needs to be sortable/filterable, add a custom index — but the index must reference the new field, NEVER
createdorupdated. - Run the script against
https://api.vinny.io(requires_superusersadmin auth — endpoint is/api/collections/_superusers/auth-with-password, not/api/admins/). - Verify the field appears in PB admin UI before continuing.
4. Bump Dexie version — lib/db.ts
- Increment the version (read the latest
version(...)call inlib/db.ts;CLAUDE.mdtracks the current number). - Add the field to the relevant table schema.
- If the field is indexed locally, add it to the index list.
- Write a migration block if existing rows need backfill (use
upgrade()callback).
5. Update CRUD — lib/tasks.ts and lib/tasks/crud/
- If the field is settable on create/update, expose it on the input type.
- Default it where appropriate.
6. Update sync engine — lib/sync/pb-sync-engine.ts
- Verify push-side serializes the new field via
task-mapper. - Verify pull-side deserializes it.
- If the field affects LWW conflict resolution, document why in a code comment.
7. Update MCP server — packages/mcp-server/src/tools/
- Add the field to schemas in
tools/schemas/if exposed through MCP tools. - Update handlers in
tools/handlers/to read/write it. - Run
npm run buildinpackages/mcp-server/.
8. Tests — REQUIRED before claiming done
Write or update:
- A schema test under
tests/data/— Zod parse/safeParse with and without the new field. tests/data/sync/task-mapper.test.ts— round-trip mapping.tests/data/db-migrations.test.ts— Dexie version upgrade preserves existing data.tests/data/sync/pb-sync-engine.test.ts(andpb-push/pb-pull) — push/pull serializes the field correctly.tests/data/import.test.tsandtests/data/import-export-sync.test.ts— import (lenient.strip()) accepts old exports without the field; export (strict.strict()) emits it.
Run bun run test -- --coverage and confirm changed-file coverage ≥80%.
9. Verification gate — before declaring done
-
bun typecheckpasses -
bun lintpasses -
bun run testpasses - Created a task with the new field locally, synced to PocketBase, verified field present in PB admin
- Logged out + back in on a second device (or cleared local data and re-pulled), verified field round-trips
- Exported tasks → imported them back → field preserved
- If the field is user-input, verified
safeParserejects bad input with a useful error toast (sonner, notalert())
10. Commit
Conventional commit format: feat(sync): add <field> to tasks collection or feat(schema): .... Bump package.json patch or minor depending on user impact.
Gotchas (condensed — full list in .claude/rules/pocketbase-sync.md)
- Sort/filter restriction — Do not reference
createdorupdatedin PB sort/filter strings. Useclient_updated_at. - Admin endpoint —
/api/collections/_superusers/auth-with-password, not/api/admins/.... - *Relation placeholder
Установить pb-collection в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл pb-collection?
Add or modify a field on the PocketBase tasks collection end-to-end — schema script, task-mapper, Zod schema, Dexie version bump, migration test. Use when the user wants to add/remove/rename a synced task field. Codifies the PocketBase v0.23+ gotchas and recurring step-order mistakes.
Как установить скилл pb-collection?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл pb-collection запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
от Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
от Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
от Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
от Anthropic