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

# ubx chat

> Conversational multi-turn infrastructure authoring — describe infrastructure in plain English and ubx generates XCL blocks.

`ubx chat` starts an interactive session where you describe infrastructure in plain English and ubx generates XCL blocks. All existing `.xcl` files in the current directory are read as context so generated code can reference existing resources.

## Usage

```bash theme={"theme":"css-variables","languages":{"custom":["/languages/xcl.json"]}}
ubx chat [flags]
```

## Flags

| Flag               | Description                                                      |
| ------------------ | ---------------------------------------------------------------- |
| `--append <file>`  | Append confirmed code blocks to this file (default: `main.xcl`)  |
| `--context <file>` | Use only this file as context (default: all `.xcl` files in cwd) |

## Requirements

Requires `UBX_AI_API_KEY` environment variable or `ai.api_key` in `workspace.xcl`.

## Examples

```bash theme={"theme":"css-variables","languages":{"custom":["/languages/xcl.json"]}}
ubx chat                          # reads all .xcl files in cwd as context
ubx chat --append infra.xcl       # append confirmed blocks to infra.xcl
ubx chat --context main.xcl       # use only main.xcl as context
```

## Session commands

| Input            | Effect                                            |
| ---------------- | ------------------------------------------------- |
| (Enter)          | Send your message                                 |
| `y`              | Append the generated XCL block to the target file |
| `N`              | Discard the block and continue chatting           |
| `e` or `edit`    | Open `$EDITOR` to edit the block before appending |
| `exit` or `quit` | End the session                                   |

## Example session

```
  ◆ Chat       reading 2 .xcl files as context
  ◆ Chat       UBX_AI_API_KEY detected

> Add an S3 bucket for storing application logs, with lifecycle rules to
  move objects to Glacier after 30 days

  logs_bucket = aws.s3.Bucket {
    bucket = "${input.env}-app-logs"
    lifecycle_rules = [{
      id      = "archive-to-glacier"
      enabled = true
      transition = {
        days          = 30
        storage_class = "GLACIER"
      }
    }]
  }

  Append to main.xcl? [y/N/e] y

  ✓  appended to main.xcl

> Add an output for the bucket name
  ...
```
