Pagination Filtering logo

Pagination Filtering

Community
zhaoxuya520
pagination-filtering

设计列表接口的分页、筛选、排序、搜索时使用。适用于所有列表 API。优先使用 cursor 分页(大数据)或 offset 分页(小数据)+ 统一筛选/排序规范。

Overview

Publisherzhaoxuya520
RepositoryAI-Fullstack-Delivery-Workflow
Skill namepagination-filtering
Stars
56
Forks
18
Bundled files
2
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • 2 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by zhaoxuya520 on GitHub. Read the source before you install it.

Installation

Install the Pagination Filtering AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/zhaoxuya520/AI-Fullstack-Delivery-Workflow/tree/master/workflows/api-designer/skills/pagination-filtering
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/zhaoxuya520/AI-Fullstack-Delivery-Workflow.git /tmp/AI-Fullstack-Delivery-Workflow
mkdir -p .claude/skills
cp -r /tmp/AI-Fullstack-Delivery-Workflow/workflows/api-designer/skills/pagination-filtering .claude/skills/pagination-filtering
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Pagination Filtering in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Pagination Filtering on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Pagination Filtering is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

分页、筛选、排序、搜索

参考来源:Stripe API Pagination、GitHub REST API

适用场景

  • 所有列表接口
  • 数据量大的查询
  • 复杂筛选场景
  • 全文搜索

分页方式

1. Offset 分页(页码分页)

text
GET /users?page=1&page_size=20
GET /users?offset=0&limit=20

响应:
{
  "data": [...],
  "pagination": {
    "page": 1,
    "page_size": 20,
    "total": 156,
    "total_pages": 8
  }
}

适用:
  ✅ 数据量小(< 10 万)
  ✅ 需要跳页(用户去第 5 页)
  ✅ 需要 total(显示"共 156 条")

不适用:
  ❌ 数据量大(性能差,深分页 OFFSET 慢)
  ❌ 高并发更新(数据可能错位)

2. Cursor 分页(游标分页)

text
GET /users?cursor=usr_abc123&limit=20

响应:
{
  "data": [...],
  "pagination": {
    "next_cursor": "usr_xyz789",
    "has_more": true
  }
}

适用:
  ✅ 数据量大(无穷滚动)
  ✅ 实时数据流
  ✅ 性能要求高
  ✅ 数据频繁更新

不适用:
  ❌ 需要跳页
  ❌ 需要精确 total

实现:
  cursor 通常是排序字段的值(id / created_at)
  WHERE id > cursor ORDER BY id LIMIT 20

3. Time-based 分页

text
GET /events?since=2026-01-15T00:00:00Z&until=2026-01-16T00:00:00Z

适用:日志、事件流、时间相关数据

选择决策

text
后台管理 / 小数据 → offset
公开 API / 大数据 / 信息流 → cursor
日志 / 事件 → time-based

筛选(Filtering)

基础筛选

text
GET /users?status=active
GET /users?role=admin
GET /users?created_after=2026-01-01

多值筛选

text
GET /users?status=active,inactive
GET /users?role=admin&role=manager   (重复参数)

范围筛选

text
GET /products?price_min=10&price_max=100
GET /orders?created_after=2026-01-01&created_before=2026-01-31

操作符筛选(高级)

text
GET /products?price[gte]=10&price[lte]=100
GET /products?stock[gt]=0
GET /products?name[like]=phone

操作符:
  eq  - 等于
  ne  - 不等于
  gt  - 大于
  gte - 大于等于
  lt  - 小于
  lte - 小于等于
  in  - 在列表中
  nin - 不在列表中
  like - 模糊匹配

全文搜索

text
GET /products?q=iphone
GET /products?keyword=iphone

参数名:q / keyword / search
搜索范围:通常服务端定义(如 name + description)

排序(Sorting)

text
GET /users?sort=created_at        升序(默认)
GET /users?sort=-created_at       降序(- 前缀)
GET /users?sort=-priority,name    多字段排序

或:
GET /users?sort_by=created_at&order=desc

字段选择(Sparse Fieldsets)

text
GET /users/{id}?fields=id,name,email
返回:只包含这三个字段

