agentleFS
GetStreamGetStream/Agents/.claude/skills/query/SKILL.md

query

Skill8.2k starsChanged 57 days agoApache-2.0View on GitHub

How list endpoints take filters and sorts, modelled on Stream's query syntax. Read before adding a filter, a sort, or a query endpoint.

41 other projects use a version of this.

Adopted by

Steady: 0 new projects took it in the last 4 weeks, none the 4 weeks before.thin data

Week of Oct 4: 0 new projectsWeek of Oct 11: 0 new projectsWeek of Oct 18: 0 new projectsWeek of Oct 25: 0 new projectsWeek of Nov 1: 0 new projectsWeek of Nov 8: 0 new projectsWeek of Nov 15: 0 new projectsWeek of Nov 22: 0 new projects
Oct 2026Nov 2026Nov 2026
New projects taking a version of this file each week, over the 8 weeks our latest run read: only 0 in all, so this is a hint, not a trend.

Most recently taken up by

Who's talking about GetStream/Agents

The biggest 5 of 8 mentions linking to the repository that our crawl found. Each line is their own headline.

See all 8

Talked about on GitHub (8 times).

On GitHub · 8

3 more on GitHub

Used with

Projects with it also use attach-db, install-duckdb and 9 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • duckdbSkill

    attach-db

    Attach a DuckDB database file for use with /duckdb-skills:query. Explores the schema (tables, columns, row counts) and writes a SQL state file so subsequent queries can restore this session automatically via duckdb -init.

    Also in 3 projects that use this

  • carlopiSkill

    install-duckdb

    Install or update DuckDB extensions. Each argument is either a plain extension name (installs from core) or name@repo (e.g. magic@community). Pass --update to update extensions instead of installing.

    Also in 3 projects that use this

  • carlopiSkill

    read-file

    Read and explore any data file (CSV, JSON, Parquet, Avro, Excel, spatial, …) by filename only — resolves the path automatically. Uses DuckDB + the magic extension for format auto-detection. Installs magic if needed.

    Also in 4 projects that use this

  • Microsoft AzureSkill

    lint

    Run all linting and spell checking for TypeScript and Rust code. Run this before committing to catch style issues, clippy warnings, and misspellings.

    Also in 18 projects that use this

  • Google CloudSkill

    ingest

    Extracts, distills, and compiles raw sources (PPTX slide decks, PDFs, Word docs, Excel sheets, web URLs, transcripts, codebases, or raw/ directories) into persistent, structured Knowledge Compiler markdown wikis following the Open Knowledge Format (OKF v0.2) and Andrej Karpathy LLM-Wiki standard. Use when the user invokes /ingest, asks to ingest raw files or a target path, compile knowledge, update the wiki, or extract unstructured files into markdown knowledge bases. Don't use for retrospectively compiling the active chat conversation without external files (use distill-session) or for read-only vault lookups (use vault-query).

    Also in 19 projects that use this

  • NVIDIASkill

    save

    Persist the working library to the run dir and durable catalog. Use for /save.

    Also in 4 projects that use this

The file

We split this skill into the rules it gives an agent

4 rules. 0 are common, 2 are distinctive, and 2 are very specific to this project.

  • 0

    Common

    Most of the 34 edited versions we read keep these.

  • 2

    Distinctive

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Not supported, and a 400: $ne, $nin, $nor, $not, regexes.

    line 57
  2. Very specific:

    Only allow what an index serves.

    line 67
  3. Distinctive:

    Put the grammar in one package and reuse it.

    line 104
  4. Distinctive:

    Document the allowed fields, operators and sorts in the operation's description.

    line 119

“Common” is measured: kept by at least 6 in 10 of the 34 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Query

One filter language for every list, the one getstream.io uses for users, channels, messages and calls. A caller who has written one Stream query can write ours.

Paging is the pagination skill (.claude/skills/pagination/SKILL.md). Read it first: this skill decides which rows, that one decides where the page starts.

Shape

A resource that needs more than a couple of equality filters gets POST /v1/<resource>/query, operationId query<Resources>:

{
  "filter": {"state": "closed", "created_at": {"$gte": "2026-09-01T00:00:00Z"}},
  "sort": [{"field": "created_at", "direction": -1}],
  "limit": 25,
  "cursor": "…"
}

The answer is a page, {items, has_more, next_cursor}, as in pagination.

  • POST because a filter is a tree, and a tree in a query string is unreadable. It still reads and nothing changes.
  • A simple GET list with a couple of query parameters stays as it is. Add query<Resources> beside it when it outgrows them; don't add a tenth query parameter.
  • filter is optional. An empty filter is every row the caller may see.

