---
title: CLI Overview
description: The stx command-line interface for building, previewing, and deploying Syntext documentation.
icon: terminal
---

# CLI Overview

The `stx` CLI is your primary interface for working with Syntext documentation. It handles project initialization, local development, building, and deployment.

## Installation

<CodeGroup>

```bash title="curl (Recommended)"
curl -fsSL https://get.syntext.dev | sh
```

```bash title="Homebrew"
brew install syntext-dev/tap/stx
```

```bash title="npm"
npm install -g @syntext/cli
```

</CodeGroup>

Verify installation:

```bash
stx --version
```

## Quick Reference

| Command | Description |
|---------|-------------|
| `stx init` | Initialize a new docs project |
| `stx dev` | Start the development server |
| `stx build` | Build on the Syntext backend and download the static site |
| `stx deploy` | Deploy to Syntext CDN |
| `stx generate` | Generate API docs from OpenAPI/code |
| `stx check` | Validate configuration and content |

## Global Flags

All commands support these global flags:

| Flag | Alias | Description |
|------|-------|-------------|
| `--help` | `-h` | Show help for a command |
| `--version` | `-v` | Show CLI version |
| `--config` | `-c` | Path to config file (default: `syntext.json`) |
| `--cwd` | | Working directory (default: current directory) |
| `--verbose` | | Enable verbose output |
| `--json` | | Output as JSON (for scripting) |

## Configuration Files

The CLI looks for configuration in these locations (in order):

1. `.syntext/syntext.json` or `.syntext/stx.json`
2. `.syntext/syntext.yaml` or `.syntext/stx.yaml`
3. `.stx/syntext.json` or `.stx/stx.json`
4. `.stx/syntext.yaml` or `.stx/stx.yaml`
5. `syntext.json` or `stx.json` (project root)
6. `syntext.yaml` or `stx.yaml` (project root)

<Note>
The first matching file is used. JSON and YAML formats are functionally equivalent — use whichever you prefer. For monorepos, place configuration in `.syntext/` to keep the root clean.
</Note>

## Project Detection

The CLI auto-detects your project layout:

**Standalone** — Config at repository root:
```
docs-repo/
├── syntext.json
├── docs/
└── public/
```

**Embedded** — Config inside `.syntext/` or `.stx/`:
```
my-api/
├── src/
├── package.json
└── .syntext/
    ├── syntext.json
    └── docs/
```

## Environment Variables

| Variable | Description |
|----------|-------------|
| `SYNTEXT_API_KEY` | API key for authenticated operations |
| `SYNTEXT_PROJECT_ID` | Override project ID |
| `SYNTEXT_ENV` | Environment: `production`, `staging` |
| `NO_COLOR` | Disable colored output |

## Exit Codes

| Code | Meaning |
|------|---------|
| `0` | Success |
| `1` | General error |
| `2` | Configuration error |
| `3` | Validation error |
| `4` | Network error |
| `5` | Authentication error |

## Command Details

<CardGroup cols={2}>
  <Card title="stx init" icon="plus" href="/cli/init">
    Initialize a new documentation project
  </Card>
  <Card title="stx dev" icon="play" href="/cli/dev">
    Start the development server
  </Card>
  <Card title="stx build" icon="hammer" href="/cli/build">
    Build static site for production
  </Card>
  <Card title="stx deploy" icon="rocket" href="/cli/deploy">
    Deploy to Syntext CDN
  </Card>
  <Card title="stx generate" icon="sparkles" href="/cli/generate">
    Generate docs from OpenAPI or code
  </Card>
  <Card title="stx check" icon="check" href="/cli/check">
    Validate configuration and content
  </Card>
</CardGroup>
