IN

incremental-fetch

Ensures reliable data pipelines using a two-watermark system to prevent duplicates and data gaps.

Install

mkdir -p .claude/skills/incremental-fetch && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/15524" && unzip -o skill.zip -d .claude/skills/incremental-fetch && rm skill.zip

Installs to .claude/skills/incremental-fetch

Activation

This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.

Build resilient data ingestion pipelines from APIs. Use when creating scripts that fetch paginated data from external APIs (Twitter, exchanges, any REST API) and need to track progress, avoid duplicates, handle rate limits, and support both incremental updates and historical backfills. Triggers: 'ingest data from API', 'pull tweets', 'fetch historical data', 'sync from X', 'build a data pipeline', 'fetch without re-downloading', 'resume the download', 'backfill older data'. NOT for: simple one-shot API calls, websocket/streaming connections, file downloads, or APIs without pagination.
591 chars✓ has a “when” triggerlonger than Claude Code's old 250-char listing cap (fine on current versions)
Advanced

Key capabilities

  • Track progress using two watermarks for forward and backward fetching
  • Save data records after each page fetch
  • Update watermarks only at the end of a successful run
  • Handle API rate limits gracefully
  • Adapt to different pagination types like cursor or timestamp

How it works

This skill builds resilient data ingestion pipelines from APIs by using a two-watermark pattern to track progress and manage data fetching.

Inputs & outputs

You give it
A request to ingest paginated data from an external API
You get back
A resilient data ingestion pipeline that avoids duplicates and supports incremental updates and historical backfills

When to use incremental-fetch

  • Ingesting paginated data from REST APIs
  • Syncing tweets or feed data
  • Building a resilient backfill pipeline

About this skill

Incremental Fetch

Build data pipelines that never lose progress and never re-fetch existing data.

The Two Watermarks Pattern

Track TWO cursors to support both forward and backward fetching:

WatermarkPurposeAPI Parameter
newest_idFetch new data since last runsince_id
oldest_idBackfill older datauntil_id

A single watermark only fetches forward. Two watermarks enable:

  • Regular runs: fetch NEW data (since newest_id)
  • Backfill runs: fetch OLD data (until oldest_id)
  • No overlap, no gaps

Critical: Data vs Watermark Saving

These are different operations with different timing:

WhatWhen to SaveWhy
Data recordsAfter EACH pageResilience: interrupted on page 47? Keep 46 pages
WatermarksONCE at end of runCorrectness: only commit progress after full success
fetch page 1 → save records → fetch page 2 → save records → ... → update watermarks

Workflow Decision Tree

First run (no watermarks)?
├── YES → Full fetch (no since_id, no until_id)
└── NO → Backfill flag set?
    ├── YES → Backfill mode (until_id = oldest_id)
    └── NO → Update mode (since_id = newest_id)

Implementation Checklist

  1. Database: Create ingestion_state table (see patterns.md)
  2. Fetch loop: Insert records immediately after each API page
  3. Watermark tracking: Track newest/oldest IDs seen in this run
  4. Watermark update: Save watermarks ONCE at end of successful run
  5. Retry: Exponential backoff with jitter
  6. Rate limits: Wait for reset or skip and record for next run

Pagination Types

This pattern works best with ID-based pagination (numeric IDs that can be compared). For other pagination types:

TypeAdaptation
Cursor/tokenStore cursor string instead of ID; can't compare numerically
TimestampUse last_timestamp column; compare as dates
Offset/limitStore page number; resume from last saved page

See references/patterns.md for schemas and code examples.

When not to use it

  • For simple one-shot API calls
  • For websocket/streaming connections
  • For file downloads

Limitations

  • The skill is not for APIs without pagination
  • The skill focuses on ID-based pagination
  • The skill requires a database for state management

How it compares

This skill implements a persistent fetching pipeline that prevents data loss and re-fetching, which is more reliable than simple API calls.

Compared to similar skills

incremental-fetch side by side with the closest alternatives in the catalog.

SkillInstallsUpdatedSafetyDifficulty
incremental-fetch (this skill)06moNo flagsAdvanced
crawl4ai218moReviewIntermediate
apify94moReviewIntermediate
douyin-scraper-skill03moReviewAdvanced

Try saying

Example prompts that trigger this skill in your AI assistant.

Search skills

Search the agent skills registry