/system-design-skills:distributed-searchfrom system-design-skills
Guides the design of distributed full-text search systems: inverted index, sharding, replication, relevance ranking (TF-IDF/BM25), autocomplete, faceted search, and near-real-time indexing pipelines.
Ships in system-design-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Find the documents that best match a free-text query, ranked by relevance, fast,
across more data than one machine holds. Getting it wrong means either slow
LIKE '%term%' scans that melt the primary database, or a search box that
returns the wrong results and erodes user trust — both are silent until traffic
or corpus size exposes them.
Users type words and expect ranked, relevant matches — not exact-key lookups.
The corpus is text-heavy (documents, products, logs, messages), queries are
ad-hoc (any term, any combination), and results need ranking, highlighting,
facets, or typeahead. Reach for it when a WHERE col LIKE or full-table scan is
already the read bottleneck, or when you need fuzzy/partial matching a B-tree
index cannot serve.
The access pattern is fetch-by-known-key or a fixed filter — a primary database
index serves that far more cheaply and consistently; keep it in data-storage.
The corpus is tiny (thousands of rows): an in-process filter or the database's
built-in full-text index is enough — a separate search cluster is pure
operational overhead (YAGNI). Search is a derived, eventually-consistent copy
of your data; never make it the system of record.
back-of-the-envelope) This decides shard count.The pipeline (almost always present): a source emits document changes → an indexing pipeline transforms/analyzes them → the inverted index stores term→document postings → the query path matches and ranks. For a crawl-based system (web search), prepend crawl → parse → dedupe; that crawler is its own subsystem feeding the same pipeline.
Index build mode
Ranking model
Autocomplete
Distribution: split the index into shards (each a self-contained
inverted index over a doc subset) for capacity, and replicas per shard for
read throughput and fault tolerance. Sharding theory lives in data-storage.
| Option | What it solves | What it worsens | Change it when |
|---|---|---|---|
| Batch reindex | Simple, atomic swap, no live-write complexity | Stale until next build; full rebuild is costly | Users need fresh results → near-real-time |
| Near-real-time | Seconds-fresh; no full rebuild | Segment churn, merge load, refresh cost on writes | Write rate or merge cost overwhelms nodes → batch/larger refresh interval |
| Boolean/filter | Cheapest; deterministic | No notion of "best" result | Users judge result quality → add BM25 |
| BM25 | Good relevance, explainable, cheap | Ignores popularity/recency/intent | Word-overlap isn't enough → hybrid signals |
| Hybrid signals | Matches business/user intent | Complex, harder to debug, needs tuning data | Tuning cost exceeds value → fall back to BM25 |
| Prefix trie/FST | Fastest typeahead | Separate structure to build/refresh; ignores filters | Suggestions need filters/relevance → edge-n-gram |
| More shards | Parallelism, fits big corpus | Per-query fan-out + merge overhead; tiny shards waste resources | Fan-out latency dominates → fewer, larger shards |
| More replicas | Read QPS + HA | More RAM/disk; replication lag on writes | Write amplification hurts → fewer replicas |
Search amplifies trouble through fan-out and derived-data lag.
from=100000 forces every shard to sort huge windows.
Mitigate: cursor/search_after, cap page depth.messaging-streaming); monitor lag, not just throughput.Monitor: per-shard p99 query latency, indexing lag (source→searchable), segment/merge count, heap/GC, shard balance, and rejected/queued requests.
Decision | Solves | Worsens | Change it when… table with one row per choice you made here (e.g. the
option, its store, its failure policy); the last column is a concrete trigger
(a number or observable signal). Then name what breaks first.Do
data-storage and be able to fully reindex from it.Don't
from/offset pagination; use cursors instead.The quantities that drive the design: total index bytes (corpus × per-doc
overhead, then ÷ target shard size to get shard count), read QPS × fan-out (each
query touches every shard) for replica sizing, and indexing throughput vs change
rate to keep freshness lag inside budget. A single shard performs well within a
bounded size range; past it, split. Use back-of-the-envelope for the latency,
QPS, and storage figures — don't restate them here.
The contracts are the document, the query, and the postings. A document is a
typed record with analyzed fields, e.g. { "id": "p123", "title": "...", "body": "...", "tags": ["a","b"], "price": 9.99 }. A query names fields,
match type, filters, sort, and pagination cursor, e.g. q="wireless earbuds", fields=[title^2, body], filter={tag:audio}, sort=_score, search_after=<cursor>.
The inverted index maps each term → posting list of (doc_id, term_freq, positions); ranking reads these to compute BM25. Decide the analyzer
(tokenizer, lowercasing, stemming, synonyms) up front — it is part of the
contract and changing it requires a reindex.
Default to the generic recipe above (Elasticsearch/OpenSearch, Lucene, Solr,
self-hosted). If the user names a cloud, read
references/providers/<provider>.md for the managed-service mapping,
quotas/limits, and provider-specific trade-offs. If no file exists for that
provider, the generic recipe is the answer.
To visualize the source → indexing pipeline → inverted index (sharded +
replicated) → query/rank path, or the crawl→parse→dedupe front end, use the
in-plugin architecture-diagram skill — show the indexing path and the query
fan-out as distinct flows, with replicas behind each shard.
data-storage — alternative to a DB LIKE/full-table scan for text search;
search owns the inverted index, while sharding/partitioning and replication
theory live there — name and link, don't re-teach.messaging-streaming — depends on this for the index-update pipeline: a
durable buffer carries document changes to the indexer and absorbs write
surges (delivery, ordering, backpressure are owned there).caching — pairs with this to cache hot/repeated queries and reduce fan-out
load (stampede, hot-key, eviction handling owned there).back-of-the-envelope — feeds into this skill: corpus bytes, QPS, and
freshness numbers size the shards, replicas, and pipeline.system-design — owned-concept lives in the orchestrator: the reasoning
loop, the trade-off method, and the ten failure modes.references/deep-dive.md — inverted-index internals (postings, segments,
merges), the crawl/index/search pipeline, BM25 scoring, near-real-time refresh,
autocomplete (trie/FST/n-gram), shard routing and replica reads. Read when
designing the search layer in detail.references/providers/{generic,aws,azure,gcp}.md — service mappings,
limits, and pitfalls per environment.What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
search-engine, full-text-search, elasticsearch, opensearch, indexing
npx claudepluginhub proyecto26/system-design-skills --plugin system-design-skills22 skills in this plugin
/api-designThis skill should be used when the user needs to "design the API", do "endpoint design", pin down a "request/response shape", choose a "pagination" strategy (cursor vs offset), add an "idempotency key" to a write, plan "API versioning", an "error contract", or pick between "REST vs gRPC vs GraphQL" or "WebSocket vs polling". Use it whenever a design has reached the interface — the concrete request, response, primary access path, and how clients page, retry, and version — even if the user only said "the boxes talk to each other"./architecture-diagramThis skill should be used when a system design needs a diagram — "draw the architecture", "diagram this system", "show the components", "make an architecture/infrastructure/topology diagram", or visualizing boxes-and-arrows, data flow, regions, or failure paths for a design. It generates a self-contained dark-theme HTML + SVG diagram (with PNG/PDF export). Use it whenever the `system-design` orchestrator or a building block reaches the "draw it" step, even if the user doesn't say "diagram"./back-of-the-envelopeThis skill should be used when the user needs to "estimate QPS", "back-of-the-envelope" (BOTEC) numbers, "how much storage / bandwidth", "how many servers", "peak load", "capacity planning", or wants the standard latency / throughput / availability numbers to ground a design (latency table, QPS rates, powers of two, nines). Use it whenever a design decision hinges on scale — convert any "high traffic" / "huge data" phrase into concrete numbers before choosing components, even if the user doesn't say "estimate". Prefer it even for a quick "rough numbers" question (DAU × actions/day → QPS, storage per day/year, replication): it carries a calculator and the reference numbers, so the arithmetic and unit conversions are checked instead of done from memory./blob-storeThis skill should be used when the user wants a "blob store" or "object storage", names "S3" or an S3-compatible store, needs to "store images / video / files", asks about "multipart upload" or "resumable upload", "signed / presigned URLs", "media storage", "unstructured data at scale", object "versioning", storage "tiering" (hot/cold/archive), or "erasure coding" vs replication for durability. Use it whenever a design must hold large unstructured objects (photos, video, backups, logs, ML datasets) and serve them cheaply and durably, even if the user just says "where do we put the files"./cachingThis skill should be used when the user asks about a "caching strategy", "cache invalidation", "what to cache", "read-through vs write-through vs write-back", "cache eviction" (LRU/LFU/TTL), "Redis vs Memcached", "stale reads", or hits "thundering herd", "cache stampede", "cache penetration", or "hot key" problems, or is choosing a Redis `maxmemory` eviction policy (allkeys-lru, volatile-lru, noeviction) vs TTL expiry for sessions or other cached state. Use it whenever a design is read-heavy or a datastore is overloaded by reads, even if the user doesn't say "cache"./consistency-coordinationThis skill should be used when the user asks about the "CAP theorem", "PACELC", a "consistency model", "eventual vs strong consistency", "read-your-writes", "causal consistency", "quorum" or "R+W>N", "consensus", "Raft / Paxos", "leader election", "consistent hashing", a "distributed transaction", "2PC", or "saga". Use it whenever a design has multiple copies of data or coordinating nodes and a decision hinges on what a reader is guaranteed to see during replication lag, a network partition, or a node failure — even if the user doesn't say "consistency".Other plugins' skills for the same job