#### Features

# Cloud send

This page covers sending from the Terminal UI. For where the work runs, see [Cloud Agents](/build/agents-window/cloud-agent).

Cloud send hands the session you have open to a cloud agent, so the work carries on after you close the terminal. The agent starts with a copy of your conversation and your code, including uncommitted work. It needs Grok Build 2.0 or later: `grok --version` shows a version that starts with `2.`.

## Before you send

* Work in a git repository with an `origin` remote and at least one commit.
* Connect source control for that repository on your Grok Build account, so the cloud agent can clone it.
* Finish or abort any merge, rebase, cherry-pick, or revert, and resolve any conflicts.
* Wait for the running turn, and any subagents or side questions, to finish.

To connect source control and set up the environment the agent runs in, see [How to access](/build/agents-window/cloud-agent#how-to-access) and [Cloud environment setup](/build/agents-window/cloud-agent/setup).

## Sending a session

1. Type `&` on an empty prompt. The prompt now starts with `&`, and the label on its border reads `Send to cloud agent`.
2. Type what the agent should do next, or leave it blank to have it continue the current task.
3. Press `Enter`.

To go back to a normal prompt without sending, clear the message and press `Backspace` or `Esc`.

## What the cloud agent receives

The cloud agent gets the conversation and the session's model. The conversation is sent as is, including the contents of files the session read. If that model isn't available to cloud agents, the agent starts on your account's default model and the TUI says so. Images in your message aren't sent.

It gets your code from `origin`, not from your computer:

* If your checkout matches your branch on `origin`, nothing is pushed.
* Otherwise, cloud send pushes your unpushed commits, uncommitted changes, and untracked files to a new temporary branch on `origin`, and the agent starts from that.

Your branch, your staged changes, and your files don't change. Commit hooks and commit signing don't run; the repository's pre-push hook does.

The temporary branch leaves out files git ignores. It also leaves out uncommitted files whose names match a fixed list of credential files, such as `.env`, `.env.local`, `*.pem`, `*.key`, and `.npmrc`, and anything under `.ssh/` or `.aws/`. Any other file that holds a secret is pushed, so add it to `.gitignore` before you send, and unstage it with `git restore --staged <file>` if you've run `git add` on it. A file you've already committed is sent whatever its name, edits included, and `.gitignore` doesn't change that.

## Stopping a send

To stop a send, press `Esc` or `Ctrl+C`. Grok deletes the temporary branch if it pushed one and puts your message back in the prompt. If you stop too late, the agent starts anyway and the TUI shows its link.

## After the agent starts

The TUI quits and prints a link to the agent's page, and the name of the temporary branch if it pushed one. Prompts you submitted during the send are printed as `Not sent:` lines, so copy any you still need.

Open the link to follow the agent in the Grok Build web app, or run `grok cloud list --format text` to see your cloud agents with their status and branch. `grok cloud get <id> --format text` adds the pull request link.

The local session isn't changed. Open it again with [`grok --resume`](/build/features/sessions#resuming).

The temporary branch stays on `origin`. Delete it with `git push origin --delete <branch>` when you're done.

## Sending from the shell

`grok cloud send` starts a cloud agent without opening the TUI. Run it inside the repository:

```bash customLanguage="bash"
# A new agent, from a message
grok cloud send -m "Fix the flaky checkout test"

# A saved session, with a message
grok cloud send --session <session-id> -m "Open the pull request"
```

| Flag | What it does |
| ---- | ------------ |
| `-m`, `--message <text>` | The agent's first message. Required without `--session` |
| `--session <id>` | The session to send, by the ID `grok --resume` uses |
| `--model <name>` | The agent's model. Defaults to the session's, then your default model |
| `--push` | Push the current branch first if `origin` doesn't have it |

It refuses a detached HEAD, and a branch that isn't on `origin` unless you pass `--push`.

## Troubleshooting

A send that can't begin says what's missing and keeps your message in the prompt. One that fails later writes its reason in the session after `Couldn't send to cloud:`.

`couldn't push the cloud agent's branch: …` is followed by git's own output. Check that you can push to `origin`.

After `Failed to start the cloud agent, though it may have been created; …`, run `grok cloud list --format text` before you send again, so you don't start a second agent.

If `&` types an ordinary `&` on an empty prompt, cloud agents are turned off. Run `grok cloud list --format text`; its reply names the setting.
