---
title: "vakna shell: run a command in a box"
description: "Run a command in a box; its output and exit code pass through."
command: "vakna shell"
generated: scripts/generate.ts
verified:
  cli: "0.0.0-mock"
  date: "2026-10-20"
---

`vakna shell`: run a command in a box; its output and exit code pass through.

## Synopsis

```sh
vakna shell <box> -- <command>
```

## Flags

| Flag | Default | What it does |
| -- | -- | -- |
| `--format <format>` | `text` | text, or json: one JSON object per line |
| `--json` | `off` | the same as --format json |
| `-h, --help` | `off` | this help |

## Examples

### Example

```sh
$ vakna shell api -- pnpm test
```

```prints
212 passed, 0 failed
ran pnpm test · exit 0 38.24s
```

Exit code 0.

### Another example

```sh
$ tar c . | vakna shell api -- tar x -C /src
```

```prints
ran tar x -C /src · exit 0 0.40s
```

Exit code 0.

### When it fails

```sh
$ vakna shell docs -- ls
```

```prints
vakna: box docs is suspended
hint: vakna resume docs  # suspended 2h 10m
```

Exit code 255.

## Exit codes

| Code | Meaning |
| -- | -- |
| 0 | ok |
| 2 | usage: a missing argument, an unknown flag or command |
| 255 | vakna failed under shell, run, try or fork |

## JSON output

With `--format json` (or `--json`) every line is one JSON object. `v` is the format's version; `mocked` marks numbers from the mock.

```sh
$ vakna shell api --json -- pnpm test
```

```prints
212 passed, 0 failed
{"v":1,"event":"ran","box":"api","id":"sbx_eu1a_01JB7X9K3M4N5P6Q7R8S9T0V1W","command":"pnpm test","exit":0,"ms":38240,"mocked":true}
```

## Errors

- [`vakna: unknown command, unknown flag or missing argument`](https://vakna.com/docs/errors/usage): Run `vakna <command> --help` and fix the command line it points to.
- [`vakna: no box "<box>"`](https://vakna.com/docs/errors/not_found): Run `vakna list` and use a name from it.
- [`vakna: "<id>" matches more than one box`](https://vakna.com/docs/errors/ambiguous): Use the box's name or its full id; `vakna list` shows both.
- [`vakna: box <box> is suspended`](https://vakna.com/docs/errors/suspended): Run `vakna resume <box>`, then run your command again.
- [`vakna: lockdown blocked <host>`](https://vakna.com/docs/errors/egress_blocked): Run `vakna net allow <host>` with the host the error names, then run your command again.

## --help

This page and the help text come from one definition.

```prints
vakna shell · run a command in a box; its output and exit code pass through

usage
  vakna shell <box> -- <command>

flags
  --format <format>  text, or json: one JSON object per line  (default: text)
  --json             the same as --format json  (default: off)
  -h, --help         this help  (default: off)

examples
  vakna shell api -- pnpm test
  tar c . | vakna shell api -- tar x -C /src

exit codes
  0    ok
  2    usage: a missing argument, an unknown flag or command
  255  vakna failed under shell, run, try or fork
```
