{"success":true,"name":"paginate-lists-before-they-grow-not-after-they-crash","description":"Building a screen or endpoint that returns 'all items' of something.","category":"ai-brimind","path":"ai-brimind/paginate-lists-before-they-grow-not-after-they-crash/SKILL.md","file":"SKILL.md","content":"---\nname: paginate-lists-before-they-grow-not-after-they-crash\ndescription: \"Building a screen or endpoint that returns 'all items' of something.\"\n---\n\n# Paginate Lists Before They Grow, Not After They Crash\n\n## When to use\nA query or API returns a full collection (all users, all channels, all orders) with no limit, and the list will grow over time.\n\n## Example request\n'SELECT all' works fine with 50 test rows → production has 40,000 and the page freezes — unbounded query. Frontend renders every row in the DOM → scrolling dies at a few thousand nodes — render only what's visible. API returns the whole table as JSON → response is 30MB on mobile — limit/offset or cursor pagination.\n\n## Instructions\nAct like a developer who always asks 'and what happens when there are 100,000 of these?'. For any list endpoint or screen: (1) put a hard limit on the query from day one (LIMIT + offset, or cursor-based paging) — 'return everything' is a bug waiting for data; (2) design the API response to include paging info (total or hasMore, current page/cursor) so the frontend can build 'load more' or page controls; (3) on the frontend, never render unbounded rows — page them, or render incrementally. Before coding, estimate realistically: how many items in a year? If the answer is more than a few hundred, pagination is required, not optional. Check first whether the framework or database layer has built-in pagination before writing custom slicing logic. Only proceed once both the query and the UI have an explicit maximum they handle per request, and state what that number is.\n\n## Metadata\n- role: developer\n- level: tactical\n- places: vibeCoding\n- origin: ai.brimind.pro skill #1008\n","linked_files":[],"origin":"ai.brimind.pro","owner_id":null,"source":"router"}