> ## 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.

# Prompt Expander Agent

> Expand and enhance prompts with more detail and context

Expand and enhance prompts with more detail and context for your Agents.

```mermaid theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
graph LR
    User([User]) --> Agent[PromptExpander]
    Agent --> Out([Expanded])

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

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

## Quick Start

**1. Simple Usage**

```typescript theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
import { PromptExpanderAgent } from 'praisonai';

const agent = new PromptExpanderAgent();

const result = await agent.expand('Write code');
console.log(result.expanded);
```

**2. With Configuration**

```typescript theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
import { PromptExpanderAgent } from 'praisonai';

const agent = new PromptExpanderAgent({
  name: 'MyExpander',
  llm: 'openai/gpt-4o',
  defaultStrategy: 'detail',
  verbose: true
});

const result = await agent.expand('Create a function');
console.log(result);
```

## Installation

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
npm install praisonai
```

## With Custom Configuration

```typescript theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
import { PromptExpanderAgent } from 'praisonai';

const agent = new PromptExpanderAgent({
  name: 'MyExpander',
  llm: 'openai/gpt-4o',
  defaultStrategy: 'detail',
  verbose: true
});

const result = await agent.expand('Create a function');
console.log(result);
```

## Expansion Strategies

```typescript theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
import { PromptExpanderAgent } from 'praisonai';

const agent = new PromptExpanderAgent();

// Detail strategy - adds specific details
const detail = await agent.expand('Write code', 'detail');

// Context strategy - adds background context
const context = await agent.expand('Explain this', 'context');

// Examples strategy - adds concrete examples
const examples = await agent.expand('Show me how', 'examples');

// Constraints strategy - adds requirements
const constraints = await agent.expand('Build a system', 'constraints');

// Auto strategy - detects best approach
const auto = await agent.expand('Do something', 'auto');
```

## Strategy Detection

```typescript theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
import { PromptExpanderAgent } from 'praisonai';

const agent = new PromptExpanderAgent();

// Automatically detects appropriate strategy
const strategy = agent.detectStrategy('Write code');
console.log(strategy); // 'detail'

const strategy2 = agent.detectStrategy('Explain why this matters');
console.log(strategy2); // 'context'
```

## Result Structure

```typescript theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
interface ExpandResult {
  original: string;      // Original prompt
  expanded: string;      // Expanded prompt
  strategy: ExpandStrategy;  // Strategy used
  additions: string[];   // New elements added
}
```

## Factory Function

```typescript theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
import { createPromptExpanderAgent } from 'praisonai';

const agent = createPromptExpanderAgent({
  name: 'Expander',
  verbose: true
});
```

## Related

> [card] [Prompt Expander CLI](https://praison.ai/docs/js/prompt-expander-cli.md)
>
> CLI commands

> [card] [Agent](https://praison.ai/docs/js/agent.md)
>
> Agent configuration


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