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

# Code Mode CLI

> Command-line interface for Code Mode tool

```mermaid theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
graph LR
    U[Input] --> A[Agent]
    A --> O[Output]

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

    class A agent
    class U,O tool
```

# Code Mode CLI

Use Code Mode from the command line for code generation and editing.

## Commands

### Generate Code

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
praisonai-ts tools run code-mode \
  --action generate \
  --content "Create a REST API with Express" \
  --language typescript
```

### Edit Code

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
praisonai-ts tools run code-mode \
  --action edit \
  --file ./src/utils.ts \
  --content "Add error handling"
```

### Explain Code

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
praisonai-ts tools run code-mode \
  --action explain \
  --file ./src/complex.ts
```

### Review Code

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
praisonai-ts tools run code-mode \
  --action review \
  --file ./src/api.ts
```

## Options

| Option       | Type    | Default      | Description                             |
| ------------ | ------- | ------------ | --------------------------------------- |
| `--action`   | string  | `generate`   | Action: generate, edit, explain, review |
| `--content`  | string  | -            | Description or instructions             |
| `--file`     | string  | -            | Target file path                        |
| `--language` | string  | `typescript` | Programming language                    |
| `--format`   | boolean | `true`       | Format output                           |
| `--output`   | string  | -            | Output file path                        |

## Examples

### Generate Python Script

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
praisonai-ts tools run code-mode \
  --action generate \
  --language python \
  --content "Web scraper for news articles" \
  --output scraper.py
```

### Refactor File

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
praisonai-ts tools run code-mode \
  --action edit \
  --file ./legacy.js \
  --content "Convert to modern ES6+ syntax"
```

## Environment Variables

| Variable         | Required | Description         |
| ---------------- | -------- | ------------------- |
| `OPENAI_API_KEY` | Yes      | For code generation |

## Related

<CardGroup cols={2}>
  <Card title="Code Mode" icon="book" href="/docs/js/tools/code-mode">
    Code documentation
  </Card>
</CardGroup>
