# basemodo run

Run a one-off command inside an App's Machine (a migration, a script).

```sh
basemodo run [OPTIONS] <COMMAND>...
```

It runs where the App's data is: with its volume at /data (its database at /data/app.db) and the environment its processes started with at its latest Deploy, Secrets included. One argument is a shell line run with sh -c ("npm run migrate && echo done"); several are quoted into one. Its output is printed as it comes, and the CLI exits with its exit code (124 when it ran past --timeout). A sleeping App is woken to run it.

## Arguments

- `COMMAND...` (required): The command to run in the App's Machine.
- `--app <APP>`: The App to run it in. Default: the one named after the current folder.
- `--timeout <SECONDS>`: How long it may run, in seconds (at most 900). Default: `60`.

Like every command, it also takes the [global options](https://basemodo.com/docs/cli#global-options) `--json` and `--api-url`.

## Examples

Run a migration:

```sh
basemodo run "npm run migrate"
```

Look at the App's disk (several arguments after -- are one command):

```sh
basemodo run -- ls -la /data
```

Run a long import, for up to 10 minutes:

```sh
basemodo run --timeout 600 "python import.py"
```

## Output

With `--json`, it prints {"command", "exit_code" (null when it timed out), "timed_out", "stdout", "stderr"}; while it runs, {"event": "output", "stream", "text"} lines on stderr. Run by an agent (an MCP tool), it waits for the command at most 45 seconds, as deploy does, so no client cuts the call; the command runs on, within its own timeout, whatever the call answers. One still running then is a result, not an error: what it printed so far, "running": true, its "id" and "next", which says to call runs with that id until it ends. Never run the same command again while it runs: it would run twice (the same command still running is refused with code run_still_running).

## From an agent

Basemodo's [MCP](https://basemodo.com/docs/mcp) serves it as the tool [`run`](https://basemodo.com/docs/mcp/tools/run). It changes things, so an agent's client may ask you before it runs. Its arguments are the command's, named as JSON keys: `command` (list of text), `app` (text), `timeout` (number). It answers what the command prints with `--json`.

## Explained in

- [Data: the disk, SQLite, db, run and Backups](https://basemodo.com/docs/data)
- [How Apps run](https://basemodo.com/docs/how-apps-run)