Skip to content
Skills Library
Programming · Building & coding

api-pagination-design

/api-pagination-design

Design pagination with cursors for stable ordering, sensible page limits, and awareness of total-count cost. Use when adding pagination to a list endpoint or fixing duplicate or skipped items under load.

Repository
AI-SKILLS ↗
Licence
MIT
Last repository change
05.09.2026

Assessment and security

90/ 100Class: good
Format25 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content25 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene15 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
1
Scripts
0
HTML comments
0
URLs in SKILL.md
0
Deprecation

No signals detected. Repository changed on 05.09.2026, without references to retired models or APIs.

Licence

MIT, open: use and modify while retaining author attribution.

What it does and when to use it

Design pagination with cursors for stable ordering, sensible page limits, and awareness of total-count cost. Use when adding pagination to a list endpoint or fixing duplicate or skipped items under load.

Original author description

Design pagination with cursors for stable ordering, sensible page limits, and awareness of total-count cost. Use when adding pagination to a list endpoint or fixing duplicate or skipped items under load.

How it works

  1. Method
  2. Boundaries
Original SKILL.md headings · 75 lines, 526 words
SKILL.md preview
---
name: api-pagination-design
description: Design pagination with cursors for stable ordering, sensible page limits, and awareness of total-count cost. Use when adding pagination to a list endpoint or fixing duplicate or skipped items under load.
---

# API pagination design

Any list endpoint that can grow needs pagination, and the choice
between cursor and offset determines whether it stays correct as data
changes. Offset pagination is simple and wrong under concurrent
modification; cursor pagination is slightly more work and stable, which
is why serious APIs use it.

## Method

1. **Default to cursor pagination for stability.** A cursor
   encodes "where the last page ended" (an opaque token over
   the sort key); the next page continues from there, so
   inserts and deletes between page fetches do not duplicate
   or skip items. Offset pagination (`LIMIT 20 OFFSET 40`)
   skips or repeats items when rows shift under it (a new
   item at the top pushes everything down a slot): the
   classic "I saw the same item twice while scrolling" bug
   (see the connections pattern in graphql-schema-design).
2. **Base cursors on a stable, unique sort.** The cursor
   must encode a total ordering (a unique column, or a
   composite like `(created_at, id)` to break ties): sorting
   by a non-unique column alone makes the cursor ambiguous
   at boundaries. The sort must be stable across requests
   (see indexing-strategy: the sort column wants an index,
   or every page is a scan).
3. **Set and enforce page-size limits.** A default page size
   and a maximum (reject or clamp larger requests): so a
   client cannot request a million items in one call and
   exhaust the server (see backpressure, request-validation).
   The client asks for a page size within bounds; unbounded
   list endpoints are a denial-of-service and a memory
   problem.
4. **Treat total counts as expensive, make them optional.**
   Counting all matching rows can be as costly as the query
   itself on large tables (a full scan: see
   query-plan-reading); do not compute it on every page by
   default. Offer it as an opt-in, use an estimate where
   exactness is not needed, or provide "has more" (cheaper:
   fetch one extra) instead of a precise total. Many clients
   want "next page" not "page 47 of 3,912".
5. **Return pagination metadata consistently.** A predictable
   envelope: the items, a next-page cursor (null when
   done), and optionally a previous cursor and count (see
   api-error-responses' consistency ethic): so clients page
   uniformly across all your list endpoints. Inconsistent
   pagination shapes across endpoints force per-endpoint
   client code (see api-client-design's auto-pagination
   wrapping this).
6. **Keep cursors opaque and encode direction.** Cursors are
   opaque tokens (base64-encoded position), not exposed
   internal IDs or offsets: so you can change the underlying
   pagination without breaking clients, and clients cannot
   forge or misuse them. Support forward (and backward if
   needed) paging; document that cursors are single-use
   positions, not permanent bookmarks.

## Boundaries

- Offset pagination is acceptable for small, stable, or
  admin datasets where the anomalies do not matter and
  "jump to page N" is a real requirement (cursors cannot
  random-access pages); know the trade and choose per
  endpoint.
- Cursor pagination trades random page access for
  stability; if the product genuinely needs "go to page
  50", that is offset's niche, with its concurrency
  caveats accepted.
- Pagination over changing real-time data is inherently
  imperfect (the data moves under any paging scheme);
  cursors minimize the anomalies but for live feeds
  consider streaming or since-timestamp patterns instead
  (see event-driven-architecture).

Versions

The database has no other skills named api-pagination-design.

Database snapshot: 13.11.2026 · package version 45c5455e186d (SHA-256 digest of the entire package)

Downloads in the last 30 days: 1 · ranking

Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.

Similar skills

  • 100pagination-helper
    Configure with pagination helper operations. Auto-activating skill for API Development. Triggers on: pagination helper, pagination helper Part of the API Development skill category. Use when working with pagination helper functionality. Trigger with phrases like "pagination…
  • 100pagination
    API pagination patterns. Offset-based, cursor-based, keyset pagination. Filtering, sorting, and page metadata. REST and GraphQL pagination implementations. USE WHEN: user mentions "pagination", "paginate", "cursor", "offset", "page size", "next page", "infinite scroll API",…
  • 100pagination-and-sync-engineer
    Designs correct cursor pagination and incremental delta sync against a mutating dataset - cursor contracts, updated_at watermarks, delete propagation, checkpointing, and idempotent reprocessing. Use when someone says "my sync is skipping rows", "should I use cursor or offset…
  • 100api-pagination
    Implements efficient API pagination using offset, cursor, and keyset strategies for large datasets. Use when building paginated endpoints, implementing infinite scroll, or optimizing database queries for collections.
  • 95relay-pagination
    Use when relay pagination with cursor-based pagination, infinite scroll, load more patterns, and connection protocols.
  • 100pagination-and-filtering
    Use when a ticket exposes a list — an API collection endpoint, a table in the UI, an export — with paging, sorting, filtering, or search, and the result must be stable under concurrent writes, bounded in cost, and consistent with the repo's existing list conventions. Invoke for…

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.