Sync Guide

SKILL开发
开发 未标注权限 许可证不明确

Comprehensive guide to building Notion Workers syncs — covers the two-sync architecture (backfill+delta), replace mode, pagination, consistency buffers, pacers, deletion strategies, and common pitfalls. Auto-loads when sync-related work is detected.

一句话选型结论

按资料字段整理

Sync Guide是开发类的 Agent Skill,安装方式:GitHub 仓库,权限级别未标注,许可证不明确,没有现成安装命令,需按说明手动放置 SKILL.md。技能本质是给模型读的说明书,效果取决于模型与客户端;装完先用一个小任务验证,再放进正式流程。

分类开发 安装方式GitHub 仓库 权限级别未标注权限 许可证许可证不明确
累计安装 未标注 本周 未标注
GitHub 星标 未标注 仓库 notion-cookbook
下载量 未标注 技能市场下载数
权限级别 未标注权限 安装前请确认风险范围
许可证 许可证不明确 未说明

安装

GitHub 仓库
在支持 Skills 的客户端里执行,装完问一句「你有哪些技能」验证
  1. 1
    确认客户端支持

    确认你的客户端支持 Skills(Claude、Codex、Cursor 等),并升级到较新的版本。

  2. 2
    拿到技能文件

    按安装说明或仓库 README,把 SKILL.md 放到客户端的 skills 目录(一般一个技能一个文件夹)。

  3. 3
    刷新技能列表

    重新打开客户端,或刷新技能列表,让新放进来的技能被加载。

  4. 4
    验证是否生效

    问一句「你有哪些技能」,确认列表里出现它,再拿一个小任务试跑。

技能档案

开发
字段来自技能仓库与公开索引,中文说明由本站标注
作者 / 维护方makenotion仓库 notion-cookbook · 版本 未标注
宿主客户端未标注技能可被这些客户端加载
安装方式GitHub 仓库安装包 makenotion/notion-cookbook
权限级别未标注权限安装前请确认风险范围
许可证未说明许可证不明确,商用前请自行确认条款
仓库可用性available技能仓库当前是否可访问
最近核验未标注上游最后核验时间 · 数据更新 2026-08-18
正文体量15.1 KBSKILL.md 原文大小,越大说明说明书写得越细

典型使用场景

3 类
按分类整理的常见用法,具体以 SKILL.md 为准
写代码与改 bug

按需求补代码、定位并修掉报错。

读仓库与生成改动

让模型读懂项目结构,再给出可落地的改动。

跑测试与排查故障

按现象排查问题,补测试用例并复跑。

选择建议

装之前先看这几条
按条目字段给出的判断,不替你决定用不用

值得选的地方

  • 基础信息齐全,可以先按说明装一个试试。

先想清楚的地方

  • 没有标注权限级别,实际能做什么要装好后确认。
  • 许可证不明确,商用或二次分发前先到仓库确认条款。
  • 没有现成安装命令,要按安装说明或仓库 README 手动放置。
  • 没有做站内核验,内容以作者仓库为准。
  • 技能只是说明书,实际效果取决于模型与客户端,装完先用小任务试一遍。

更适合

  • 需要在开发场景里给模型补一套做法的人。
  • 愿意先读一遍 SKILL.md、确认它会让模型做什么的人。

不太适合

  • 对许可证要求很严、必须明确可商用的人。
  • 只想装完就自动变强、不打算看说明书的人。

同类对比

6 个同类
同分类里挑最接近的几条,字段以各自详情页为准
技能权限级别安装方式累计安装宿主客户端安装命令
Sync Guide当前 未标注权限 GitHub 仓库 未标注 未标注 无
技能审查员 浏览器控制 ClawHub 市场 877.9 万 OpenClaw 有
Vercel React 最佳实践 浏览器控制 GitHub 仓库 849.1 万 Codex、Claude、Cursor 有
GitHub 代码协作 联网访问 ClawHub 市场 763.3 万 OpenClaw 有
网页设计指南 联网访问 GitHub 仓库 668.6 万 Codex、Claude、Cursor 有
本体论 只读 ClawHub 市场 663.7 万 OpenClaw 有

SKILL.md 全文

15.1 KB
模型实际读到的说明书原文,来自技能仓库

What is a Sync?

