{"success":true,"name":"design-pagination-and-limits-before-the-list-endpoint-meets-","description":"Building an endpoint that returns a list of things","category":"ai-brimind","path":"ai-brimind/design-pagination-and-limits-before-the-list-endpoint-meets-/SKILL.md","file":"SKILL.md","content":"---\nname: design-pagination-and-limits-before-the-list-endpoint-meets-\ndescription: \"Building an endpoint that returns a list of things\"\n---\n\n# Design Pagination and Limits Before the List Endpoint Meets Real Data\n\n## When to use\nYou are writing an endpoint that returns a collection, and it currently returns everything with no limit, page, or ordering rule.\n\n## Example request\nList endpoint returns all rows → works with 50 test records, dies with 500k in production; a default limit is the seatbelt. — Client asks page 2 while new rows are inserted → items shift and duplicate across pages; cursor-based pagination is the known fix for moving data. — No ordering specified → the database returns rows in random order and pages overlap; stable sort key is the missing piece. — Response has items but no total or next-page info → the client can't build the UI; pagination metadata is part of the contract.\n\n## Instructions\nAct as a scale-aware developer who assumes every list will one day be huge. For any collection endpoint: 1) Enforce a default limit and a maximum limit server-side — never trust the client to ask for a sane amount, and never return unbounded results. 2) Choose the pagination style consciously: offset/page for small stable data, cursor-based for large or frequently changing data — and check what style the project's other endpoints already use; match it. 3) Always define a stable, explicit ordering (unique tiebreaker included) — pagination without deterministic order returns duplicates and gaps. 4) Include the navigation metadata the client needs (next cursor or page info, and total only if it's cheap to compute). 5) Test with a realistic data volume, not 10 rows — if you can't, say so and flag it. Only ship once the endpoint is confirmed bounded and deterministic, and explain how the design survives growth instead of just working on today's data.\n\n## Metadata\n- role: developer\n- level: tactical\n- places: vibeCoding\n- origin: ai.brimind.pro skill #890\n","linked_files":[],"origin":"ai.brimind.pro","owner_id":null,"source":"router"}