api-pagination

api-pagination is a skill for Claude Code from secondsky/claude-skills. It costs 39 tokens per session (546 once invoked), scanned A, original, MIT.

A guide to API pagination, the practice of splitting a large collection of results into smaller responses. It covers page-based, cursor-based, and keyset methods.

In plain words
What is it for?
Use it when building paginated endpoints, loading long lists, supporting infinite scroll, or improving database queries for large collections.
Why use it?
It helps prevent large queries from slowing down an application and supports interfaces such as page navigation and infinite scrolling.

Skill for Claude Code

Written for Claude Code: shipped in a Claude Code plugin.

Part of the api-pagination plugin — 1 skill shipped together

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/secondsky/claude-skills/api-pagination
Any agent
npx skills add secondsky/claude-skills --skill api-pagination
Clone the repo
git clone --depth 1 https://github.com/secondsky/claude-skills

Made for: Claude Code.

Or install api-pagination, the plugin that ships this one along with the rest of its 1 skill.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for api-pagination

README.md
[![agentmods](https://agentmods.dev/badge/skills/secondsky/claude-skills/api-pagination.svg)](https://agentmods.dev/skills/secondsky/claude-skills/api-pagination)
Your own site
<a href="https://agentmods.dev/skills/secondsky/claude-skills/api-pagination"><img src="https://agentmods.dev/badge/skills/secondsky/claude-skills/api-pagination.svg" alt="Measured on agentmods" height="20"></a>
Per session 39 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 546 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00039 $0.00546
Opus 5 $0.00019 $0.00273
Sonnet 5 $0.00008 $0.00109
Haiku 4.5 $0.00004 $0.00055

Measured 6d ago against content hash e41874735760, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-05, from the pricing page.

Security

Grade A, and why

api-pagination scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 6d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

plugins/api-pagination/skills/api-pagination/SKILL.md · 93 lines

What it actually says

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

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() } }
    : {};

  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

{
  "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
Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 6d ago First seen · 93 lines · 39 tokens per session scan A e41874735760

Subscribe to this mod's changes

api-pagination is a skill published in the GitHub repository secondsky/claude-skills (214 stars, last pushed 2d ago), licensed MIT. It adds 39 tokens to every session and 546 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.