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

# Sessions

> Run, attach, list, kill, and manage persistent sessions.

# Sessions

Sessions are persistent PTY processes that run in the background. They survive disconnects — start a process, close your terminal, reconnect later.

<Note>
  `cw run` creates a local PTY session. `cw launch` creates a workspace on the platform. See [Platform commands](/cli/platform) for workspace management.
</Note>

## run

Start a new session in a persistent PTY.

```bash theme={null}
cw run [name] [--dir <dir>] [--tag <tag>...] -- <command> [args...]
```

| Flag    | Description                                                          |
| ------- | -------------------------------------------------------------------- |
| `name`  | Optional positional name before `--` for stable messaging identifier |
| `--dir` | Working directory for the process                                    |
| `--tag` | Tags for filtering and orchestration (repeatable)                    |

```bash theme={null}
# Run with tags
cw run worker --dir ~/project --tag build -- claude -p "refactor the auth module"

# Run unnamed
cw run --tag lint -- eslint src/
```

## attach

Connect to a running session interactively. Detach with `Ctrl+B d`.

```bash theme={null}
cw attach [<id>] [--no-history]
```

| Flag           | Description                                                   |
| -------------- | ------------------------------------------------------------- |
| `id`           | Session ID. Omit to auto-select the oldest unattached session |
| `--no-history` | Don't replay buffered output on attach                        |

## list

Show all sessions with status, tags, age, and command.

```bash theme={null}
cw list [node] [--json]
```

```
 ID  NAME      STATUS     TAGS           AGE     COMMAND
  1  planner   running    worker,build   2m ago  claude -p "refactor the auth module"
  2  coder     running    worker         45s     claude -p "implement changes"
```

## kill

Terminate a session by ID, tag, or all.

```bash theme={null}
cw kill <id> [--all] [--tag <tag>]
```

```bash theme={null}
cw kill 1                    # kill session 1
cw kill --tag worker         # kill all workers
cw kill --all                # kill everything
```

## logs

View captured output without attaching.

```bash theme={null}
cw logs <id> [--follow] [--tail <N>]
```

| Flag             | Description                    |
| ---------------- | ------------------------------ |
| `--follow`, `-f` | Stream new output in real-time |
| `--tail`         | Show last N lines              |

## send

Send input to a session without attaching.

```bash theme={null}
cw send <id> [input] [--stdin] [--file <path>] [--no-newline]
```

| Flag           | Description                         |
| -------------- | ----------------------------------- |
| `input`        | Text to send as positional argument |
| `--stdin`      | Read input from stdin               |
| `--file`       | Read input from a file              |
| `--no-newline` | Don't append a newline after input  |

## watch

Monitor a session in real-time without attaching. Read-only observation.

```bash theme={null}
cw watch <id> [--tail <N>] [--no-history] [--timeout <s>]
```

## status

Get detailed session info including exit code, duration, tags, PID, and output stats.

```bash theme={null}
cw status <id> [--json]
```
