> ## Documentation Index
> Fetch the complete documentation index at: https://praison.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Query Rewriter CLI

> CLI commands for query rewriting in PraisonAI TypeScript

The `praisonai-ts` CLI provides the `query-rewrite` command for optimizing search queries.

```mermaid theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
graph LR
    User([User]) --> CLI[CLI]
    CLI --> Rewrite([Rewrite])

    classDef agent fill:#8B0000,stroke:#7C90A0,color:#fff
    classDef tool fill:#189AB4,stroke:#7C90A0,color:#fff

    class CLI agent
    class User,Rewrite tool
    classDef agent fill:#8B0000,color:#fff
    classDef tool fill:#189AB4,color:#fff
```

## Quick Start

**1. Simple Usage**

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
# Rewrite a query (default strategy: auto)
praisonai-ts query-rewrite "how to code"
```

**Example Output:**

```json theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
{
  "success": true,
  "data": {
    "originalQuery": "best programming language",
    "rewrittenQueries": [
      "What is the top programming language?",
      "Which programming language is considered the best?",
      "What is the most highly regarded programming language?"
    ],
    "strategy": "rephrase",
    "confidence": 0.85
  }
}
```

**2. With Configuration**

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
# JSON output with strategy
praisonai-ts query-rewrite "best programming language" --json --strategy rephrase
```

***

## Rewrite Strategies

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
# Expand strategy - add more context
praisonai-ts query-rewrite "AI" --strategy expand

# Simplify strategy - make query simpler
praisonai-ts query-rewrite "complex multi-word query" --strategy simplify

# Decompose strategy - break into sub-queries
praisonai-ts query-rewrite "AI and ML and DL" --strategy decompose

# Rephrase strategy - alternative phrasings
praisonai-ts query-rewrite "learn programming" --strategy rephrase

# Auto strategy (default) - automatically detect best approach
praisonai-ts query-rewrite "test query" --strategy auto
```

## Available Strategies

| Strategy | Description |
| - | - |
| `expand` | Add more context and detail to the query |
| `simplify` | Make the query simpler and more focused |
| `decompose` | Break complex queries into sub-queries |
| `rephrase` | Generate alternative phrasings |
| `auto` | Automatically detect the best strategy |

## SDK Usage

For programmatic usage, see the [Query Rewriter SDK documentation](https://praison.ai/docs/js/query-rewriter.md).

***

## Related

> [card] [Query Rewriter SDK](https://praison.ai/docs/js/query-rewriter.md)
>
> Programmatic rewriting

> [card] [Retrieval](https://praison.ai/docs/js/retrieval.md)
>
> Search and retrieval


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.