tinybase

作为 TinyBase 专家,帮助开发者构建面向本地优先的响应式数据存储应用,支持离线能力、结构化表格、自动响应性、基于 CRDT 的同步以及持久化到 IndexedDB/SQLite/Postgres,并可进行关系建模,提供无需自定义后端即可跨设备同步的完整客户端数据库方案。

仓库最近推送
GitHub Stars
219
Forks
38
Issues / PRs
7

安装方式

先用 Prompt 核对来源与依赖。也可下载安装包。

用 AI 助手安装

复制提示词,让助手先核对固定版本和依赖。

查看 Prompt收起 Prompt
先检查当前 Agent 是否已安装 SkillPI Skill Finder。如果尚未安装,请按官方仓库的说明安装并启用:https://github.com/Findskills/skillpi。然后使用 Skill Finder 打开此 SkillPI 详情页并定位 "tinybase":https://skillpi.com/zh/skills/deepskill-8b6c706f135afcdfcc1791a8f33a6208204d7b9550d297824bc0d4df460652e4。安装前核对上游来源和版本:https://github.com/TerminalSkills/skills。来源不一致时停止并说明差异。核对通过后,用 Skill Finder 安装目标 Skill,并报告安装路径和来源版本。

来源与配置

github.com

配置方式待核实

请查看原始来源中的适用工具、依赖和权限要求。

安装实测待补充

作为 TinyBase 专家,帮助开发者构建面向本地优先的响应式数据存储应用,支持离线能力、结构化表格、自动响应性、基于 CRDT 的同步以及持久化到 IndexedDB/SQLite/Postgres,并可进行关系建模,提供无需自定义后端即可跨设备同步的完整客户端数据库方案。

0 下载

介绍来源: third_party · TerminalSkills · 1.0.0 参考来源

SkillPi 解读

实测状态
未测试

文件浏览

在原站浏览文件 ↗

原始 SKILL.md

打开原文 ↗
Frontmatter
name: tinybase
description: >-
  You are an expert in TinyBase, the reactive data store for local-first
  applications. You help developers build offline-capable apps with structured
  tables, automatic reactivity, CRDT-based sync, persistence to
  IndexedDB/SQLite/Postgres, and relationship modeling — providing a complete
  client-side database that syncs across devices without a custom backend.
license: Apache-2.0
compatibility: ''
metadata:
  author: terminal-skills
  version: 1.0.0
  category: Frontend Development
  tags:
    - state-management
    - reactive
    - local-first
    - sync
    - crdt
    - offline
    - database

TinyBase — Reactive Data Store for Local-First Apps

You are an expert in TinyBase, the reactive data store for local-first applications. You help developers build offline-capable apps with structured tables, automatic reactivity, CRDT-based sync, persistence to IndexedDB/SQLite/Postgres, and relationship modeling — providing a complete client-side database that syncs across devices without a custom backend.

Core Capabilities

Store

import { createStore, createQueries, createRelationships } from "tinybase";
import { createLocalPersister } from "tinybase/persisters/persister-browser";

// Create store with tables
const store = createStore()
  .setTablesSchema({
    todos: {
      text: { type: "string" },
      done: { type: "boolean", default: false },
      priority: { type: "number", default: 0 },
      categoryId: { type: "string" },
    },
    categories: {
      name: { type: "string" },
      color: { type: "string" },
    },
  });

// Add data
store.setRow("todos", "t1", { text: "Build app", done: false, priority: 1, categoryId: "c1" });
store.setRow("todos", "t2", { text: "Ship it", done: false, priority: 2, categoryId: "c1" });
store.setRow("categories", "c1", { name: "Work", color: "#3b82f6" });

// Queries
const queries = createQueries(store);
queries.setQueryDefinition("activeTodos", "todos",
  ({ select, where, order }) => {
    select("text");
    select("priority");
    where("done", false);
    order("priority", true);              // Descending
  },
);

// Relationships
const relationships = createRelationships(store);
relationships.setRelationshipDefinition("todoCategory", "todos", "categories", "categoryId");

// Reactivity — listener fires on any change
store.addRowListener("todos", null, (store, tableId, rowId) => {
  console.log(`Todo ${rowId} changed:`, store.getRow(tableId, rowId!));
});

// Persist to IndexedDB
const persister = createLocalPersister(store, "my-app");
await persister.startAutoLoad();          // Load on startup
await persister.startAutoSave();          // Save on every change