A sync is a recurring execute function that returns data changes to populate a Notion database. The runtime calls execute in a loop:

const db = worker.database("myDb", {
  type: "managed",
  initialTitle: "My Data",
  primaryKeyProperty: "ID",
  schema: {
    properties: {
      Name: Schema.title(),
      ID: Schema.richText(),
    },
  },
})

worker.sync("mySync", {
  database: db,
  execute: async (state, { notion }) => ({
    changes: [
      {
        type: "upsert",
        key: "1",
        properties: {
          Name: Builder.title("Item 1"),
          ID: Builder.richText("1"),
        },
      },
    ],
    hasMore: false,
    nextState: undefined,
  }),
})

Each call returns { changes, hasMore, nextState }. If hasMore is true, the runtime calls execute again with nextState. This continues until hasMore is false, completing a cycle. The next cycle begins at the scheduled interval with the state from the end of the previous cycle.

Imports:

import { Worker } from "@notionhq/workers"
import * as Builder from "@notionhq/workers/builder"
import * as Schema from "@notionhq/workers/schema"

Decision Framework

Step 1: Choose an Architecture

The deciding factor is API capability and dataset size. Two tiers:

Condition Architecture
Small source (<1k records) or API with no change tracking Simple replace sync — one sync, mode: &quot;replace&quot;
Everything else (API supports updated_at, change feeds, events) Backfill + delta pair — two syncs writing to the same database

Simple replace sync: One sync returns the full dataset each cycle. After the final hasMore: false, any records not seen are deleted automatically. Use when the dataset is small enough to re-fetch entirely.

Backfill + delta pair: Two syncs share a single database. The backfill sync (mode: &quot;replace&quot;, schedule: &quot;manual&quot;) re-fetches everything when triggered. The delta sync (mode: &quot;incremental&quot;, frequent schedule) fetches only changes since the last run. This separates concerns cleanly — no bi-modal state machine, no backfill-to-delta transition bugs.

Initialize the delta cursor before starting the backfill. When both syncs can
write the same record, include upstreamUpdatedAt on each upsert so a stale
backfill response cannot overwrite a newer delta response.

Step 2: Understand Your API's Pagination

Most APIs require paginating through results. Return batches of ~100 changes. Returning too many changes in one execute call will fail.

Backfill pagination (full dataset load):

  1. Opaque cursor token — GraphQL endCursor, Stripe starting_after
  2. Page number / offset — ?page=N&amp;limit=100
  3. Keyset (timestamp + id) — WHERE created_at &gt; X OR (created_at = X AND id &gt; Y) — the gold standard for timestamp-sorted mutable data

Delta pagination (change-only loads, incremental mode):

  1. Timestamp cursor — ?updated_since=&lt;cursor&gt; with consistency buffer
  2. Keyset on updated_at + id — same keyset pattern on the modification timestamp
  3. Event/changelog feed — GET /events?after=&lt;eventId&gt;
  4. Same opaque cursor — when the API sorts by updated_at, the backfill cursor works for delta too

Step 3: Consistency Buffer (Delta Syncs)

APIs tend to be eventually consistent. A record that was just written or updated may not appear in query results immediately. Since the cursor never resets in incremental mode, if it advances past a record that hasn't been indexed yet, that record is skipped permanently. Lag the cursor 10-60 seconds behind "now":

const bufferMs = 15_000
const maxCursor = new Date(Date.now() - bufferMs).toISOString()
function minTimestamp(a: string, b: string): string {
  return Date.parse(a) &lt;= Date.parse(b) ? a : b
}

const nextCursor =
  records.length &gt; 0 ? minTimestamp(lastRecord.updatedAt, maxCursor) : maxCursor

Step 4: Deletion Strategies

  1. Backfill sync (replace mode): free — unseen records are auto-deleted each cycle. This is the primary mechanism for handling deletes when the API has no delete signal.
  2. Delta sync with delete API: emit { type: &quot;delete&quot;, key } markers. If the delete signal comes from a separate endpoint (audit log, archived filter), use the flip-flop pattern: run the main delta stream until caught up (hasMore: false), then switch to the delete stream for a cycle, then back. Both cursors persist in state independently.
  3. No delete API, large dataset: rely on the backfill sync's replace-mode mark-and-sweep. Trigger the backfill manually or on a slow schedule to clean up stale records.

