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

# Fast CLI Startup

> Sub-commands load only when you run them — every CLI invocation starts fast

Sub-commands load on demand — only the module you actually use is imported, so every `praisonai` invocation starts in milliseconds regardless of how many commands exist.

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
from praisonaiagents import Agent

agent = Agent(name="assistant", instructions="You are a helpful CLI assistant.")
agent.start("Hello from a fast-starting CLI session.")
```

The user runs `praisonai chat`; only the chat module loads, so startup stays fast even with many subcommands installed.

```mermaid theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
graph LR
    A[📝 You run<br/>praisonai chat] --> B{🔍 Sub-command?}
    B -->|Yes| C[🧠 Load only<br/>chat module]
    B -->|No| D[⚡ Skip to<br/>prompt/YAML path]
    C --> E[✅ Run]
    D --> E

    classDef input fill:#8B0000,stroke:#7C90A0,color:#fff
    classDef decision fill:#F59E0B,stroke:#7C90A0,color:#fff
    classDef load fill:#189AB4,stroke:#7C90A0,color:#fff
    classDef skip fill:#6366F1,stroke:#7C90A0,color:#fff
    classDef result fill:#10B981,stroke:#7C90A0,color:#fff

    classDef agent fill:#8B0000,color:#fff
    classDef tool fill:#189AB4,color:#fff
    class A input
    class B decision
    class C load
    class D skip
    class E result
```

## How It Works

```mermaid theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
sequenceDiagram
    participant User
    participant Agent
    participant FastCliStartup

    User->>Agent: Request
    Agent->>FastCliStartup: Process
    FastCliStartup-->>Agent: Result
    Agent-->>User: Response
```

## Quick Start

<Steps>
  <Step title="Run a prompt directly">
    No sub-command is needed — and no sub-command modules load:

    ```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
    from praisonaiagents import Agent

    Agent(
        name="Assistant",
        instructions="You are a helpful assistant",
    ).start("Summarise the latest sales report")
    ```

    The CLI equivalent is identical in startup cost:

    ```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
    praisonai "Summarise the latest sales report"
    ```
  </Step>

  <Step title="Run a sub-command">
    Only the matching module loads — the other \~77 commands stay unloaded:

    ```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
    praisonai chat
    ```
  </Step>

  <Step title="List all available commands">
    ```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
    praisonai --help
    ```
  </Step>
</Steps>

***

## How It Works

```mermaid theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
sequenceDiagram
    participant User
    participant Agent
    participant Feature as Fast CLI Startup

    User->>Agent: Request
    Agent->>Feature: Process request
    Feature-->>Agent: Result
    Agent-->>User: Response
```

PraisonAI keeps a static map of command names (`_COMMAND_GROUPS` in `praisonai/cli/app.py`). When you run `praisonai chat`, the CLI checks that map and imports only the `chat` module. All other \~77 modules are never touched.

```mermaid theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
graph TB
    subgraph "CLI Startup"
        A[praisonai chat] --> B[Check _COMMAND_GROUPS]
        B --> C{Match found?}
        C -->|Yes| D[Import chat module only]
        C -->|No| E[Treat as prompt or YAML]
        D --> F[Run chat]
        E --> G[Run prompt/YAML]
    end

    classDef entry fill:#8B0000,stroke:#7C90A0,color:#fff
    classDef check fill:#F59E0B,stroke:#7C90A0,color:#fff
    classDef decision fill:#6366F1,stroke:#7C90A0,color:#fff
    classDef load fill:#189AB4,stroke:#7C90A0,color:#fff
    classDef run fill:#10B981,stroke:#7C90A0,color:#fff

    class A entry
    class B check
    class C decision
    class D,E load
    class F,G run
```

***

## Best Practices

<AccordionGroup>
  <Accordion title="You don't have to opt in">
    Lazy command dispatch is always on — no flag, no environment variable. Every `praisonai` invocation benefits automatically.
  </Accordion>

  <Accordion title="Adding a new sub-command">
    Add an entry to `_COMMAND_GROUPS` in `praisonai/cli/app.py`:

    ```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
    _COMMAND_GROUPS = {
        # existing entries ...
        "mycommand": ".commands.mycommand",
    }
    ```

    Without this entry, `praisonai --help` won't list your command and dispatch won't reach it.
  </Accordion>

  <Accordion title="When things go wrong">
    Run the built-in diagnostic to check your CLI setup:

    ```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
    praisonai doctor
    ```
  </Accordion>
</AccordionGroup>

***

## Related

<CardGroup cols={2}>
  <Card title="Lazy Imports & Fast Startup" icon="bolt" href="/docs/features/lazy-imports">
    SDK-side lazy imports for litellm, chromadb, and mem0 — a different but complementary optimization
  </Card>

  <Card title="Performance Benchmarks" icon="chart-line" href="/docs/features/performance-benchmarks">
    Measured startup times and memory usage across PraisonAI versions
  </Card>
</CardGroup>
