From aj-geddes-useful-ai-prompts-4
Implements offset/limit, cursor-based, and keyset pagination strategies for large datasets. Use when returning collections or optimizing query performance.
How this skill is triggered — by the user, by Claude, or both
Slash command
/aj-geddes-useful-ai-prompts-4:api-paginationThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
- [Overview](#overview)
Implement scalable pagination strategies for handling large datasets with efficient querying, navigation, and performance optimization.
Minimal working example:
// Node.js offset/limit implementation
app.get('/api/users', async (req, res) => {
const page = parseInt(req.query.page) || 1;
const limit = Math.min(parseInt(req.query.limit) || 20, 100); // Max 100
const offset = (page - 1) * limit;
try {
const [users, total] = await Promise.all([
User.find()
.skip(offset)
.limit(limit)
.select('id email firstName lastName createdAt'),
User.countDocuments()
]);
const totalPages = Math.ceil(total / limit);
res.json({
data: users,
pagination: {
page,
limit,
total,
totalPages,
hasNext: page < totalPages,
// ... (see reference guides for full implementation)
Detailed implementations in the references/ directory:
| Guide | Contents |
|---|---|
| Offset/Limit Pagination | Offset/Limit Pagination |
| Cursor-Based Pagination | Cursor-Based Pagination |
| Keyset Pagination | Keyset Pagination |
| Search Pagination | Search Pagination |
| Pagination Response Formats | Pagination Response Formats |
| Python Pagination (SQLAlchemy) | Python Pagination (SQLAlchemy) |
npx claudepluginhub joshuarweaver/cascade-code-languages-misc-1 --plugin aj-geddes-useful-ai-prompts-4Implements offset, cursor, and keyset pagination strategies for APIs handling large datasets. Use for paginated endpoints, infinite scroll, or optimizing database collection queries.
Explains offset/limit pagination tradeoffs: page drift, deep offset performance costs, and COUNT(*) overhead. Useful when reviewing PRs, designing list endpoints, or evaluating migration to cursor pagination.
Provides step-by-step guidance and configurations for implementing pagination in API development, covering REST, GraphQL, OpenAPI patterns.