api-pagination · secondsky — Claude Code skill: what it does, how to install
Implements offset, cursor, and keyset pagination for API endpoints. Useful for handling infinite scroll and optimizing collection queries.
npx skills add secondsky/claude-skills --skill api-pagination -a claude-codeWhat api-pagination does
The skill equips the agent with patterns for three pagination types. Offset and limit fit smaller collections with O(n) lookups. For large datasets and infinite scrolling, the skill applies cursor-based navigation with base64 identifiers or keyset pagination to maintain O(1) complexity.
Responses include a structured pagination payload alongside direct navigation links such as first, prev, next, and last. The instructions forbid unbounded page sizes and suggest capping batch limits at 100 items. Omitting indexes on sorted fields will break query efficiency on high-volume tables.
What it helps with
- implement cursor pagination for infinite scrolling feeds
- cap API batch limits to prevent unbounded database queries
- speed up large collection queries without heavy COUNT operations
- generate structured API responses with page metadata and navigation links
Example prompts for the agent
- Create a cursor-based pagination route for posts using base64 tokens
- Add pagination to the /products endpoint with a strict maximum limit of 100
- Set up keyset pagination for our orders database query
How to install api-pagination
1Skills CLI (Vercel)
npx skills add secondsky/claude-skills --skill api-pagination -a claude-code2Manually: put the files in place
~/.claude/skills/api-pagination/SKILL.mdCopy the whole skill folder; for one project use .claude/skills/api-pagination/
1Skills CLI (Vercel)
npx skills add secondsky/claude-skills --skill api-pagination -a codex2Manually: put the files in place
.agents/skills/api-pagination/SKILL.mdFor all projects use ~/.agents/skills/
1Skills CLI (Vercel)
npx skills add secondsky/claude-skills --skill api-pagination -a cursor2Manually: put the files in place
.cursor/skills/api-pagination/SKILL.mdCursor also reads .agents/skills/ and .claude/skills/
1GitHub CLI
gh skill install secondsky/claude-skills api-pagination2Manually: put the files in place
.github/skills/api-pagination/SKILL.md1Skills CLI (Vercel)
npx skills add secondsky/claude-skills --skill api-pagination -a gemini-cli2Platform CLI
gemini skills install https://github.com/secondsky/claude-skills --path plugins/api-pagination/skills/api-paginationManually: put the files in place
.devin/skills/api-pagination/SKILL.mdThe legacy .windsurf/skills/ path still works
Skills CLI (Vercel)
npx skills add secondsky/claude-skills --skill api-pagination -a opencodeClaude.ai
Zip the folder and upload it in Settings → Capabilities → Skills
Step by step, with commands for each platform: How to install skills in Claude Code: five ways
Questions about api-pagination
How to install api-pagination in Claude Code?
Run npx skills add secondsky/claude-skills --skill api-pagination -a claude-code in your terminal.
What does api-pagination do?
It provides code templates and rules for offset, cursor, and keyset pagination strategies. The skill also enforces response standards with links and metadata.
What performance guidelines does the skill enforce?
It requires capping request limits at a safe threshold like 100 and indexing sorting fields. It also advises against executing full count queries on large tables.
Source text
SKILL.md · MIT
---
name: api-pagination
description: Implements efficient API pagination using offset, cursor, and keyset strategies for large datasets. Use when building paginated endpoints, implementing infinite scroll, or optimizing database queries for collections.
license: MIT
---
# API Pagination
Implement scalable pagination strategies for handling large datasets efficiently.
## Pagination Strategies
| Strategy | Best For | Performance |
|----------|----------|-------------|
| Offset/Limit | Small datasets, simple UI | O(n) |
| Cursor | Infinite scroll, real-time | O(1) |
| Keyset | Large datasets | O(1) |
## Offset Pagination
```javascript
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
```javascript
app.get('/posts', async (req, res) => {
const limit = 20;
const cursor = req.query.cursor;
const query = cursor
? { _id: { $gt: Buffer.from(cursor, 'base64').toString() } }
: {};
const posts = await Post.find(query).limit(limit + 1);
const hasMore = posts.length > limit;
if (hasMore) posts.pop();
res.json({
data: posts,
nextCursor: hasMore ? Buffer.from(posts[posts.length - 1]._id).toString('base64') : null
});
});
```
## Response Format
```json
{
"data": [...],
"pagination": {
"page": 2,
"limit": 20,
"total": 150,
"totalPages": 8
},
"links": {
"first": "/api/products?page=1",
"prev": "/api/products?page=1",
"next": "/api/products?page=3",
"last": "/api/products?page=8"
}
}
```
## Best Practices
- Set reasonable max limits (e.g., 100)
- Use cursor pagination for large datasets
- Index sorting fields
- Avoid COUNT queries when possible
- Never allow unlimited page sizes
© secondsky · MIT · secondsky/claude-skills
Similar skills
All skills for Backend and APIs →api-pagination by other authors comes first.