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

# Context Manager CLI

> Manage Agent context via command line

Manage Agent context windows from the command line.

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

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

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

```

## Quick Start

<Steps>
  <Step title="Simple Usage">
    ```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
    npx praisonai context create --budget 4000
    ```
  </Step>

  <Step title="With Configuration">
    ```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
    npx praisonai context add "User prefers concise answers" --priority 0.9
    ```
  </Step>
</Steps>

***

## Basic Usage

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
# Create context manager with budget
npx praisonai context create --budget 4000

# Add high-priority context
npx praisonai context add "User prefers concise answers" --priority 0.9

# Add context from file
npx praisonai context add-file ./system-prompt.txt --priority 1.0

# Show current context stats
npx praisonai context stats
```

## Budget Management

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
# Show budget allocation
npx praisonai context budget --show

# Allocate tokens to a source
npx praisonai context budget allocate system 500 --priority 10

# Check available tokens
npx praisonai context budget available
```

## Context Optimization

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
# Optimize context to fit budget
npx praisonai context optimize --target 4000

# Optimize with specific strategy
npx praisonai context optimize --strategy truncate-low-priority

# Available strategies: truncate-old, truncate-low-priority, deduplicate, compress
```

## Export and Build

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
# Build context string
npx praisonai context build

# Export context to file
npx praisonai context export --output context.txt

# Export as JSON
npx praisonai context export --json --output context.json
```

## Programmatic (TypeScript)

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

const context = new ContextManager({ maxTokens: 4000 });
const budgeter = new ContextBudgeter({ totalBudget: 8000 });
const optimizer = new ContextOptimizer({ targetTokens: 5000 });
```

## Related

<CardGroup cols={2}>
  <Card title="Context Manager" icon="book" href="/docs/js/context-manager">
    SDK documentation
  </Card>

  <Card title="Sessions CLI" icon="terminal" href="/docs/js/sessions-cli">
    Session management
  </Card>

  <Card title="Memory CLI" icon="terminal" href="/docs/js/memory-cli">
    Memory operations
  </Card>
</CardGroup>
