api-filtering-sorting

api-filtering-sorting is a skill for Claude Code, Codex from secondsky/claude-skills. It costs 40 tokens per session (590 once invoked), scanned A, original, MIT.

A guide to adding filters and sorting to API requests. It covers query parameters, which are options added to a request URL, plus validation and security checks.

In plain words
What is it for?
Use it for search endpoints, data grids, and APIs that need controlled filtering by fields or operators and sorting in ascending or descending order.
Why use it?
It helps prevent arbitrary or unsafe database queries while allowing clients to search and order returned data.

Skill for Claude CodeCodex

Part of the api-filtering-sorting plugin — 1 skill shipped together

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/secondsky/claude-skills/api-filtering-sorting
Any agent
npx skills add secondsky/claude-skills --skill api-filtering-sorting
Clone the repo
git clone --depth 1 https://github.com/secondsky/claude-skills

Made for: Claude Code, Codex.

Or install api-filtering-sorting, the plugin that ships this one along with the rest of its 1 skill.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for api-filtering-sorting

README.md
[![agentmods](https://agentmods.dev/badge/skills/secondsky/claude-skills/api-filtering-sorting.svg)](https://agentmods.dev/skills/secondsky/claude-skills/api-filtering-sorting)
Your own site
<a href="https://agentmods.dev/skills/secondsky/claude-skills/api-filtering-sorting"><img src="https://agentmods.dev/badge/skills/secondsky/claude-skills/api-filtering-sorting.svg" alt="Measured on agentmods" height="20"></a>
Per session 40 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 590 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00040 $0.00590
Opus 5 $0.00020 $0.00295
Sonnet 5 $0.00008 $0.00118
Haiku 4.5 $0.00004 $0.00059

Measured 4d ago against content hash caad19551760, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

api-filtering-sorting scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 4d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

plugins/api-filtering-sorting/skills/api-filtering-sorting/SKILL.md · 87 lines

How it starts

The opening of the file, as written. The whole thing — 87 lines — stays where its author put it; the contents beside it link to each section on GitHub.

API Filtering & Sorting

Build flexible filtering and sorting systems that handle complex queries efficiently.

Query Parameter Syntax

GET /products?category=electronics&price[gte]=100&price[lte]=500&sort=-price,name

Implementation (Node.js)

const allowedFilters = ['category', 'status', 'price', 'createdAt'];
const allowedSorts = ['name', 'price', 'createdAt'];

app.get('/products', async (req, res) => {
  const filter = {};
  const sort = {};

  // Parse filters
  for (const [key, value] of Object.entries(req.query)) {
    if (key === 'sort') continue;

    const match = key.match(/^(\w+)\[(\w+)\]$/);
    if (match) {
      const [, field, operator] = match;
      if (!allowedFilters.includes(field)) continue;
      filter[field] = { [`$${operator}`]: parseValue(value) };
    } else if (allowedFilters.includes(key)) {
      filter[key] = value;
    }
  }

  // Parse sort
  if (req.query.sort) {
    for (const field of req.query.sort.split(',')) {
      const direction = field.startsWith('-') ? -1 : 1;
      const name = field.replace(/^-/, '');
      if (allowedSorts.includes(name)) sort[name] = direction;
    }
  }

  const products = await Product.find(filter).sort(sort);
  res.json({ data: products });
});

function parseValue(value) {
  if (value === 'true') return true;
  if (value === 'false') return false;
  if (!isNaN(value)) return Number(value);
  return value;
}

Filter Operators

Operator Meaning Example
eq Equals ?status=active
ne Not equals ?status[ne]=deleted
gt/gte Greater than ?price[gte]=100
lt/lte Less than ?price[lte]=500
in In array ?status[in]=active,pending
like Contains ?name[like]=phone

Security

  • Whitelist allowed filter fields
  • Validate input types per field
  • Index frequently-filtered columns
  • Limit query complexity
  • Prevent SQL/NoSQL injection

Best Practices

  • Support common operators
  • Cache filter option lists
  • Monitor query performance
  • Provide sensible defaults

Read the full file on GitHub · 87 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 4d ago First seen · 87 lines · 40 tokens per session scan A caad19551760

Subscribe to this mod's changes

api-filtering-sorting is a skill published in the GitHub repository secondsky/claude-skills (214 stars, last pushed today), licensed MIT. It adds 40 tokens to every session and 590 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other skills, from other repositories

context-mode-ops

Manage context-mode GitHub issues, PRs, releases, and marketing with parallel subagent army. Orchestrates 10-20 dynamic agents per task. Use when triaging issues, reviewing PRs, releasing versions, writing LinkedIn posts, announcing releases, fixing bugs, merging contributions, validating ENV vars, testing adapters…

mksglu/context-mode · 75 tokens

context-mode

Mandatory routing rules for Antigravity CLI. Invoke when exploring a codebase, reading files for analysis, listing context-mode tools, searching, parsing, counting, comparing, summarizing, fetching web content, or running data-heavy commands.

mksglu/context-mode · 50 tokens

ctx-purge

Purge the context-mode knowledge base. Permanently deletes all indexed content and resets session stats. This is destructive and cannot be undone. Trigger: /context-mode:ctx-purge.

mksglu/context-mode · 42 tokens

ctx-index

Index a local file or directory into context-mode's persistent FTS5 knowledge base so future ctxsearch calls can retrieve focused snippets without rereading raw files. Trigger: /context-mode:ctx-index.

mksglu/context-mode · 44 tokens

ctx-doctor

Run context-mode diagnostics. Checks runtimes, hooks, FTS5, plugin registration, npm and marketplace versions. Trigger: /context-mode:ctx-doctor.

mksglu/context-mode · 37 tokens

ctx-search

Search context-mode's persistent FTS5 knowledge base for previously indexed local project content, documentation, or session memory. Trigger: /context-mode:ctx-search.

mksglu/context-mode · 36 tokens