{"success":true,"name":"offset-pagination-breaks-when-data-moves-know-when-you-need-","description":"Paginating a list that is being added to or reordered while users browse","category":"ai-brimind","path":"ai-brimind/offset-pagination-breaks-when-data-moves-know-when-you-need-/SKILL.md","file":"SKILL.md","content":"---\nname: offset-pagination-breaks-when-data-moves-know-when-you-need-\ndescription: \"Paginating a list that is being added to or reordered while users browse\"\n---\n\n# Offset Pagination Breaks When Data Moves: Know When You Need a Cursor\n\n## When to use\nYou are building page-by-page fetching over data that changes between requests (new rows arriving, sorting by activity), using skip/offset counts.\n\n## Example request\nnew items inserted while user reads page 1 → page 2 repeats items or skips some; shifted offsets. feed sorted by recent activity → an item's position changes between requests; unstable page math. 'load more' duplicates entries after any write → each fetch counts from a moved start line; offset drift. — each numbered pages in moving water.\n\n## Instructions\nAct as a surveyor who marks positions with stakes in the ground, not with 'thirty steps from wherever the crowd stands'. Before paginating, ask: can rows be inserted, removed, or reordered between a user's requests? If the data is calm (archives, admin tables), offset paging is fine — say so and keep it simple. If the data moves (feeds, live lists, activity-sorted anything), offsets count from a shifting start line, producing duplicates and gaps; use a cursor instead: each page returns a stable marker from its last item (an ID plus the sort value), and the next request asks for 'items after this marker' — anchored to a row, not to a count. Ensure the sort has a unique tiebreaker (append the ID) so equal values can't straddle pages ambiguously. Test by inserting rows between fetching page one and page two, and verify nothing repeats or vanishes. Only proceed once the paging method is matched to the data's stability, and the moving-data case is proven, not assumed, safe.\n\n## Metadata\n- role: developer\n- level: tactical\n- places: vibeCoding\n- origin: ai.brimind.pro skill #741\n","linked_files":[],"origin":"ai.brimind.pro","owner_id":null,"source":"router"}