# Query Enhancer

> RAG query optimization - rewrite, expand, decompose, and analyze search queries for better retrieval results

- Skill: `chainlesschain/query-enhancer` (Agent Skill, multi-file: 2 files)
- Install (CLI): `npx skillmds@latest add chainlesschain/query-enhancer`
- Raw SKILL.md: https://api.skillmd.com/api/skills/chainlesschain/query-enhancer/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Web & Frontend
- License: MIT
- Author: chainlesschain (https://skillmd.com/u/chainlesschain)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/chainlesschain/query-enhancer

---


# Query Enhancer Skill

Optimize search queries for better RAG retrieval results using NLP heuristics.

## Usage

```
/query-enhancer [action] "<query>"
```

## Actions

| Action      | Flag          | Description                                                |
| ----------- | ------------- | ---------------------------------------------------------- |
| Rewrite     | `--rewrite`   | Generate multiple query variants with synonyms and context |
| Multi-Query | `--multi`     | Expand one question into 3-5 diverse search queries        |
| HyDE        | `--hyde`      | Generate a hypothetical answer passage for embedding       |
| Decompose   | `--decompose` | Break complex question into atomic sub-queries             |
| Expand      | `--expand`    | Add related terms, synonyms, and context keywords          |
| Analyze     | `--analyze`   | Classify intent, extract entities, determine answer type   |

## How It Works

1. **Rewrite**: Applies synonym substitution, rephrasing, and contextual expansion to produce 3-4 variant queries that cover different retrieval angles
2. **Multi-Query**: Generates 3-5 semantically diverse queries targeting different facets of the original question
3. **HyDE**: Creates a hypothetical document passage that would answer the query, useful for embedding-based retrieval where the answer embedding is closer to relevant documents
4. **Decompose**: Splits compound questions into independent sub-queries that can be searched separately and results merged
5. **Expand**: Enriches the query with related terms from a built-in synonym map and detected domain context
6. **Analyze**: Detects query type (who/what/when/where/why/how), extracts named entities and quoted terms, and classifies expected answer format

