Implements offset/limit pagination with Spring Data JPA and Spring Data REST: Pageable, HAL links, page metadata, and sort parameters.
Agentic Workflow: Read -> Reason -> Act (api-pagination-spring-data)
You are Api Pagination Spring Data (backend) — a sub-agent that Reads, Reasons, and Acts via allowed-tools.
1. Read — backend context for api-pagination-spring-data
- Domain: Implements offset/limit pagination with Spring Data JPA and Spring Data REST: Pageable, HAL links, page metadata, and sort parameters.
- spring-data-paging: Use Spring Data Pageable with HAL response metadata —
curl -s 'http://localhost:8080/api/users?page=0&size=20' | jq '.page.totalElemen
- pageable-repositories: Define paging repository methods and custom Pageable defaults —
curl -s 'http://localhost:8080/api/users?size=0' -o /dev/null -w '%{http_code}\n
- Check
knowledge and prerequisites: node.js, python, postgresql
2. Reason — think for api-pagination-spring-data
- For
spring-data-paging: Use Spring Data Pageable with HAL response metadata — decide which checks to run
- For
pageable-repositories: Define paging repository methods and custom Pageable defaults — decide which checks to run
- Evaluate trust/policy:
kdesk trust + kdesk doctor patterns for your inputs
3. Act — execute with api-pagination-spring-data tools
- Tools:
Glob, Grep, Read, Bash, ./mvnw (see frontmatter tools/allowed-tools)
- Use
safe_path for any write; record evidence (paths, checksums)
- Fingerprint:
api-pagination-spring-data:1228bdee
API Pagination v2 - Spring Data
Offset pagination with Spring Data.
What This Skill Does
- Maps Pageable parameters to JPA queries
- Returns HAL links and page metadata
- Enforces page size limits and sort whitelisting
When to Use
- Spring Boot APIs needing standard page/size paging
- HATEOAS-style clients that follow HAL links
- Admin tables with simple data volumes
Real Commands
curl -s 'http://localhost:8080/api/users?page=0&size=20' | jq '.page.totalElements, .page.totalPages'
curl -s -H 'Accept: application/hal+json' 'http://localhost:8080/api/users' | jq '._links.next.href'
Repository Method
@Repository
public interface UserRepository extends JpaRepository<User, Long> {
Page<User> findByActiveTrue(Pageable pageable);
}
Testing
- Verify totalPages math on boundary sizes
- Confirm size=0 and negative pages are rejected
- Test sort injection attempts do not cause SQL errors
Best Practices
- Configure spring.data.rest.max-page-size globally
- Whitelist sortable properties to avoid expensive sorts
- Use Page projections to avoid N+1 lazy loading
Capabilities
spring-data-paging
Use Spring Data Pageable with HAL response metadata
Parameters:
page (integer): Zero-based page index
size (integer): Page size, capped by Spring config
sort (string): Comma-separated property,dir pairs
Commands:
curl -s 'http://localhost:8080/api/users?page=0&size=20' | jq '.page.totalElements, .page.totalPages'
curl -s -H 'Accept: application/hal+json' 'http://localhost:8080/api/users' | jq '._links.next.href'
curl -s 'http://localhost:8080/api/users?sort=name,desc' | jq '._embedded.users[0].name'
./mvnw clean test
Examples:
- page=0&size=20 selects page one with 20 items
- Accept: application/hal+json returns _links with next/prev
- sort=name,desc orders results before paging
pageable-repositories
Define paging repository methods and custom Pageable defaults
Commands:
curl -s 'http://localhost:8080/api/users?size=0' -o /dev/null -w '%{http_code}\n'
curl -s 'http://localhost:8080/api/users?page=-1' -o /dev/null -w '%{http_code}\n'
./mvnw spring-boot:run -Dspring-boot.run.arguments=--spring.data.rest.default-page-size=50
Examples:
References
1---2name: "api-pagination-spring-data"3description: "Implements offset/limit pagination with Spring Data JPA and Spring Data REST: Pageable, HAL links, page metadata, and sort parameters. Use when working with spring data paging, pageable repositories or when the user mentions spring data paging, pageable repositories."4license: "MIT"5compatibility: "Requires node.js, python, postgresql, redis, graphql. Needs network access."6metadata:7 source: https://skillmd.com/skills/opknock/api-pagination-spring-data8 author: Kdesk9 version: 2.0.010 category: backend11allowed-tools: "Glob Grep Read Bash(./mvnw:*) Bash(curl:*)"12---1314Implements offset/limit pagination with Spring Data JPA and Spring Data REST: Pageable, HAL links, page metadata, and sort parameters.1516## Agentic Workflow: Read -> Reason -> Act (api-pagination-spring-data)1718You are **Api Pagination Spring Data** (backend) — a sub-agent that **Reads, Reasons, and Acts** via `allowed-tools`.1920### 1. Read — backend context for `api-pagination-spring-data`21- Domain: Implements offset/limit pagination with Spring Data JPA and Spring Data REST: Pageable, HAL links, page metadata, and sort parameters.22- **spring-data-paging**: Use Spring Data Pageable with HAL response metadata — `curl -s 'http://localhost:8080/api/users?page=0&size=20' | jq '.page.totalElemen`23- **pageable-repositories**: Define paging repository methods and custom Pageable defaults — `curl -s 'http://localhost:8080/api/users?size=0' -o /dev/null -w '%{http_code}\n`24- Check `knowledge` and `prerequisites: node.js, python, postgresql`2526### 2. Reason — think for `api-pagination-spring-data`27- For `spring-data-paging`: Use Spring Data Pageable with HAL response metadata — decide which checks to run28- For `pageable-repositories`: Define paging repository methods and custom Pageable defaults — decide which checks to run29- Evaluate trust/policy: `kdesk trust` + `kdesk doctor` patterns for your inputs3031### 3. Act — execute with `api-pagination-spring-data` tools32- Tools: `Glob`, `Grep`, `Read`, `Bash`, `./mvnw` (see frontmatter `tools`/`allowed-tools`)33- Use `safe_path` for any write; record evidence (paths, checksums)34- Fingerprint: `api-pagination-spring-data:1228bdee`3536# API Pagination v2 - Spring Data3738Offset pagination with Spring Data.3940## What This Skill Does41- Maps Pageable parameters to JPA queries42- Returns HAL links and page metadata43- Enforces page size limits and sort whitelisting4445## When to Use46- Spring Boot APIs needing standard page/size paging47- HATEOAS-style clients that follow HAL links48- Admin tables with simple data volumes4950## Real Commands5152```bash53curl -s 'http://localhost:8080/api/users?page=0&size=20' | jq '.page.totalElements, .page.totalPages'54curl -s -H 'Accept: application/hal+json' 'http://localhost:8080/api/users' | jq '._links.next.href'55```5657## Repository Method5859```java60@Repository61public interface UserRepository extends JpaRepository<User, Long> {62 Page<User> findByActiveTrue(Pageable pageable);63}64```6566## Testing67- Verify totalPages math on boundary sizes68- Confirm size=0 and negative pages are rejected69- Test sort injection attempts do not cause SQL errors7071## Best Practices72- Configure spring.data.rest.max-page-size globally73- Whitelist sortable properties to avoid expensive sorts74- Use Page<DTO> projections to avoid N+1 lazy loading7576## Capabilities7778### spring-data-paging79Use Spring Data Pageable with HAL response metadata8081**Parameters:**82- `page` (integer): Zero-based page index83- `size` (integer): Page size, capped by Spring config84- `sort` (string): Comma-separated property,dir pairs8586**Commands:**87- `curl -s 'http://localhost:8080/api/users?page=0&size=20' | jq '.page.totalElements, .page.totalPages'`88- `curl -s -H 'Accept: application/hal+json' 'http://localhost:8080/api/users' | jq '._links.next.href'`89- `curl -s 'http://localhost:8080/api/users?sort=name,desc' | jq '._embedded.users[0].name'`90- `./mvnw clean test`9192**Examples:**93- page=0&size=20 selects page one with 20 items94- Accept: application/hal+json returns _links with next/prev95- sort=name,desc orders results before paging9697### pageable-repositories98Define paging repository methods and custom Pageable defaults99100**Commands:**101- `curl -s 'http://localhost:8080/api/users?size=0' -o /dev/null -w '%{http_code}\n'`102- `curl -s 'http://localhost:8080/api/users?page=-1' -o /dev/null -w '%{http_code}\n'`103- `./mvnw spring-boot:run -Dspring-boot.run.arguments=--spring.data.rest.default-page-size=50`104105**Examples:**106- -cli --help107- -api --help108109## References110- [Spring Data REST Docs](https://docs.spring.io/spring-data/rest/reference/paging-chapter.html)111- [Spring Data JPA Repositories](https://docs.spring.io/spring-data/jpa/reference/repositories/paging-and-sorting.html)