Solid reference implementation covering the three main pagination patterns you'll actually need in production. Offset/limit for simple cases, cursor-based for infinite scroll and real-time feeds, and keyset for performant queries on large datasets. The comparison table is helpful for choosing between them, and the examples show practical details like encoding cursors in base64, capping page sizes at 100, and avoiding expensive count queries. If you've ever written the same pagination logic three times across different projects or shipped offset pagination that crawled to a halt at page 500, this gives you patterns worth copying.

skills.sh installs
433
GitHub stars
248
last updated
Aug 21, 2026

Install

$ npx -y skills add secondsky/claude-skills --skill api-pagination --agent claude-code

Installs into .claude/skills of the current project.

Files

API Pagination

Implement scalable pagination strategies for handling large datasets efficiently.

Pagination Strategies

StrategyBest ForPerformance
Offset/LimitSmall datasets, simple UIO(n)
CursorInfinite scroll, real-timeO(1)
KeysetLarge datasetsO(1)

Offset Pagination

app.get('/products', async (req, res) => {
  const page = parseInt(req.query.page) || 1;
  const limit = Math.min(parseInt(req.query.limit) || 20, 100);
  const offset = (page - 1) * limit;

  const [products, total] = await Promise.all([
    Product.find().skip(offset).limit(limit),
    Product.countDocuments()
  ]);

  res.json({
    data: products,
    pagination: {
      page,
      limit,
      total,
      totalPages: Math.ceil(total / limit)
    }
  });
});

Cursor Pagination

app.get('/posts', async (req, res) => {
  const limit = 20;
  const cursor = req.query.cursor;

  const query = cursor
    ? { _id: { $gt: Buffer.from(cursor, 'base64').toString() } }
    : {};

Sponsors

Details

Repository
github.com/secondsky/claude-skills
Categories
Backend & APIs, Databases
First seen
Jun 3, 2026

More from secondsky/claude-skills

All 146
1sanjay3290 avatarmysqlsanjay3290/ai-skillsExecute read-only SQL queries against multiple MySQL databases. Use when: (1) querying MySQL databases, (2) exploring database schemas/tables, (3) running SELEC430skills.sh installs
2jezweb avatarfirebase-firestorejezweb/claude-skillsBuild with Firestore NoSQL database - real-time sync, offline support, and scalable document storage. Use when: creating collections, querying documents, settin426skills.sh installs
3personamanagmentlayer avatarpostgresql-expertpersonamanagmentlayer/pclExpert-level PostgreSQL database administration, advanced queries, performance tuning, and production operations425skills.sh installs
4wispbit-ai avatarpostgresql-expert-best-practices-code-reviewwispbit-ai/skillsPostgreSQL database design, migration, and performance optimization best practices. This skill should be used when writing, reviewing, or refactoring database s390skills.sh installs
5patricio0312rev avatarauth-security-reviewerpatricio0312rev/skillsReviews authentication and authorization implementation for session management, CSRF, cookie security, and auth flow vulnerabilities with findings, severity ass352skills.sh installs
6memtensor avatarmemos-cloud-servermemtensor/memos-cloud-skillExternal long-term memory and knowledge base backed by the MemOS Cloud API. Capabilities — search prior memory, add conversation messages, delete or correct mem336skills.sh installs