> Documentation index: https://rift.sh/llms.txt

[Use Rift with your agent](https://rift.sh/docs/use-with.md)

# Use Rift with Modal

Modal runs the code and Rift keeps the files. Rift runs on Linux, which is what a Modal container runs.

## Set it up

On your own machine, make an invite for the sandbox and share the folder the run should write to.

```
$ rift invite modal-run
$ rift share runs/modal-1 modal-run
```

Give the sandbox the token as a secret, for example an environment variable named `RIFT_INVITE`. The sandbox needs outbound network access.

A sandbox that kept its disk is already joined. Run `rift status` first, and skip the two commands below if it prints a line that contains `folder at`. Otherwise install Rift and join.

```
$ curl -fsSL https://rift.sh/install | sh
$ rift init --invite "$RIFT_INVITE"
```

To skip the install on a fresh sandbox, add the first command to the image or template it boots from. Have the agent keep its work in the shared folder. In the sandbox it appears under its own name, at `~/rift/modal-1`.

## What you get

Files the agent writes there reach your machines as they are written. When the sandbox ends, they are still on your machines. A later sandbox that joins and is given the same folder starts with those files.

Before the sandbox stops, run `rift status` and wait for `in sync`. A file still uploading when it stops is lost. When the run is over, remove its access.

```
# your machine
$ rift unshare runs/modal-1 modal-run
```

The token still lets a machine join under that name, with no folders. If it may have leaked, share nothing more with that name and make an invite under a new name.

## How they differ

The comparison says what each one does, who can read your files and when to choose which.

[Rift vs Modal](https://rift.sh/compare/rift-vs-modal.md)
