Skip to main content
Run the Cursor command-line interface (CLI) against a repository in a CoreWeave sandbox. Attach your terminal for interactive work, or run a prompt through the Sandbox software development kit (SDK) and collect the result. The CLI process, workspace, and commands run in the sandbox. Model requests go to Cursor.
CoreWeave Serverless sandboxes are in public preview.
Cursor also supports Self-Hosted Machines, where Cursor’s cloud runs the agent loop and a separate worker executes tool calls.

Prerequisites

Before you begin, you need the following:
  • A W&B API key or CoreWeave API access token with sandbox access. See Choose a credential.
  • A Cursor user API key and access to a model supported by Cursor CLI.
  • A public repository URL. Private repositories require Git credentials inside the sandbox.
  • Outbound connectivity to Cursor, its download host, and your Git host.
In your local terminal, set the sandbox credential you want to use:
Unsetting CWSANDBOX_API_KEY makes cws-agent select W&B authentication.
Cursor reads CURSOR_API_KEY inside the sandbox. Cursor can send prompts, file contents, and tool output to its service. Use a repository and credentials appropriate for the task.

Run Cursor CLI with cws-agent

Use cws-agent to create a sandbox, install Cursor, and attach your terminal. Interactive attachment requires an interactive terminal (TTY) on macOS, Linux, or Windows Subsystem for Linux (WSL). Native Windows terminals aren’t supported. Export your Cursor key locally. cws-agent forwards it into the sandbox’s environment:
  1. Follow the cws-agent installation instructions.
  2. Replace [SANDBOX-NAME] with a session name containing 1 to 40 lowercase letters, digits, or hyphens, starting with a letter or digit. Replace [REPOSITORY-URL] with your repository URL:
    Cursor opens in /workspace/project. If a workspace trust prompt appears, accept it. --permission-mode native retains Cursor’s approval settings. cws-agent otherwise uses --force. --no-config-sync skips importing your local skills and Model Context Protocol (MCP) configuration.
  3. Ask Cursor to create a file you can retrieve:
    Approve any prompts for the task. Exit Cursor with /exit. In your local terminal, read the file:
    The output should be Hello from CoreWeave. Exiting Cursor leaves the sandbox running.
  4. After exiting all Cursor sessions in the sandbox, remove Cursor’s leftover worker.sock socket files, save the workspace, and stop compute:
    The cleanup removes socket files that can block snapshot creation. down takes a snapshot before stopping the sandbox. If snapshot creation fails, the sandbox stays running. Resolve the error and retry down before restoring.
  5. To return to the saved workspace, keep CURSOR_API_KEY exported locally and run:
    Ask Cursor to read the sandbox-proof.txt file to verify that it was restored. When finished, exit Cursor and repeat the cleanup and down commands.

Run an unattended prompt

Choose a new session name. In your local terminal, launch with --detach to skip terminal attachment, then send a prompt:
cws-agent run passes Cursor’s --force flag by default so the headless task can write files without interactive approval. Cursor retains explicit deny rules. To attach your terminal to the running session, run:
When finished, exit Cursor if attached, read the result with cws-agent exec, then clean up the sockets and save with cws-agent down as shown in Run Cursor CLI with cws-agent.

Run a task with the Sandbox SDK

Use the Sandbox SDK to manage a task directly. This path creates a separate sandbox, runs Cursor in print mode, retrieves the file, and stops the sandbox in a cleanup block. It doesn’t configure snapshots or require cws-agent.

Choose how to supply the Cursor key

Both scripts take an authentication mode as their first argument: W&B secret injection requires W&B authentication and serverless placement. It isn’t available with a CoreWeave API access token. These examples use serverless placement for both modes.
Ask a W&B administrator to add your Cursor key as a team secret. In your local terminal, replace [WANDB-TEAM] with your team name and [CURSOR-SECRET-NAME] with the secret name:
Your W&B API key must have access to that team. The scripts map the named secret to CURSOR_API_KEY inside the sandbox. See Use W&B secrets.

Install a client

Choose a language and install the client locally:
Use Python 3.11 or later and uv. In a new project directory, run:

Create, run, and clean up

Save the script for your language using the filename shown. Each script installs Cursor, clones the repository passed on the command line, and asks Cursor to write the sandbox-proof.txt file. The --print, --force, and --trust flags enable non-interactive output, permit file changes, and trust the workspace. Use this example only with a repository you trust. See Cursor headless mode.
run_cursor_sandbox.py
In the local terminal where you set your credentials, replace [AUTH-MODE] with wandb or coreweave, and [REPOSITORY-URL] with your repository URL:
The script prints Cursor’s response followed by the file contents, Hello from CoreWeave. The cleanup block calls stop() even if setup or execution raises an error. Retrieve any additional files before the cleanup block runs. For larger results, use file operations. The 2-hour lifetime is a maximum wall-clock limit, including startup. Each command also has its own timeout. Changing the command timeout doesn’t extend the sandbox lifetime.

Troubleshoot

Use these checks to resolve common issues:
  • If sandbox creation fails, verify the credential for your selected authentication mode.
  • If a W&B secret can’t be resolved, check WANDB_ENTITY, CURSOR_SECRET_NAME, and your API key’s team access.
  • If Cursor reports an authentication error, verify the key in your W&B secret or local CURSOR_API_KEY, and check your account’s model access.
  • If an SDK prompt only proposes changes, confirm that the Cursor command includes --force.
  • If installation, cloning, or model requests fail, check outbound connectivity and provider credentials. For CoreWeave Kubernetes Service (CKS) placement, your runner policy must allow the required destinations.

Next steps

For more information, see these guides:
Last modified on September 24, 2026