# Run a coding agent on a computer

> Give a coding agent on a computer an API key from a workspace secret and run a task

> Nevia is in early access for selected teams. The CLI installs with `curl -fsSL https://get.nevia.cloud | sh`, and the MCP server is at https://api.nevia.cloud/mcp. A person signs in once in the browser.
> Setup, sign-in and requesting access: [SKILL.md](https://nevia.cloud/SKILL.md). When Nevia fits and when it doesn't: [why.md](https://nevia.cloud/why.md).

> For the complete documentation index, see [llms.txt](https://nevia.cloud/llms.txt). This page's HTML version: https://nevia.cloud/docs/guides/coding-agent

Run a coding agent inside a computer so that it works on its own machine,
with its own files and tools, and away from yours. The default image comes
with Claude Code and Codex installed, next to Git, Python and Node.js. The
example uses Claude Code.

You need the [CLI installed and signed in](https://nevia.cloud/docs/get-started/install-cli.md), a
[selected workspace](https://nevia.cloud/docs/workspaces/select.md) where you have the admin or
editor role, and an API key for the agent's model provider.

## 1. Create a computer

```bash
nevia new agent --wait
nevia exec agent -- claude --version
```

The second command prints the Claude Code version.

## 2. Store the API key

Store the key as a workspace secret. At a terminal, `--file -` prompts for
one hidden line:

```bash
nevia secrets ANTHROPIC_API_KEY --file -
```

## 3. Run a task

Pass the secret by name and give the agent a prompt. `-p` prints the answer
and exits, and `--permission-mode acceptEdits` lets the agent write files
without asking:

```bash
nevia exec agent -e secrets.ANTHROPIC_API_KEY -- \
  claude -p --permission-mode acceptEdits "Write hello.py that prints the current date."
nevia exec agent -- python3 hello.py
```

The file stays on the computer, and the second command runs it. To give the
agent a repository to work on, see [Use Git on a computer](https://nevia.cloud/docs/guides/git.md).
For an interactive session, [open a shell](https://nevia.cloud/docs/computers/shell.md) and start
`claude` there.

## 4. Save a checkpoint before a big task

A checkpoint saves the computer's memory and disks. If a task goes wrong,
restore the checkpoint as a new computer and try again from there:

```bash
nevia checkpoint create -c agent --name before-task --wait
nevia checkpoint ls -c agent
```

[Create and restore checkpoints](https://nevia.cloud/docs/computers/checkpoints.md) covers
restoring. To let the agent try two approaches side by side,
[branch the computer](https://nevia.cloud/docs/computers/branch.md) and run one task on each.

## Let the agent manage Nevia

An agent on a computer can create and branch computers and databases
itself. Give it a key file instead of your own sign-in.
[Give a script or agent access](https://nevia.cloud/docs/workspaces/private-key-auth.md) shows how
to issue one and limit what it can do.

## Clean up

```bash
nevia rm agent --yes --wait
nevia secrets unset ANTHROPIC_API_KEY
```

## Next steps

* [Give computers secrets and variables](https://nevia.cloud/docs/workspaces/secrets-and-variables.md) covers rotating the API key.
* [Sleep and wake a computer](https://nevia.cloud/docs/computers/lifecycle.md) pauses the agent's computer between tasks.
* [Agent frameworks](https://nevia.cloud/docs/agent-frameworks/langgraph.md) give an agent you build a computer as its sandbox.