Stream calls the field filter_conditions. We call it filter; the grammar is the same.

Filter grammar

A filter is a JSON object. Keys are field names or logical operators, and all keys at one level are ANDed.

OperatorMeaningExample
$eqequal; a bare value is shorthand{"state": "closed"}
$inequal to any of a list{"agent": {"$in": ["a", "b"]}}
$gt $gte $lt $lterange, on numbers and RFC3339 times{"created_at": {"$lt": "…"}}
$existsthe field is set or not{"ended_at": {"$exists": false}}
$containsarray holds the value; object holds every key and value{"custom": {"$contains": {"team": "x"}}}
$autocompleteprefix match on a name{"title": {"$autocomplete": "sup"}}
$qfull-text match{"title": {"$q": "billing refund"}}
$and $ora list of filters{"$or": [{"state": "running"}, {"agent": "x"}]}

custom.<key> is shorthand for $contains on the custom object: {"custom.team": "x"} is {"custom": {"$contains": {"team": "x"}}}.

Not supported, and a 400: $ne, $nin, $nor, $not, regexes. Negative filters walk every row that does not match instead of seeking to the ones that do. Rewrite them as a positive $in. Stream allows $ne only on id and booleans; we allow $ne only on booleans, where it is just $eq with the other value.

Rules

  • Each endpoint declares an allow-list: field → operators, and the column each field reads. Anything else is a 400 that names the field and the operator. Never pass a caller's field name into SQL; it is looked up in the allow-list and the column comes from there.
  • Only allow what an index serves. If (customer_id, agent, created_at, id) exists, agent gets $eq and $in; a field with no index gets nothing until it has one. Custom fields get $eq/$contains only, as containment (@>), which a jsonb_path_ops GIN index on the JSONB column answers. Never $exists on a custom key: key-exists (?, ?|, ?&) needs the default jsonb_ops index, which is several times larger.
  • $and/$or nest one level deep at most, and $in takes at most 100 values. Deeper trees are a 400; they are how a list becomes a table scan.
  • Scope is not a filter. The handler ANDs the customer, and for end users the user, onto whatever arrived, as SessionFilter.UserID does. A caller cannot widen it by writing $or.
  • Values are typed by the field: a time must parse as RFC3339, a number as a number, an enum as one of its values. A wrong type is a 400, not an empty page.

Sort

sort is a list of {"field", "direction"}, direction 1 ascending or -1 descending, as Stream does it. Fields come from a sort allow-list, usually two or three indexed columns.

  • Omitted, the endpoint's default applies, e.g. created_at descending.
  • The server appends id in the direction of the last key, so the order is total.
  • The cursor holds every sort key and a fingerprint of the sort. A cursor sent with a different sort is a 400. See pagination for why the keys are in the cursor.
  • One index per allowed sort, behind the filters it is used with.

Paging

As in pagination: limit + cursor, never offset. Stream Chat's queries page by offset with a 1,000 row ceiling; Stream Video's queryCalls hands back a next pointer. We do what Video does.

  • filter and sort are resent with every page. The cursor is only a position.
  • The next page is the filter ANDed with (sort keys, id) < (cursor values), flipped to > for ascending keys.
  • Fetch limit + 1 for has_more. No counts.

Go

Put the grammar in one package and reuse it; an endpoint only supplies its allow-lists.

  • A short allow-list needs no parser. querySessions (internal/api/session_query.go) declares its filter as closed Huma structs, with one struct per operator (Equals, TextMatch), so the schema validates the request and documents it too. Combinations the schema cannot express, such as a text search with project_id, are refused in sessionQueryOf. The cursor carries the sort, so a cursor from one sort is refused by another. Start here, and move to a tree only when $and, $or or $in are needed.
  • Parse the body into a tree once, validating against the allow-list as you go. The handler gets a typed tree or an invalidRequest APIError.
  • Compile the tree to bun Where clauses with bound values. Field names never reach SQL as text.
  • Where a list merges rows held in memory with rows in Postgres, like live sessions in Manager.find, the same tree needs a Match(item) too, so both halves filter and sort alike.
  • Document the allowed fields, operators and sorts in the operation's description; that is what a caller reads.
  • Tests follow the go-testing skill: one per allowed operator, one for a rejected field and a rejected operator, one for a nested $or, and one that pages a filtered, sorted list to the end without repeating or skipping a row.

SDKs

Go first, as AGENTS.md says. The filter is a plain map in every SDK (map[string]any, a dict, an object), which is how Stream's SDKs take filter_conditions. Sort is a typed list. List methods follow the cursor the way Items.Unwind does.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.