Skip to content
Back to skills

Pagination Patterns

ASecurity

Paginate lists and APIs with cursors or keys, stable ordering and bounded page sizes

  • 7 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added November 30, 2026
ai-agentssqlapidatabaseperformance

Works with

  • cursor
  • cli
  • api

Security analysis

A100/100

Scanned November 30, 2026

npx -y skills add ansh44233/forge --skill pagination-patterns --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Pagination Patterns?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Pagination Patterns
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/ansh44233-pagination-patterns/badge)](https://www.skillsdirectory.com/skills/ansh44233-pagination-patterns)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
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.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.