Replace Mode

Simple: fetch everything, return it all, let the runtime handle deletes. Use as a standalone sync for small sources, or as the backfill half of a backfill+delta pair.

const db = worker.database(&quot;records&quot;, {
  type: &quot;managed&quot;,
  initialTitle: &quot;Records&quot;,
  primaryKeyProperty: &quot;ID&quot;,
  schema: {
    properties: { Name: Schema.title(), ID: Schema.richText() },
  },
})

const apiPacer = worker.pacer(&quot;myApi&quot;, {
  allowedRequests: 10,
  intervalMs: 1000,
})

worker.sync(&quot;recordsBackfill&quot;, {
  database: db,
  mode: &quot;replace&quot;,
  schedule: &quot;manual&quot;, // trigger manually or on a slow schedule
  execute: async (state) =&gt; {
    const page = state?.page ?? 1
    await apiPacer.wait()
    const { items, totalPages } = await fetchPage(page, 100)
    const hasMore = page &lt; totalPages
    return {
      changes: items.map((item) =&gt; ({
        type: &quot;upsert&quot; as const,
        key: item.id,
        properties: {
          Name: Builder.title(item.name),
          ID: Builder.richText(item.id),
        },
      })),
      hasMore,
      nextState: hasMore ? { page: page + 1 } : undefined,
    }
  },
})

See examples/replace-simple.ts and examples/replace-paginated.ts for complete working examples.

Incremental Mode (Delta Sync)

The delta sync fetches only changes since the last run. When paired with a replace-mode backfill sync on the same database, this replaces the old bi-modal single-sync pattern.

// Reuses the same `db` and `apiPacer` from above

worker.sync(&quot;recordsDelta&quot;, {
  database: db,
  mode: &quot;incremental&quot;,
  schedule: &quot;5m&quot;,
  execute: async (state: { cursor: string } | undefined) =&gt; {
    const cursor = state?.cursor ?? new Date(0).toISOString()
    const bufferTs = new Date(Date.now() - 15_000).toISOString()

    await apiPacer.wait()
    // fetchChanges must apply bufferTs as an upstream upper bound.
    const { items, nextCursor } = await fetchChanges(cursor, bufferTs)
    const done = !nextCursor

    return {
      changes: items.map(toUpsert),
      hasMore: !done,
      nextState: {
        // This example assumes nextCursor is an ISO timestamp. Opaque cursors
        // must not be compared with the timestamp buffer.
        cursor: done
          ? minTimestamp(nextCursor ?? cursor, bufferTs)
          : nextCursor,
      },
    }
  },
})

Key points:

  • The delta sync's state is simple — just a cursor. No phase discrimination needed.
  • The backfill sync (replace mode) handles the initial full load and periodic cleanup of deleted records.
  • Both syncs write to the same database via the shared db handle.
  • The pacer is shared between syncs — the server apportions the budget evenly.

See examples/incremental-basic.ts, examples/incremental-bimodal.ts, and examples/incremental-events.ts for complete patterns.

Schema Reference

Define the Notion database shape with Schema types and build values with Builder:

