Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Pagination Patterns?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/ansh44233-pagination-patterns)
---
description: Paginate lists and APIs with cursors or keys, stable ordering and bounded page sizes
profile: standard
tags: api, database, performance
---
# Pagination patterns
Unbounded lists are outages waiting for data growth.
## Choose a strategy
- **Cursor/keyset** (`WHERE (created_at, id) < (?, ?) ORDER BY created_at DESC, id DESC LIMIT n`) for feeds and large tables: fast at any depth and stable under inserts.
- **Offset** only for small tables or when users need page numbers.
## Rules
- Always order by a unique key (add `id` as a tie-breaker).
- Enforce a maximum page size server-side; default to a sensible small one.
- Return an opaque `next_cursor` (base64 of the sort keys), not raw SQL values clients may tamper with.
- Index the sort columns in the same order.
## Verify
A test inserts rows while paging through and asserts no row is skipped or duplicated; `EXPLAIN` shows an index scan for a deep page.