React Integration

import { Provider, useRow, useTable, useResultTable, useCell } from "tinybase/ui-react";

function App() {
  return (
    <Provider store={store} queries={queries}>
      <TodoList />
    </Provider>
  );
}

function TodoList() {
  const activeTodos = useResultTable("activeTodos");  // Auto-updates on data change
  return (
    <ul>
      {Object.entries(activeTodos).map(([id, todo]) => (
        <TodoItem key={id} id={id} />
      ))}
    </ul>
  );
}

function TodoItem({ id }: { id: string }) {
  const done = useCell("todos", id, "done");          // Subscribes to single cell
  const text = useCell("todos", id, "text");
  return (
    <li onClick={() => store.setCell("todos", id, "done", !done)}
      style={{ textDecoration: done ? "line-through" : "none" }}>
      {text}
    </li>
  );
}

CRDT Sync

import { createWsSynchronizer } from "tinybase/synchronizers/synchronizer-ws-client";
import { createMergeableStore } from "tinybase";

// Mergeable store (CRDT-based, conflict-free)
const store = createMergeableStore();

// Sync via WebSocket
const synchronizer = createWsSynchronizer(store, new WebSocket("wss://sync.example.com"));
await synchronizer.startSync();

// Now any device with the same store syncs automatically
// Offline changes merge cleanly when reconnected

Installation

npm install tinybase

Best Practices

  1. Local-first — Data lives on the client; works offline, syncs when online; instant UI responses
  2. Fine-grained reactivity — Use useCell for single value subscriptions; only re-renders what changed
  3. CRDT sync — Use MergeableStore for multi-device sync; conflicts resolve automatically
  4. Queries — Define queries with select/where/order; reactive, auto-update when underlying data changes
  5. Relationships — Model foreign keys with setRelationshipDefinition; navigate between tables
  6. Persistence — Auto-save to IndexedDB, SQLite (via OPFS), or remote Postgres; seamless persistence
  7. Tiny bundle — Core is ~5KB gzipped; add only the modules you need (queries, relationships, sync)
  8. Schema validation — Define table schemas for type safety; rejects invalid data at write time

当前收录版本

1.0.0

核对来源版本 ↗

质量评测

满分100 · 来自 SkillPi LAB 实验室的评测报告。

场景价值92/100

亮点

  • TinyBase 提供完整的本地优先数据库解决方案,涵盖数据存储、响应式 UI、CRDT 同步和持久化等核心能力
  • 面向前端开发者解决离线应用、跨设备同步等实际痛点,具备高频刚需价值
触发精准95/100

亮点

  • description 明确描述 TinyBase 专家角色,覆盖 'reactive data store'、'local-first'、'CRDT sync' 等核心关键词
  • 触发词精准完整,边界清晰,能有效引导目标用户使用
结构规范90/100

亮点

  • 文档结构清晰,分 Core Capabilities、React Integration、CRDT Sync、Installation、Best Practices 等逻辑章节
  • 提供完整 TypeScript/React 代码示例,步骤明确,frontmatter 信息完整
执行可靠88/100

亮点

  • 提供标准 npm 安装命令,代码示例参数正确,涵盖主要使用场景
  • 无不可逆操作,执行流程可靠
证据可验 (前四项均值)91/100

取前四项原始分值的算术平均,四舍五入取整。可通过收录报告核对各项评分与说明,运行记录需单独查证。

正文静态检测

100 / 100 · skillpi-20261123-no-r3-v1

正文未命中当前规则。

分数仅反映正文中的规则命中,供使用前参考。附件与运行行为不在此评分范围内。

权限与使用前检查

根据当前主文档自动整理,命中内容可能是示例或防护说明;不是实际权限声明,也未覆盖附件、外部依赖或运行行为。

  • 安装或获取外部依赖

    使用官方来源并锁定版本,在隔离环境检查安装脚本。当前文档检查不覆盖后续下载的代码。

    主文档提及 · 第 139 行

本站展示提示不会授予权限。涉及文件改动、密钥、外部发送或费用时,仍由你使用的工具按需确认。

安全评级与访问范围

safe · 静态证据核验,不代表运行安全保证。

使用前请由宿主核对并授权实际文件读写、外部服务和联网目的地;本站的核验不会授予任何运行权限。