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

# Output formats & automation

> Render lsh list results as JSON, YAML, or CSV, filter them with JMESPath, and control pagination for scripts, CI, and AI agents

Every `lsh` `list` command can render its results in a machine-readable format that's easy to consume from scripts, CI pipelines, and AI agents. Output format, filtering, and pagination all work the same way across every list command.

You can also run `lsh output-formats` for the built-in version of this guide.

## Output formats

Use the global `--output` (or `-o`) flag to choose how results are rendered. The default is a human-readable table.

```shell theme={null}
lsh servers list -o table   # human-readable table (default)
lsh servers list -o json    # JSON
lsh servers list -o yaml    # YAML
lsh servers list -o csv     # CSV (header row + one row per item)
lsh servers list --json     # shortcut for -o json
```

Structured formats (`json`, `yaml`, `csv`) are honored everywhere, including when you pipe the output to another command. An empty result set prints `[]` in JSON, so your scripts always receive valid JSON to parse.

## Filtering with `--query`

The `--query` flag post-processes structured output with a [JMESPath](https://jmespath.org/) expression, so you can filter and reshape results without piping to `jq` or another tool. It works with `json`, `yaml`, and `csv`.

```shell theme={null}
# Only the IDs of servers that are powered on
lsh servers list --query "[?status=='on'].id" -o json

# A projection of selected fields
lsh servers list --query "[].{id: id, host: hostname}" -o yaml
```

`--query` requires a structured output format, so pair it with `-o json`, `-o yaml`, or `-o csv`. The expression is validated up front: an invalid query fails immediately with a non-zero exit code instead of producing partial output.

## Pagination

List commands fetch every page by default. These global flags give you control over large listings:

| Flag              | Purpose                                                                                                          |
| ----------------- | ---------------------------------------------------------------------------------------------------------------- |
| `--page-size <N>` | Items requested per API page (default `100`).                                                                    |
| `--max-items <N>` | Stop after `N` items across all pages (`0` = no limit).                                                          |
| `--no-paginate`   | Fetch only the first page. If more results exist, the next page number is printed to `stderr` so you can resume. |

```shell theme={null}
lsh servers list --page-size 10 --max-items 50   # at most 50 items, fetched in pages of 10
lsh servers list --no-paginate -o json           # first page only
```

## Environment variables

| Variable             | Purpose                                                                                                                                    |
| -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------ |
| `LSH_OUTPUT`         | Default output format (`table`, `json`, `yaml`, or `csv`). Precedence is `--output` flag > `LSH_OUTPUT` > config file > default (`table`). |
| `LSH_CLASSIC_OUTPUT` | Set to `true` to force the legacy plain-ASCII table. An explicit `-o json/yaml/csv` still takes precedence.                                |

Set `LSH_OUTPUT` to avoid passing `-o` on every command:

```shell theme={null}
export LSH_OUTPUT=json
lsh servers list   # prints JSON
```
