agentleFS
gerard-labsgerard-labs/superpowers-api-platform/skills/api-platform-pagination/SKILL.md

api-platform-pagination

Skill2 starsChanged 6 months agoMITView on GitHub

Configure API Platform 4.3 pagination — default page size (30 items in 4.x, not 20), `hydra_prefix: false` shape (`member` / `totalItems` / `view` / `next` keys, no `hydra:` prefix), partial pagination (`paginationPartial: true`) to skip the COUNT on large tables, cursor-based pagination via `paginationViaCursor` paired with UUID v7 / ULID identifiers, `paginationMaximumItemsPerPage` to prevent DoS, fetch-join collection / output walker tuning, custom paginator implementations (`PartialPaginatorInterface`, `PaginatorInterface`, `TraversablePaginator`), and renaming the client parameters via `collection.pagination.{page,items_per_page,enabled,partial}_parameter_name`. Trigger when listing a resource that may grow beyond ~100k rows, when designing infinite-scroll / autocomplete APIs, or when fixing slow `COUNT(*)` queries.

The file

We split this skill into the rules it gives an agent

2 rules. About 0 are common, 1 is distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Default 30 items per page is wrong for your domain (raise or lower it explicitly).

    line 18
  2. Very specific:

    Verify the 4.x defaults: pagination_items_per_page: 30, hydra_prefix: false.

    line 22

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

API Platform 4.3 — Pagination

Use when

  • The collection can grow to millions of rows and COUNT(*) is too expensive.
  • Infinite-scroll / autocomplete needs cursor pagination on a chronologically sortable key.
  • Default 30 items per page is wrong for your domain (raise or lower it explicitly).
  • Custom paginator needed (search engine, external API, computed projections).

Default workflow

  1. Verify the 4.x defaults: pagination_items_per_page: 30, hydra_prefix: false. Adapt tests.
  2. Cap paginationMaximumItemsPerPage (50-100) per operation — anti-DoS.
  3. For large tables: paginationPartial: true (no COUNT, no totalItems).
  4. For infinite scroll: identifier = UUID v7 / ULID + paginationViaCursor + ComparisonFilter on the cursor field.
  5. For non-Doctrine sources: implement a custom PaginatorInterface.

Guardrails

  • hydra_prefix: false is the default — tests must use member / totalItems / view / next (no hydra: prefix).
  • Default page size is 30 in 4.x (changed from 20 in 3.x) — fix tests that hard-code 20.
  • Always cap the max page size to prevent abusers from requesting ?itemsPerPage=10000.
  • Cursor pagination requires a stable sort key — UUID v7 / ULID are ideal; auto-increment IDs work but leak volume.

Progressive disclosure

  • SKILL.md lists posture and rules.
  • reference.md carries the full patterns: 4.x JSON-LD shape, partial pagination, cursor with UUID v7, fetch-join collection / output walkers, custom parameter names, custom paginator, best practices.

Output contract

  • Operations declare paginationItemsPerPage, paginationMaximumItemsPerPage, and where applicable paginationPartial / paginationViaCursor.
  • Tests assert the 4.x JSON-LD shape (no hydra: prefix).
  • Cursor pagination uses an indexed sort key; performance verified on a representative dataset.

References

  • reference.md

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.