|
| 1 | +--- |
| 2 | +name: stl-cli |
| 3 | +description: Use when working with the Stainless CLI (stl) to manage SDK generation projects, builds, branches, configs, and authentication. Covers all stl commands including auth, workspace, init, dev, lint, and API resources (projects, builds, orgs, user). |
| 4 | +--- |
| 5 | + |
| 6 | +# Stainless CLI (`stl`) |
| 7 | + |
| 8 | +## Overview |
| 9 | + |
| 10 | +`stl` is the CLI for the Stainless API — a platform that generates and manages SDKs from OpenAPI specs. Version `0.1.0-alpha.79`. |
| 11 | + |
| 12 | +## Global Options |
| 13 | + |
| 14 | +These apply to all API resource commands: |
| 15 | + |
| 16 | +| Flag | Description | |
| 17 | +|------|-------------| |
| 18 | +| `--debug` | Enable debug logging | |
| 19 | +| `--base-url string` | Override base URL for API requests | |
| 20 | +| `--format string` | Response format: `auto`, `explore`, `json`, `jsonl`, `pretty`, `raw`, `yaml` (default: `auto`) | |
| 21 | +| `--format-error string` | Error format (same options as `--format`) | |
| 22 | +| `--transform string` | GJSON transformation for data output | |
| 23 | +| `--transform-error string` | GJSON transformation for errors | |
| 24 | +| `--environment string` | Set the environment for API requests | |
| 25 | + |
| 26 | +## Auth |
| 27 | + |
| 28 | +``` |
| 29 | +stl auth login # OAuth browser-based login |
| 30 | +stl auth logout # Remove saved credentials |
| 31 | +stl auth status # Check current auth status |
| 32 | +``` |
| 33 | + |
| 34 | +`login` accepts `--client-id string` to override the OAuth client ID. |
| 35 | + |
| 36 | +## Workspace |
| 37 | + |
| 38 | +``` |
| 39 | +stl workspace init # Initialize workspace config in current directory |
| 40 | +stl workspace status # Show workspace configuration status |
| 41 | +``` |
| 42 | + |
| 43 | +Note: `workspace init` and `workspace status` do not accept `--help`/`-h` flags. |
| 44 | + |
| 45 | +## Init |
| 46 | + |
| 47 | +Set up a new Stainless project: |
| 48 | + |
| 49 | +``` |
| 50 | +stl init [options] |
| 51 | +``` |
| 52 | + |
| 53 | +| Flag | Description | |
| 54 | +|------|-------------| |
| 55 | +| `--org string` | Organization name | |
| 56 | +| `--project string` | Project slug | |
| 57 | +| `--display-name string` | Project display name | |
| 58 | +| `--targets string` | Comma-separated target languages | |
| 59 | +| `--openapi-spec / --oas string` | Path to OpenAPI spec file | |
| 60 | +| `--workspace-init` | Also initialize workspace configuration | |
| 61 | +| `--download-config` | Download Stainless config to workspace | |
| 62 | +| `--download-targets` | Download and configure SDK targets | |
| 63 | + |
| 64 | +## Dev / Preview |
| 65 | + |
| 66 | +Interactive development mode with build monitoring: |
| 67 | + |
| 68 | +``` |
| 69 | +stl dev [options] |
| 70 | +stl preview [options] # alias |
| 71 | +``` |
| 72 | + |
| 73 | +| Flag | Description | |
| 74 | +|------|-------------| |
| 75 | +| `-p / --project string` | Project name | |
| 76 | +| `--oas / --openapi-spec string` | Path to OpenAPI spec | |
| 77 | +| `--config / --stainless-config string` | Path to Stainless config | |
| 78 | +| `-b / --branch string` | Branch to use | |
| 79 | +| `-t / --target string` | Target language(s) — repeatable | |
| 80 | +| `-w / --watch` | Watch mode: rebuild when files change | |
| 81 | + |
| 82 | +## Lint |
| 83 | + |
| 84 | +``` |
| 85 | +stl lint [options] |
| 86 | +``` |
| 87 | + |
| 88 | +| Flag | Description | |
| 89 | +|------|-------------| |
| 90 | +| `-p / --project string` | Project name | |
| 91 | +| `--oas / --openapi-spec string` | Path to OpenAPI spec | |
| 92 | +| `--config / --stainless-config string` | Path to Stainless config | |
| 93 | +| `-w / --watch` | Watch for file changes and re-run | |
| 94 | + |
| 95 | +## MCP Server |
| 96 | + |
| 97 | +Run Stainless as an MCP server: |
| 98 | + |
| 99 | +``` |
| 100 | +stl mcp [options] |
| 101 | +``` |
| 102 | + |
| 103 | +| Flag | Description | |
| 104 | +|------|-------------| |
| 105 | +| `--transport string` | `stdio` (default, local) or `http` (remote) | |
| 106 | +| `--port number` | Port for http transport (default: 3000) | |
| 107 | +| `--socket string` | Unix socket for http transport | |
| 108 | +| `--tools array` | Explicitly enable tools: `code`, `docs` | |
| 109 | +| `--no-tools array` | Explicitly disable tools: `code`, `docs` | |
| 110 | +| `--code-execution-mode string` | `stainless-sandbox` (default) or `local` | |
| 111 | +| `--code-allow-http-gets` | Allow GET-mapped code tool methods | |
| 112 | +| `--code-allowed-methods array` | Regex patterns of allowed methods | |
| 113 | +| `--code-blocked-methods array` | Regex patterns of blocked methods | |
| 114 | +| `--stainless-api-key string` | API key for Stainless-hosted tool endpoints | |
| 115 | + |
| 116 | +--- |
| 117 | + |
| 118 | +## API Resources |
| 119 | + |
| 120 | +### `stl projects` |
| 121 | + |
| 122 | +| Command | Description | |
| 123 | +|---------|-------------| |
| 124 | +| `create` | Create a new project | |
| 125 | +| `retrieve` | Retrieve a project by name | |
| 126 | +| `update` | Update a project's properties | |
| 127 | +| `list` | List projects in an org (oldest→newest) | |
| 128 | +| `generate-commit-message` | AI commit message by comparing two git refs | |
| 129 | + |
| 130 | +**create** flags: `--display-name`, `--org`, `--slug`, `--target` (repeatable), `--revision string=any` (repeatable, file contents) |
| 131 | + |
| 132 | +**retrieve** flags: `--project` |
| 133 | + |
| 134 | +**update** flags: `--project`, `--display-name` |
| 135 | + |
| 136 | +**list** flags: `--org`, `--cursor`, `--limit` (default 10, max 100) |
| 137 | + |
| 138 | +**generate-commit-message** flags: `--project`, `--target`, `--base-ref`, `--head-ref` |
| 139 | + |
| 140 | +--- |
| 141 | + |
| 142 | +### `stl projects:branches` |
| 143 | + |
| 144 | +| Command | Description | |
| 145 | +|---------|-------------| |
| 146 | +| `create` | Create a new branch | |
| 147 | +| `retrieve` | Retrieve a branch by name | |
| 148 | +| `list` | List branches for a project | |
| 149 | +| `delete` | Delete a branch | |
| 150 | +| `rebase` | Rebase a branch onto another | |
| 151 | +| `reset` | Reset a branch | |
| 152 | + |
| 153 | +**create** flags: `--project`, `--branch`, `--branch-from`, `--force` (don't error if branch exists) |
| 154 | + |
| 155 | +**retrieve / delete** flags: `--project`, `--branch` |
| 156 | + |
| 157 | +**list** flags: `--project`, `--cursor`, `--limit` (default 10, max 100) |
| 158 | + |
| 159 | +**rebase** flags: `--project`, `--branch`, `--base` (default: `main`) |
| 160 | + |
| 161 | +**reset** flags: `--project`, `--branch`, `--target-config-sha` (required when resetting main) |
| 162 | + |
| 163 | +--- |
| 164 | + |
| 165 | +### `stl projects:configs` |
| 166 | + |
| 167 | +| Command | Description | |
| 168 | +|---------|-------------| |
| 169 | +| `retrieve` | Get config files for a project | |
| 170 | +| `guess` | AI-generated config suggestions from an OpenAPI spec | |
| 171 | + |
| 172 | +**retrieve** flags: `--project`, `--branch` (default: main), `--include` |
| 173 | + |
| 174 | +**guess** flags: `--project`, `--spec` (OpenAPI spec), `--branch` (default: main) |
| 175 | + |
| 176 | +--- |
| 177 | + |
| 178 | +### `stl builds` |
| 179 | + |
| 180 | +| Command | Description | |
| 181 | +|---------|-------------| |
| 182 | +| `create` | Create a build against an input revision | |
| 183 | +| `retrieve` | Retrieve a build by ID | |
| 184 | +| `list` | List user-triggered builds for a project | |
| 185 | +| `compare` | Create two comparable builds (base vs head) | |
| 186 | + |
| 187 | +**create** key flags: |
| 188 | + |
| 189 | +| Flag | Description | |
| 190 | +|------|-------------| |
| 191 | +| `--oas / --openapi-spec` | Path to OpenAPI spec | |
| 192 | +| `--config / --stainless-config` | Path to Stainless config | |
| 193 | +| `--project` | Project name | |
| 194 | +| `--branch` | Project branch | |
| 195 | +| `--target` (repeatable) | SDK targets to build (default: all) | |
| 196 | +| `--revision` | Branch name, commit SHA, merge command (`base..head`), or file contents | |
| 197 | +| `--wait string` | `all` (default), `commit`, or `none` | |
| 198 | +| `--pull` | Pull build outputs after completion (requires `--wait`) | |
| 199 | +| `--commit-message` | Commit message for new commit | |
| 200 | +| `--enable-ai-commit-message` | Generate AI commit messages | |
| 201 | +| `--target-commit-messages` (repeatable) | Per-SDK commit messages | |
| 202 | +| `--allow-empty` | Allow empty commits | |
| 203 | + |
| 204 | +**retrieve** flags: `--build-id` |
| 205 | + |
| 206 | +**list** flags: `--project`, `--branch`, `--cursor`, `--limit` (default 10, max 100), `--revision` |
| 207 | + |
| 208 | +**compare** flags: `--project`, `--target` (repeatable), `--base string=any` (repeatable), `--head string=any` (repeatable) |
| 209 | + |
| 210 | +--- |
| 211 | + |
| 212 | +### `stl builds:diagnostics` |
| 213 | + |
| 214 | +``` |
| 215 | +stl builds:diagnostics list |
| 216 | +``` |
| 217 | + |
| 218 | +| Flag | Description | |
| 219 | +|------|-------------| |
| 220 | +| `--build-id` | Build ID | |
| 221 | +| `--cursor` | Pagination cursor | |
| 222 | +| `--limit` | Default 100, max 100 | |
| 223 | +| `--severity` | Min severity: `fatal > error > warning > note` | |
| 224 | +| `--targets` | Comma-delimited language targets to filter | |
| 225 | + |
| 226 | +--- |
| 227 | + |
| 228 | +### `stl builds:target-outputs` |
| 229 | + |
| 230 | +``` |
| 231 | +stl builds:target-outputs retrieve [options] |
| 232 | +``` |
| 233 | + |
| 234 | +| Flag | Description | |
| 235 | +|------|-------------| |
| 236 | +| `--build-id` | Build ID | |
| 237 | +| `--project` | Project name (required if no build-id) | |
| 238 | +| `--branch` | Branch name (default: main) | |
| 239 | +| `--target` (repeatable) | SDK language target name(s) | |
| 240 | +| `--type` | Output type | |
| 241 | +| `--output` | Format: `url` (download URL) or `git` (temp access token) | |
| 242 | +| `--pull` | Pull the outputs | |
| 243 | + |
| 244 | +--- |
| 245 | + |
| 246 | +### `stl orgs` |
| 247 | + |
| 248 | +``` |
| 249 | +stl orgs retrieve --org <name> |
| 250 | +stl orgs list |
| 251 | +``` |
| 252 | + |
| 253 | +--- |
| 254 | + |
| 255 | +### `stl user` |
| 256 | + |
| 257 | +``` |
| 258 | +stl user retrieve # Get current authenticated user info |
| 259 | +``` |
| 260 | + |
| 261 | +--- |
| 262 | + |
| 263 | +## Common Workflows |
| 264 | + |
| 265 | +**Initial project setup:** |
| 266 | +```bash |
| 267 | +stl auth login |
| 268 | +stl init --org myorg --project myapi --targets typescript,python --oas ./openapi.yaml |
| 269 | +``` |
| 270 | + |
| 271 | +**Trigger a build and wait:** |
| 272 | +```bash |
| 273 | +stl builds create --project myapi --oas ./openapi.yaml --wait all --pull |
| 274 | +``` |
| 275 | + |
| 276 | +**Local dev loop:** |
| 277 | +```bash |
| 278 | +stl dev --project myapi --oas ./openapi.yaml --watch |
| 279 | +``` |
| 280 | + |
| 281 | +**Lint config:** |
| 282 | +```bash |
| 283 | +stl lint --oas ./openapi.yaml --config ./stainless.yaml --watch |
| 284 | +``` |
| 285 | + |
| 286 | +**Check a build's diagnostics:** |
| 287 | +```bash |
| 288 | +stl builds:diagnostics list --build-id <id> --severity warning |
| 289 | +``` |
| 290 | + |
| 291 | +**Download SDK output:** |
| 292 | +```bash |
| 293 | +stl builds:target-outputs retrieve --project myapi --target typescript --output git |
| 294 | +``` |
| 295 | + |
| 296 | +**Branch management:** |
| 297 | +```bash |
| 298 | +stl projects:branches create --project myapi --branch feature/new-endpoints --branch-from main |
| 299 | +stl projects:branches rebase --project myapi --branch feature/new-endpoints --base main |
| 300 | +stl projects:branches delete --project myapi --branch feature/new-endpoints |
| 301 | +``` |
0 commit comments