GET /orders/{id}?include=items,user
返回:默认字段 + 嵌套关联

适用:
  - 移动端节省流量
  - 性能优化
  - 减少敏感字段返回

统一规范模板

markdown
## 列表接口规范

### 分页参数(offset 风格)
- page: integer, default=1, min=1
- page_size: integer, default=20, min=1, max=100

### 分页响应
{
  "data": [...],
  "pagination": {
    "page": 1,
    "page_size": 20,
    "total": 156,
    "total_pages": 8,
    "has_next": true,
    "has_previous": false
  }
}

### 筛选参数
- 单值:?status=active
- 多值:?status=active,inactive
- 范围:?created_after=...&created_before=...

### 排序
- 单字段:?sort=created_at(升序)
- 单字段降序:?sort=-created_at
- 多字段:?sort=-priority,name

### 搜索
- 全文:?q=keyword

### 字段选择
- 包含:?fields=id,name,email
- 关联:?include=user,items

完整示例

text
GET /products?
  q=phone&
  category=electronics&
  price_min=100&
  price_max=1000&
  in_stock=true&
  sort=-rating,-created_at&
  page=1&
  page_size=20&
  fields=id,name,price,rating

→
{
  "data": [
    {
      "id": "prd_001",
      "name": "iPhone 15",
      "price": 999,
      "rating": 4.8
    }
  ],
  "pagination": {
    "page": 1,
    "page_size": 20,
    "total": 87,
    "total_pages": 5,
    "has_next": true,
    "has_previous": false
  }
}

工作流程

text
1. 评估数据量和查询场景
2. 选择分页方式(offset / cursor / time)
3. 列出可筛选字段
4. 决定支持的操作符(基础 / 高级)
5. 列出可排序字段和默认排序
6. 决定是否支持搜索
7. 决定是否支持字段选择
8. 写入 OpenAPI 参数定义
9. 输出列表接口规范

质量自检

text
□ 全 API 用同一种分页方式(不要混用)
□ page_size 有上限(防止滥用,max 100)
□ 排序字段命名一致(- 前缀降序)
□ 筛选参数有校验(防注入)
□ 搜索的 q 参数有最小长度
□ 列表响应有 total 或 has_more
□ 大数据集用 cursor 不用 offset
□ 默认排序明确(不能不排序)

常见坑

  1. 不同端点不同分页风格——/users 用 page,/orders 用 cursor
  2. page_size 无上限——攻击者请求 page_size=10000
  3. OFFSET 深分页慢——OFFSET 100000 LIMIT 20 性能差
  4. 排序字段未限制——?sort=password_hash 暴露字段
  5. 不返回 total——前端无法显示"共 X 条"
  6. 筛选直接拼 SQL——SQL 注入风险
  7. 搜索全表扫描——无索引,数据量大时崩溃
  8. 响应格式不一——有的 data 有的 items 有的 results

配套模板

  • templates/pagination-filter-sort-template.md — 分页参数 + 筛选参数 + 列表响应结构模板

与其他 skill 的协作

text
上游:
  endpoint-design → 列表端点清单

平行:
  request-response → 列表响应结构

下游:
  openapi-mock → OpenAPI 参数定义
  转交后端 → 数据库索引设计(database-engineer 协作)

Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

Frequently asked questions

What does the Pagination Filtering AI skill do?

设计列表接口的分页、筛选、排序、搜索时使用。适用于所有列表 API。优先使用 cursor 分页(大数据)或 offset 分页(小数据)+ 统一筛选/排序规范。

Why use Pagination Filtering on TypingMind?

Because you install it once and use it with any model. Pagination Filtering is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Pagination Filtering in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/zhaoxuya520/AI-Fullstack-Delivery-Workflow/tree/master/workflows/api-designer/skills/pagination-filtering. TypingMind reads its SKILL.md and bundles its files and installs it as a skill you can enable per chat.

Which AI models can use Pagination Filtering?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Pagination Filtering?

As many as you like. As long as a model supports skills, you can use Pagination Filtering with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Pagination Filtering AI skill free?

It is published on GitHub by zhaoxuya520. Check the repository for licensing terms. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