# swarmops ws discard

> Release: 0.11.0 · Last changed: 2026-11-08 · Source: https://github.com/KeiaiLab/SwarmOps/blob/stable/docs/reference/commands/ws-discard.md

Restore paths of a workspace from its head, every changed one without a PATH: the edits are lost.

```yaml
title: "swarmops ws discard"
description: "Restore paths of a workspace from its head, every changed one without a PATH: the edits are lost."
group: "workspaces"
since: "0.3.0"
mutates: true
identity_required: false
mcp_tool: "ws_discard"
envelope_op: "ws_discard"
exit_codes: [0, 4]
errors: [E_WS_LOCKED]
syntax: "swarmops ws discard [OPTIONS] [PATH]..."
```

## Syntax

```text
swarmops ws discard [OPTIONS] [PATH]...
```

## Required arguments

None.

## Optional arguments

The command also takes the [global options](../cli.md#global-options).

### `--ws`

Syntax: `--ws <NAME>`.

The workspace, by its name in the store's registry (default: the one around the working directory).

### `--ws-path`

Syntax: `--ws-path <DIR>`.

The workspace's directory.

### `PATH`

Syntax: `<PATH>`.

The repository paths to restore.

### `--status-after`

Syntax: `--status-after <STATUS_AFTER>`.
Default: `page`.

page: the first page of the status follows the result; none: it is left out. Values: `page`: The first page of the status; `none`: No status.

## Examples

### CLI

```sh
swarmops --repo [tmp]/store --as agent/worker-17 ws discard --ws w1
```

```json
{
  "ok": false,
  "op": "ws_discard",
  "api": 1,
  "error": {
    "code": "E_WS_LOCKED",
    "message": "another mutation of this workspace held its lock for 5 s",
    "retryable": true,
    "exit": 4,
    "details": {},
    "hint": "run the command again once the other one has finished"
  },
  "meta": {
    "repo": "[tmp]/store",
    "elapsed_ms": "[elapsed_ms]",
    "resolved": {},
    "auth": "trust"
  }
}
```

Exit code 4. Recorded by the CLI tests. A name in square brackets, such as `[tmp]` or `[c1]`, stands for what differs from run to run: the test's temporary directory, an id, a time.

### MCP

No recorded example yet.

## Return information

`result` is a `WsDiscardResp` (`swarmops schema WsDiscardResp` prints its JSON Schema).

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `discarded` | `array of string` | yes | The paths restored. |
| `status_after` | `WsStatus or null` | no | The status after the mutation; omitted when the request said `none`. |

Envelope `op`: `ws_discard`.

Exit codes:

- `0`: Success.
- `4`: The operation can succeed when it is run again.

## Errors

- [`E_WS_LOCKED`](../errors.md#e_ws_locked) (exit 4): Another mutation held the workspace's lock for the whole wait (`details.holder`, when it is known); running the operation again can succeed.

Any command that opens a store may also fail with a store error, such as [`E_NOT_A_REPO`](../errors.md#e_not_a_repo), [`E_IO`](../errors.md#e_io) or [`E_STORE_CORRUPT`](../errors.md#e_store_corrupt); a command line the grammar refuses is [`E_INVALID_ARG`](../errors.md#e_invalid_arg) (exit 2).

## See also

- [`swarmops ws create`](ws-create.md)
- [`swarmops ws status`](ws-status.md)
- [`swarmops ws diff`](ws-diff.md)
- [`swarmops ws commit`](ws-commit.md)
- [`swarmops ws rebase`](ws-rebase.md)
- [`swarmops ws resolve`](ws-resolve.md)
- [`swarmops ws land`](ws-land.md)
- [`swarmops ws materialize`](ws-materialize.md)
- [`swarmops ws snapshot`](ws-snapshot.md)
- [`swarmops ws list`](ws-list.md)
- [`swarmops ws info`](ws-info.md)
- [`swarmops ws delete`](ws-delete.md)
- [`swarmops ws hook`](ws-hook.md)
- [CLI reference](../cli.md)
- [Error codes](../errors.md)
