# Runs

> Run any command from a worktree on a fresh BareCI machine with bareci run or the run_create tool. Upload, logs, artifacts, shards, limits and lifecycle.

Source: https://bareci.com/docs/modules/runs

A run executes a command from your worktree, uncommitted changes included, on a fresh machine built from the repository's image. Output streams back, and the CLI exits with the command's exit code. Runs use the same machines, cap and isolation as CI, and spend no Actions minutes and no local CPU.

## From the CLI

```sh
bareci run -- bun test
```

| Flag                     | What it does                                                                                        |
| ------------------------ | --------------------------------------------------------------------------------------------------- |
| `--collect <path>`       | Bring a file or directory back (repeatable)                                                         |
| `--junit <path>`         | Bring a JUnit report back and summarise it (repeatable); it also feeds [Tests](https://bareci.com/docs/modules/tests) |
| `--shards <n>`           | Run on n machines with `BARECI_SHARD_INDEX` and `BARECI_SHARD_TOTAL` set                            |
| `--env NAME=value`, `-e` | Environment for the command (repeatable; never secrets)                                             |
| `--timeout <seconds>`    | Stop the command after this long (default 1800)                                                     |
| `--label <label>`        | The pool, for example `bareci-8`                                                                    |
| `--branch <name>`        | The branch the run is for (default: the current one)                                                |

Collected files are saved under `.bareci/out/runs/<id>/`.

## What is uploaded

The CLI packs tracked and untracked files that git does not ignore (`git ls-files -co --exclude-standard`), so `node_modules` and build output stay behind and the image's dependencies are used. The upload is at most 100 MB, as `tar.gz` or a git bundle.

## Lifecycle

A run moves `uploading → queued → running → passed | failed | timed_out`, or `cancelled`, or `expired` when no source arrives within an hour.

## From MCP or HTTP

1. `run_create` (`POST /v1/runs`) with `repo` and `command`. The answer carries a signed `upload` URL.
2. `PUT` the worktree to that URL. The run is queued.
3. `run_logs` (`GET /v1/runs/:id/logs?after=N&wait=S`) long-polls for output; read until `done`.
4. `run_artifacts` lists collected files and JUnit reports.

See the [Runs API](https://bareci.com/docs/api/runs).

## Limits

| Limit          | Value                                                                 |
| -------------- | --------------------------------------------------------------------- |
| Upload         | 100 MB; the upload URL is single-use and lasts an hour                |
| Timeout        | 30 minutes by default, at most 6 hours                                |
| Output kept    | 32 MB per run; past that the run notes the truncation and keeps going |
| Source kept    | Deleted when the run ends                                             |
| Artifacts kept | 7 days                                                                |

## Safety

The command runs as an unprivileged user with only the run's own environment and no secrets.
