|
| 1 | +--- |
| 2 | +title: Cursor |
| 3 | +weight: 33 |
| 4 | +description: | |
| 5 | + Use Cursor in Docker Sandboxes with API key or proxy-managed OAuth |
| 6 | + authentication. |
| 7 | +keywords: docker sandboxes, cursor, cursor agent, ai agent, sbx |
| 8 | +--- |
| 9 | + |
| 10 | +{{< summary-bar feature_name="Docker Sandboxes sbx" >}} |
| 11 | + |
| 12 | +This guide covers authentication, configuration, and usage of Cursor in a |
| 13 | +sandboxed environment. |
| 14 | + |
| 15 | +Official documentation: [Cursor CLI](https://cursor.com/cli) |
| 16 | + |
| 17 | +## Quick start |
| 18 | + |
| 19 | +Create a sandbox and run Cursor for a project directory: |
| 20 | + |
| 21 | +```console |
| 22 | +$ sbx run cursor ~/my-project |
| 23 | +``` |
| 24 | + |
| 25 | +The workspace parameter is optional and defaults to the current directory: |
| 26 | + |
| 27 | +```console |
| 28 | +$ cd ~/my-project |
| 29 | +$ sbx run cursor |
| 30 | +``` |
| 31 | + |
| 32 | +## Authentication |
| 33 | + |
| 34 | +Cursor supports two authentication methods: an API key or OAuth. |
| 35 | + |
| 36 | +**API key**: Store your Cursor API key using |
| 37 | +[stored secrets](../security/credentials.md#stored-secrets): |
| 38 | + |
| 39 | +```console |
| 40 | +$ sbx secret set -g cursor |
| 41 | +``` |
| 42 | + |
| 43 | +Alternatively, export the `CURSOR_API_KEY` environment variable in your shell |
| 44 | +before running the sandbox. See |
| 45 | +[Credentials](../security/credentials.md) for details on both methods. |
| 46 | + |
| 47 | +**OAuth**: If no API key is set, Cursor prompts you to sign in interactively |
| 48 | +on first run. The proxy intercepts the token exchange with |
| 49 | +`api2.cursor.sh/auth/poll`, so credentials are managed by the host and aren't |
| 50 | +stored inside the sandbox. |
| 51 | + |
| 52 | +## Configuration |
| 53 | + |
| 54 | +Sandboxes don't pick up user-level configuration from your host, such as |
| 55 | +`~/.cursor`. Only project-level configuration in the working directory is |
| 56 | +available inside the sandbox. See |
| 57 | +[Why doesn't the sandbox use my user-level agent configuration?](../faq.md#why-doesnt-the-sandbox-use-my-user-level-agent-configuration) |
| 58 | +for workarounds. |
| 59 | + |
| 60 | +Cursor reads `AGENTS.md` from the workspace for agent-specific instructions. |
| 61 | + |
| 62 | +The sandbox runs Cursor in YOLO mode by default, which executes commands |
| 63 | +without approval prompts. Pass additional `cursor-agent` CLI options after |
| 64 | +`--`: |
| 65 | + |
| 66 | +```console |
| 67 | +$ sbx run cursor --name <sandbox-name> -- <cursor-options> |
| 68 | +``` |
| 69 | + |
| 70 | +## Base image |
| 71 | + |
| 72 | +Template: `docker/sandbox-templates:cursor-agent-docker` |
| 73 | + |
| 74 | +Preconfigured to run in YOLO mode with HTTP/1.1 and server-sent events for |
| 75 | +agent traffic so requests flow through the host proxy. Authentication state |
| 76 | +is persisted across sandbox restarts. |
| 77 | + |
| 78 | +See [Customize](../customize/) to pre-install tools or customize this |
| 79 | +environment. |
0 commit comments