Sync debug

From makenotion/notion-cookbook · View interactive version

Sync debug is an AI agent skill from the GitHub repository makenotion/notion-cookbook. Diagnose a failing or misbehaving sync — fetch run logs, identify errors, cross-reference with code, and suggest fixes

How to use this skill

Skill file

Instructions

Help the user figure out why their sync is failing or producing wrong results. Work through the steps below systematically.

Step 1: Get Current State

Run these commands to understand the situation:

ntn workers sync status

Note which syncs are listed, their status, last run time, and next scheduled run. Look for syncs that are stuck, failing, or haven't run recently.

Step 2: Fetch Recent Runs

ntn workers runs list

Look for runs with non-zero exit codes (shown in red in table output). Note the run IDs for failed runs.

Step 3: Get Logs

For the most recent run (any capability):

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

For the most recent run of a specific sync:

ntn workers runs list --plain | grep <syncKey> | head -n1 | cut -f1 | xargs -I{} ntn workers runs logs {}

Read the full log output. Look for error messages, stack traces, and any console.log output from the sync code.

Step 4: Read the Sync Code

Read src/index.ts (and any imported modules) to understand the sync's logic. Cross-reference the error from the logs with the code.

Step 5: Diagnose

Common failure patterns and their fixes:

API Authentication Errors (401/403)

Rate Limiting (429)

Timeout / Long Execution

Cursor / State Errors

Schema Mismatch

Infinite Loop (sync never completes)

Empty Results

Network / Transient Errors

Step 6: Fix and Verify

After identifying the issue:

  1. Apply the fix to the code
  2. Run npm run check to verify types
  3. If the state shape changed, warn the user they may need ntn workers sync state reset <key> (this triggers a full re-backfill)
  4. Deploy and preview to verify: suggest /sync-preview or run ntn workers deploy && ntn workers sync trigger <key> --preview
  5. When the fix is verified, ntn workers sync trigger <key> to resume
Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.