Automated summary
This skill provides API pagination implementation patterns (offset, cursor, keyset) including filtering, sorting and page metadata, in TypeScript/Express and Spring Boot.
Strengths
- Demonstrates the cursor pattern with a limit+1 fetch to compute hasMore without COUNT(*)
- Covers offset, cursor and keyset with a comparison table of pros, cons and use cases
- Ships concrete anti-patterns (no max page size, COUNT on huge tables, missing default sort) and a production checklist
- Examples are directly copy-pasteable for Express/Prisma and Spring Boot Pageable
Limitations
- Examples are tied to Prisma and Spring Data, so other ORMs or databases require adaptation
- The simple id cursor does not handle multi-column sorting or opaque encoded cursors
- Does not address frontend infinite scroll UI or database query optimization, which it explicitly delegates to other skills
Use it when designing or fixing a paginated list endpoint with filters and sorting.
Avoid it for building infinite scroll UI on the frontend or for optimizing SQL/ORM queries.
Security analysis
SafeThe skill contains only pagination guidance and illustrative code snippets. It does not instruct destructive actions, secret exfiltration, obfuscated execution, or disabling safety controls. The declared tools are appropriate for a documentation/code-reference skill, and there is no meaningful execution risk.
No concerns found
How this analysis is madeExamples
Add cursor-based pagination to my GET /api/posts endpoint in Express with Prisma, capping the page size and returning nextCursor and hasMore without a total count.Our /api/orders endpoint uses offset pagination on a table with 5 million rows and is slow — review it and switch to keyset pagination with a stable default sort.Implement a paginated /api/products endpoint that supports category, minPrice/maxPrice and search filters plus configurable sort and order, with proper page metadata.name: pagination description: | 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", "list endpoint"
DO NOT USE FOR: frontend infinite scroll UI - use frontend framework skills; database query optimization - use database skills allowed-tools: Read, Grep, Glob, Write, Edit
Pagination
Cursor-Based (recommended for large datasets)
app.get('/api/products', async (req, res) => {
const limit = Math.min(parseInt(req.query.limit as string) || 20, 100);
const cursor = req.query.cursor as string | undefined;
const where: any = {};
if (cursor) {
where.id = { gt: cursor };
}
const items = await db.product.findMany({
where,
take: limit + 1, // Fetch one extra to check hasMore
orderBy: { id: 'asc' },
});
const hasMore = items.length > limit;
if (hasMore) items.pop();
res.json({
data: items,
pagination: {
hasMore,
nextCursor: hasMore ? items[items.length - 1].id : null,
},
});
});
Offset-Based (simple, good for small datasets)
app.get('/api/products', async (req, res) => {
const page = Math.max(parseInt(req.query.page as string) || 1, 1);
const limit = Math.min(parseInt(req.query.limit as string) || 20, 100);
const offset = (page - 1) * limit;
const [items, total] = await Promise.all([
db.product.findMany({ skip: offset, take: limit, orderBy: { createdAt: 'desc' } }),
db.product.count(),
]);
res.json({
data: items,
pagination: {
page, limit, total,
totalPages: Math.ceil(total / limit),
hasMore: offset + items.length < total,
},
});
});
Filtering and Sorting
app.get('/api/products', async (req, res) => {
const { sort = 'createdAt', order = 'desc', category, minPrice, maxPrice, search } = req.query;
const where: any = {};
if (category) where.category = category;
if (minPrice || maxPrice) {
where.price = {};
if (minPrice) where.price.gte = parseFloat(minPrice as string);
if (maxPrice) where.price.lte = parseFloat(maxPrice as string);
}
if (search) where.name = { contains: search, mode: 'insensitive' };
const items = await db.product.findMany({
where,
orderBy: { [sort as string]: order },
take: limit,
skip: offset,
});
res.json({ data: items, pagination: { /* ... */ } });
});
Spring Boot (Pageable)
@GetMapping("/products")
public Page<ProductDto> list(
@RequestParam(defaultValue = "0") int page,
@RequestParam(defaultValue = "20") int size,
@RequestParam(defaultValue = "createdAt,desc") String[] sort) {
Pageable pageable = PageRequest.of(page, Math.min(size, 100),
Sort.by(Sort.Direction.fromString(sort[1]), sort[0]));
return productRepo.findAll(pageable).map(mapper::toDto);
}
Comparison
| Strategy | Pros | Cons | Best For | |----------|------|------|----------| | Offset | Simple, jump to page | Slow on large tables, skip drift | Admin panels, small datasets | | Cursor | Fast, stable with inserts | Can't jump to page N | Feeds, infinite scroll, large datasets | | Keyset | Fast, no skip drift | Complex multi-column sort | Time-series, ordered data |
Anti-Patterns
| Anti-Pattern | Fix |
|--------------|-----|
| No max page size | Cap limit (e.g., max 100) |
| COUNT(*) on huge tables | Use cursor pagination, skip total count |
| Offset on millions of rows | Use cursor or keyset pagination |
| Returning all fields | Select only needed fields, support fields param |
| No default sorting | Always define default sort for stable results |
Production Checklist
- [ ] Maximum page size enforced (e.g., 100)
- [ ] Default sort order defined
- [ ] Cursor pagination for large/growing datasets
- [ ] Input validation on page/limit/sort params
- [ ] Consistent response envelope (
data,pagination)
From the file to a first result
The download contains exactly the content displayed on this page. This copy may differ from the latest version in the source repository.
View the source and supporting filesThis download contains SKILL.md only. Any scripts, references, templates and dependencies are not included. Get the required files from the source, preserving their directory structure, before continuing.
1. Download the file
Download SKILL.mdFrom the root of a test project, save the file as .skill-downloads/api-pagination-patterns-mrwakb69/SKILL.md, or use the command below. This folder is for inspecting the skill before installation.
Command for macOS/Linux or WSL: requires a POSIX shell and curl. On Windows without WSL, use the download button and create the folder manually.
mkdir -p '.skill-downloads/api-pagination-patterns-mrwakb69' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/api-pagination-patterns-mrwakb69/download' --output '.skill-downloads/api-pagination-patterns-mrwakb69/SKILL.md.part' && mv '.skill-downloads/api-pagination-patterns-mrwakb69/SKILL.md.part' '.skill-downloads/api-pagination-patterns-mrwakb69/SKILL.md'2. Check prerequisites
Read SKILL.md before using it. If it references scripts or external services, inspect them and prepare the required access in your test environment.
Tools declared by the author (check availability in your agent): Read, Grep, Glob, Write, Edit
No recognized prerequisites section in this file. This does not mean it is self-contained: libraries, tools and access requirements may be mentioned elsewhere in the content or source repository.
The platforms on this page are catalog indications. The paths below follow tool documentation; they do not prove this skill has been run in those tools. No minimum tool version is confirmed for this listing.
3. Load the skill
After inspection, copy the complete folder into your project using one of the commands below, then open a new tool session. The command stops if a folder with the same name already exists: compare the files before replacing it.
Claude Code
test -f '.skill-downloads/api-pagination-patterns-mrwakb69/SKILL.md' && test -s '.skill-downloads/api-pagination-patterns-mrwakb69/SKILL.md' && mkdir -p '.claude/skills' && test ! -e '.claude/skills/pagination' && cp -R '.skill-downloads/api-pagination-patterns-mrwakb69' '.claude/skills/pagination'Cursor
test -f '.skill-downloads/api-pagination-patterns-mrwakb69/SKILL.md' && test -s '.skill-downloads/api-pagination-patterns-mrwakb69/SKILL.md' && mkdir -p '.cursor/skills' && test ! -e '.cursor/skills/pagination' && cp -R '.skill-downloads/api-pagination-patterns-mrwakb69' '.cursor/skills/pagination'Codex
test -f '.skill-downloads/api-pagination-patterns-mrwakb69/SKILL.md' && test -s '.skill-downloads/api-pagination-patterns-mrwakb69/SKILL.md' && mkdir -p '.agents/skills' && test ! -e '.agents/skills/pagination' && cp -R '.skill-downloads/api-pagination-patterns-mrwakb69' '.agents/skills/pagination'OpenSkills
OpenSkills must already be installed. The local install/read procedure is checked with OpenSkills 1.5.0, which requires Node.js ≥ 20.6.0. Catalog slugs are not resolved automatically.
Official OpenSkills installationopenskills install './.skill-downloads/api-pagination-patterns-mrwakb69'openskills read 'api-pagination-patterns-mrwakb69'Reading should display the installed file content and its base directory. It does not run the skill or install its dependencies.
For an agent that reads AGENTS.md, then sync the index. This command changes AGENTS.md: review the diff before using it.
openskills syncManual method or another tool: attach SKILL.md to a conversation, or open it in an agent that can read files. Include any required supporting resources. No universal folder is recognized by every tool.
4. Try a first task
Use a short, synthetic input: an API endpoint, a small document or an interface brief. In a new conversation, attach the file or give the agent its path, then adapt this request:
Read .skill-downloads/api-pagination-patterns-mrwakb69/SKILL.md and apply its instructions to this example: [describe a test input]. Identify any missing files, dependencies or access. Produce the result requested by the skill without inventing data or running unreviewed scripts.Expected result: output matching the skill instructions, or a precise list of missing prerequisites. A read confirmation alone does not validate a first use. If an external resource is unavailable, that path remains untested.
React Hook Form Best Practices
Development
Master React Hook Form: avoid anti-patterns, manage subscriptions, and handle reset, dirty state, and controlled inputs correctly.
Emotion to Mantine Migration
Development
Migrate Emotion styled-components to Mantine components with style props and CSS modules. Use when converting .styled.tsx files or removing @emotion imports.
Scope Creep Detector
Development
Analyzes git diffs against a stated intent to detect scope creep, unrelated files, broad PRs, and oversized changes, then suggests keep, split, or justify actions.