$ recombobulate _
home / tips / use-claude-to-implement-cursor-based-pagination
0

Use Claude to Implement Cursor-Based Pagination

bagwaa @bagwaa · Mar 26, 2026 · Workflows
use-claude-to-implement-cursor-based-pagination

Offset pagination (LIMIT 20 OFFSET 1000) is slow on large tables and breaks if rows are inserted or deleted between pages. Cursor-based pagination is the scalable alternative — and Claude can implement it for you.

Implement cursor-based pagination for my /api/posts endpoint.
Use the post ID as the cursor, encoded as base64.
Return a next_cursor field in the response and accept a cursor query param.

Paste in your existing controller and Claude will refactor the query, add the cursor encode/decode logic, and update the response shape. It understands the tradeoffs and can explain them as it writes.

For tie-breaking on timestamp columns, be explicit:

Add cursor pagination to PostController@index.
The cursor should encode both created_at and id to handle posts 
created at the same timestamp. Use base64 encoding.
Paginate 15 results per page.

Claude will generate the correct WHERE (created_at, id) < (?, ?) clause and handle both ascending and descending sort orders. For Laravel users, it can use the built-in cursorPaginate() method or build a raw implementation depending on your constraints.

Cursor pagination scales to millions of rows — ask Claude to implement it once and move on.

~/recombobulate $ tip --comments --count=0

Log in to leave a comment.

~/recombobulate $ tip --related --limit=3
0
Scan Pending Changes for Security Issues with /security-review

The /security-review command scans your uncommitted changes for injection vectors, auth gaps, hardcoded secrets, and other common vulnerabilities.

bagwaa @bagwaa · 1 hour ago
0
Run Setup Scripts on Every Session with the SessionStart Hook

The SessionStart hook fires when any session begins or resumes, making it ideal for loading environment variables and running one-time setup scripts.

bagwaa @bagwaa · 1 hour ago
0
Write Property-Based Tests with fast-check and Claude

Ask Claude to write property-based tests for your functions using fast-check — it identifies the mathematical invariants in your code and generates tests that cover inputs you'd never enumerate by hand.

bagwaa @bagwaa · 2 hours ago