Schema type Builder value Notes
Schema.title() Builder.title(&quot;text&quot;) Primary display field. Every schema needs exactly one.
Schema.richText() Builder.richText(&quot;text&quot;) Text content, IDs
Schema.url() Builder.url(&quot;https://...&quot;) URL field
Schema.email() Builder.email(&quot;a@b.com&quot;) Email field
Schema.phoneNumber() Builder.phoneNumber(&quot;+1...&quot;) Phone field
Schema.checkbox() Builder.checkbox(true) Boolean
Schema.file() Builder.file(&quot;https://...&quot;, &quot;name&quot;) File URL + optional display name
Schema.number() Builder.number(42) Number. Optional format: Schema.number(&quot;percent&quot;)
Schema.date() Builder.date(&quot;2024-01-15&quot;) Date (YYYY-MM-DD). Also: Builder.dateTime(&quot;2024-01-15T10:30:00Z&quot;), Builder.dateRange(start, end)
Schema.select([...]) Builder.select(&quot;Option A&quot;) Single select. Define options: Schema.select([{ name: &quot;A&quot; }, { name: &quot;B&quot; }]). Options must have non-empty name values — Schema.select([]) and { name: &quot;&quot; } are not supported.
Schema.multiSelect([...]) Builder.multiSelect(&quot;A&quot;, &quot;B&quot;) Multi select
Schema.status(...) Builder.status(&quot;Done&quot;) Status with groups
Schema.people() Builder.people(&quot;email@co.com&quot;) People by email
Schema.place() Builder.place({ lat: 40.7, lon: -74.0 }) Geographic location
Schema.relation(&quot;databaseKey&quot;) [Builder.relation(&quot;pk&quot;)] Relation to another managed database. Value is an array.

Relations use the related database key. Two-way relations are configured the same way:

Schema.relation(&quot;otherDatabase&quot;, {
  twoWay: true,
  relatedPropertyName: &quot;Back Link&quot;,
})

Row-level icons and page content:

changes: [
  {
    type: &quot;upsert&quot;,
    key: &quot;1&quot;,
    properties: {
      Name: Builder.title(&quot;Example&quot;),
      // ... other properties ...
    },
    icon: Builder.emojiIcon(&quot;🎯&quot;), // or Builder.notionIcon(&quot;rocket&quot;, &quot;blue&quot;)
    pageContentMarkdown: &quot;## Details\nSome text&quot;, // Markdown body for the page
  },
]

Common Mistakes

  1. Not using a pacer — every API call inside execute should be preceded by await apiPacer.wait(). Without it, syncs will hit rate limits and fail.
  2. Missing consistency buffer on delta syncs — the cursor will permanently skip records not yet indexed in eventually consistent APIs.
  3. Not paginating — returning too many changes at once. Start with batches of ~100.
  4. Using replace mode for large datasets — if the API supports change tracking, pair a replace-mode backfill sync with an incremental delta sync instead of re-fetching everything each cycle.
  5. Cursor that doesn't advance — infinite loop. Ensure nextState changes between iterations.
  6. Forgetting first-run handling — state is undefined on first call. Use state?.cursor ?? null.
  7. Forgetting that backfill + delta share a database — both syncs must use the same worker.database() handle and the same key/properties shape.
  8. Not triggering the backfill sync — the backfill sync with schedule: &quot;manual&quot; won't run automatically. Trigger it on deploy or periodically to clean up deleted records.
  9. Empty select values — Schema.select() requires at least one option with a non-empty name. Schema.select([]) and { name: &quot;&quot; } are not supported.

CLI Commands for Sync Development

# Deploy
ntn workers deploy

# Preview (test without writing)
ntn workers sync trigger &lt;key&gt; --preview
ntn workers sync trigger &lt;key&gt; --preview --context &#x27;&lt;json&gt;&#x27;  # continue pagination

# Trigger a sync run
ntn workers sync trigger &lt;key&gt;

# Check sync status
ntn workers sync status

# View run logs
ntn workers runs list
ntn workers runs list --plain | head -n1 | cut -f1 | xargs -I{} ntn workers runs logs {}

# Reset state (full re-backfill)
ntn workers sync state reset &lt;key&gt;

# Manage secrets
ntn workers env set KEY=value
ntn workers env push

API Patterns Reference

See api-pagination-patterns.md for detailed strategies drawn from production syncs with Salesforce, Stripe, HubSpot, GitHub, and ServiceNow.

常见问题

5 问
答案由本站依据条目字段整理
Sync Guide怎么安装?

没有现成安装命令:按安装说明或仓库 README,把 SKILL.md 放进客户端的 skills 目录(一般一个技能一个文件夹)。

Sync Guide支持哪些客户端?

资料没有标注宿主客户端,但只要客户端支持 Skills(Claude、Codex、Cursor 等),一般都能加载。

Sync Guide权限高吗,安全吗?

权限级别为未标注权限。安装前先看它会读取或写入哪些内容。

Sync Guide收费吗?

本站不代收费用,也没有标注具体价格。是否收费取决于技能本身和所用的模型或客户端,正式使用前按作者说明确认。

Sync Guide用什么许可证?

许可证标注为 未说明(许可证不明确)。商用或二次分发前请到仓库确认条款原文。

热门专题

按场景挑技能
全部专题 →

技能内容以作者仓库为准;分类、权限级别与许可证状态的中文说明为中文整理,最近核验 未标注。