Ranks retrieved context chunks by relevance, diversity, and utility using scoring algorithms and multi-stage pipelines to surface the best information for a given query.
npx skills add https://github.com/seb1n/awesome-ai-agent-skills --skill context-ranking
Context ranking is the process of ordering retrieved text chunks so the most relevant, diverse, and useful information rises to the top. In any retrieval pipeline, the initial search returns a broad set of candidates -- many of which are only tangentially related to the query. Ranking transforms this unordered candidate set into a prioritized list, enabling downstream steps (context assembly, prompt construction) to select the best material and discard the rest. Effective ranking is the difference between a grounded, precise answer and a vague, off-topic one.
bge-reranker-v2-m3, or ColBERTv2 are commonly used. This step is slower but dramatically improves precision.Provide a query and a list of candidate text chunks (with optional preliminary scores and metadata). The skill scores, reranks, and diversifies the chunks, returning a ranked list with final scores and confidence tiers. Specify the desired number of output chunks (top-n) and an optional diversity parameter (MMR lambda).
Query: "Why does the WebSocket connection drop after 60 seconds of inactivity?"
Candidate Chunks (from hybrid search, top-8):
| # | Source | BM25 | Cosine | Content Summary |
|---|--------|------|--------|-----------------|
| 1 | src/ws/server.ts:40-65 | 12.4 | 0.88 | WebSocket server config with pingInterval: 30000 and pingTimeout: 60000 |
| 2 | src/ws/server.ts:80-95 | 8.1 | 0.82 | Connection cleanup handler that logs "connection timed out" |
| 3 | docs/websocket.md:15-30 | 6.3 | 0.79 | Documentation: "Connections are kept alive via ping/pong. Default timeout is 60s." |
| 4 | src/ws/client.ts:10-35 | 5.7 | 0.84 | Client-side WebSocket wrapper -- does not implement pong response handler |
| 5 | nginx.conf:22-28 | 9.8 | 0.71 | Nginx proxy config: proxy_read_timeout 60s for WebSocket upstream |
| 6 | CHANGELOG.md:44-50 | 3.2 | 0.55 | "v2.1: Fixed WebSocket reconnection logic" -- no timeout details |
| 7 | src/ws/server.ts:100-120 | 4.5 | 0.76 | Rate limiting middleware for WebSocket messages |
| 8 | package.json:15-20 | 2.1 | 0.45 | "ws": "^8.14.0" dependency entry |
After Cross-Encoder Reranking:
| Rank | # | Reranker Score | Reason |
|------|---|----------------|--------|
| 1 | 1 | 0.96 | Directly shows the 60s timeout configuration |
| 2 | 5 | 0.93 | Nginx proxy timeout -- a second cause of 60s drops |
| 3 | 4 | 0.89 | Client missing pong handler -- explains why pings fail |
| 4 | 2 | 0.85 | Cleanup handler confirms timeout behavior |
| 5 | 3 | 0.78 | Documentation corroborates the 60s default |
| 6 | 7 | 0.42 | Rate limiting -- marginally related |
| 7 | 6 | 0.30 | Changelog -- no useful detail |
| 8 | 8 | 0.15 | Package.json -- irrelevant |
After MMR Diversity Selection (top-5, lambda=0.6):
src/ws/server.ts:40-65 (score 0.96) -- Server-side 60s timeout confignginx.conf:22-28 (score 0.93) -- Nginx proxy 60s read timeout (different source of the problem)src/ws/client.ts:10-35 (score 0.89) -- Client missing pong handler (client-side root cause)src/ws/server.ts:80-95 (score 0.85) -- Cleanup handler confirms the timeout behaviordocs/websocket.md:15-30 (score 0.78) -- Documentation confirming 60s defaultThe ranked list covers three distinct causes (server config, nginx proxy, client pong handler) plus confirmation from the cleanup handler and docs.
Query: "How do I configure SSO with SAML for my organization?"
Candidate Chunks (top-6 from vector search):
| # | Source | Cosine | Content Summary |
|---|--------|--------|-----------------|
| 1 | docs/sso/saml-setup.md | 0.91 | Step-by-step SAML configuration: metadata URL, certificate upload, attribute mapping |
| 2 | docs/sso/overview.md | 0.85 | Overview of SSO options: SAML, OIDC, LDAP. High-level comparison. |
| 3 | docs/sso/saml-setup.md | 0.83 | Troubleshooting SAML errors: invalid signature, clock skew, missing NameID |
| 4 | docs/sso/oidc-setup.md | 0.80 | OIDC configuration guide -- not SAML |
| 5 | docs/admin/org-settings.md | 0.77 | Organization settings page: where to find the SSO configuration panel |
| 6 | blog/sso-announcement.md | 0.72 | Blog post announcing SSO feature launch -- marketing copy, no setup details |
After Cross-Encoder Reranking and MMR (top-4, lambda=0.7):
docs/sso/saml-setup.md (setup guide, score 0.95) -- Direct answer: step-by-step SAML configurationdocs/admin/org-settings.md (score 0.82) -- Where to access the SSO settings (different doc, complements #1)docs/sso/saml-setup.md (troubleshooting, score 0.79) -- Anticipates common errors the user may encounterdocs/sso/overview.md (score 0.71) -- Provides broader context on SSO optionsChunk 4 (OIDC guide) was filtered as irrelevant to SAML. Chunk 6 (blog post) was filtered for low information density.
Integration with protocols.io API for managing scientific protocols. This skill should be used when working with protocols.io to search, create, update, or publish protocols; manage protocol steps and materials; handle discussions and comments; organize workspaces; upload and manage files; or integrate protocols.io functionality into workflows. Applicable for protocol discovery, collaborative protocol development, experiment tracking, lab protocol management, and scientific documentation.
Analyzes job descriptions and generates tailored resumes that highlight relevant experience, skills, and achievements to maximize interview chances
Generate Excalidraw diagrams from natural language descriptions. Use when asked to "create a diagram", "make a flowchart", "visualize a process", "draw a system architecture", "create a mind map", or "generate an Excalidraw file". Supports flowcharts, relationship diagrams, mind maps, and system architecture diagrams. Outputs .excalidraw JSON files that can be opened directly in Excalidraw.
Build and distribute Expo development clients locally or via TestFlight
Use when you have a written implementation plan to execute in a separate session with review checkpoints
Data structure for annotated matrices in single-cell analysis. Use when working with .h5ad files or integrating with the scverse ecosystem. This is the data format skill—for analysis workflows use scanpy; for probabilistic models use scvi-tools; for population-scale queries use cellxgene-census.
Benchling R&D platform integration. Access registry (DNA, proteins), inventory, ELN entries, workflows via API, build Benchling Apps, query Data Warehouse, for lab data management automation.
Comprehensive molecular biology toolkit. Use for sequence manipulation, file parsing (FASTA/GenBank/PDB), phylogenetics, and programmatic NCBI/PubMed access (Bio.Entrez). Best for batch processing, custom bioinformatics pipelines, BLAST automation. For quick lookups use gget; for multi-service integration use bioservices.
Take seb1n/context-ranking from the repository into ~/.claude/skills for personal
use, or into .claude/skills inside a project.
The agent identifies a skill by the name field in its header. Two skills with the
same name cannot sit side by side — one of them will be ignored.