agentleFS
jgamaraalvjgamaraalv/delivery-loop/.claude/skills/redis-query-engine/SKILL.md

redis-query-engine

Skill0 starsChanged 4 months agoMITView on GitHub

Redis Query Engine (RQE) — FT.CREATE schema design, field-type choice, DIALECT 2 syntax, efficient FT.SEARCH/FT.AGGREGATE, zero-downtime index swaps. Use when creating, querying, or optimizing search indexes on Hash or JSON documents.

The file

We split this skill into the rules it gives an agent

4 rules. About 0 are common, 1 is distinctive, and 3 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 3

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Start with the minimum schema.

    line 54
  2. Very specific:

    Always set PREFIX (or filter via FILTER expression).

    line 55
  3. Very specific:

    Use FT.INFO idx:<name> to monitor index size after adding fields.

    line 56
  4. Very specific:

    Use SORTABLE only on fields you actually sort by.

    line 57

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “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

Redis Query Engine

Guidance for using the Redis Query Engine (RQE) to index and search Hash or JSON documents. Covers schema design with FT.CREATE, field-type choices, query syntax, index lifecycle management, and the most common performance pitfalls.

1. Use DIALECT 2 (the modern default)

DIALECT 2 is the baseline. Other dialects (1, 3, 4) are deprecated as of Redis 8. Most modern client libraries already default to it — but specify it explicitly in raw commands for portability.

FT.SEARCH idx:products "@name:laptop" DIALECT 2

DIALECT 2 is required for vector search queries. It also handles special characters and NULLs predictably.

See references/dialect.md.

2. Pick the right field type

The field type decides both what you can query and how fast that query is. Use the narrowest type that supports your access pattern.

Field typeUse whenNotes
TEXTFull-text search neededTokenized + stemmed; not for exact match
TAGExact match / filteringAdd SORTABLE UNF for fastest tag queries
NUMERICRange queries, sortingPrices, counts, timestamps
GEOLat/long point queriesSingle points (stores, users)
GEOSHAPEPolygon / area queriesDelivery zones, regions
VECTORSimilarity searchHNSW or FLAT; see redis-vector-search

The classic mistake is using TEXT for a category or status field because "it's a string." TAG is 10× faster for those.

See references/field-types.md.

3. Index only what you query — and always set a prefix

FT.CREATE without a PREFIX indexes every matching key in the database; with a wide schema it can blow up index size and write latency.

FT.CREATE idx:products ON HASH PREFIX 1 product:
    SCHEMA
        name TEXT WEIGHT 2.0
        category TAG SORTABLE
        price NUMERIC SORTABLE
        location GEO

Rules of thumb:

  • Start with the minimum schema. Add fields as new query patterns emerge.
  • Always set PREFIX (or filter via FILTER expression).
  • Use FT.INFO idx:<name> to monitor index size after adding fields.
  • Use SORTABLE only on fields you actually sort by; it has a memory cost.

See references/index-creation.md.

4. Zero-downtime index updates — use aliases

For schema changes in production, keep application queries pointed at an alias and swap the underlying index.

FT.CREATE idx:products_v2 ON HASH PREFIX 1 product: SCHEMA ...
FT.ALIASUPDATE products idx:products_v2

# App queries are stable:
FT.SEARCH products "@category:{electronics}"

Useful management commands: FT.INFO, FT.DROPINDEX, FT._LIST, FT.ALIASADD/UPDATE/DEL.

See references/index-management.md.

5. SKIPINITIALSCAN — only when historical data is irrelevant

By default FT.CREATE walks all existing keys that match the prefix and indexes them. Use SKIPINITIALSCAN only when:

  • You're standing up the index for a new feature and existing data shouldn't be queryable.
  • Existing data is too large to scan synchronously.
  • You're indexing event streams where only future events matter.

For most schema migrations, the default (scan everything) is what you want.

See references/skip-initial-scan.md.

6. Write specific queries, not *

Narrow the result set with filters before paging or aggregating.

# Good — specific filter, limited fields returned
FT.SEARCH idx:products "@category:{electronics} @price:[100 500]"
    LIMIT 0 20
    RETURN 3 name price category
# Bad — full scan plus unbounded LIMIT
FT.SEARCH idx:products "*" LIMIT 0 10000

Other levers:

  • SORTBY requires SORTABLE on the sort field. Without it, sort is slow.
  • LIMIT early; the engine still processes everything above the limit if you don't.
  • RETURN specific fields — don't fetch the whole document if you only need a few.
  • Profile with FT.PROFILE idx:<name> SEARCH QUERY "<query>" when a query is slow.

See references/query-optimization.md.

References

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.