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

# CLI Workflows

> Repeatable operational workflows — and the deterministic form to use once they run unattended.

# CLI Workflows

Common operational flows, in two forms: natural language for working interactively, and
`stateset-direct` for the same workflow once it runs unattended.

<Note>
  Every write needs `--apply`. Run the read steps first — they cost nothing and they tell you whether
  the write is the one you meant.
</Note>

## Order fulfilment

**Interactively:**

```bash theme={null}
stateset "show me pending orders"
stateset "show order #12345"
stateset --apply "ship order #12345 with tracking FEDEX123"
```

**Scripted** — same effect, no interpretation layer:

```bash theme={null}
stateset-direct orders list
stateset-direct --apply orders ship <order-id> FEDEX123
```

## Returns processing

```bash theme={null}
stateset "list returns awaiting review"
stateset --apply "approve return RMA-1001"
stateset --apply "refund return RMA-1001 for $29.99"
```

<Warning>
  Approving a return doesn't restock anything — `markReceived` does, when the parcel actually arrives.
  Refunding before receipt means you've paid out on an item that may never come back. See the
  [returns workflow](/stateset-icommerce/stateset-icommerce-returns-workflow).
</Warning>

## Inventory adjustment

```bash theme={null}
stateset --apply "adjust inventory for sku WIDGET-001 by -5 at warehouse LA"
```

```bash theme={null}
stateset-direct --apply inventory adjust WIDGET-001 -5 "Sold 5 units"
```

Always pass a reason. Adjustments are recorded as movements with an audit trail, and a reason is
what makes a later discrepancy traceable to the correction that caused it.

## Batch work

For repeated operations, put the requests in a file rather than looping the shell:

```bash theme={null}
stateset --apply --batch requests.txt
```

Sessions carry context, so a multi-step flow can refer back:

```bash theme={null}
stateset --apply "create an order for that customer with 2 widgets at $29.99"
stateset --apply --resume <session-id> "ship that order with tracking ABC123"
```

## Parsing output

```bash theme={null}
stateset --json "show me pending orders" | jq '.orders[].id'
```

Use `--json` whenever something downstream reads the result. Prose output shape isn't a contract;
the JSON shape is.

## Promoting a workflow to production

Once a workflow is doing real work on a schedule, move it off natural language:

| Stage      | Form                                              |
| ---------- | ------------------------------------------------- |
| Exploring  | `stateset "…"` — read-only, no flag               |
| Confirming | `stateset --apply "…"` — watch what it does       |
| Scripted   | `stateset-direct --apply …` — deterministic       |
| Scheduled  | `stateset-autonomous` — jobs, policies, approvals |

<Warning>
  Don't leave natural language in a cron job. The same sentence can resolve to a different action as
  the model changes, and a scheduled task is exactly where nobody is watching when it does.
</Warning>

## Related

* [CLI Reference](/stateset-icommerce/stateset-icommerce-cli-reference) — all three binaries
* [CLI Safety Model](/stateset-icommerce/stateset-icommerce-cli-safety)
* [Order Lifecycle](/stateset-icommerce/stateset-icommerce-order-lifecycle)
* [Scenarios](/stateset-icommerce/stateset-icommerce-scenarios)
